tisonkun commented on code in PR #204:
URL: https://github.com/apache/pulsar-site/pull/204#discussion_r965454293
##########
site2/website-next/src/theme/DocVersionBanner/index.js:
##########
@@ -0,0 +1,148 @@
+import React from "react";
+import clsx from "clsx";
+import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
+import Link from "@docusaurus/Link";
+import Translate from "@docusaurus/Translate";
+import {
+ useActivePlugin,
+ useDocVersionSuggestions,
+} from "@docusaurus/plugin-content-docs/client";
+import { ThemeClassNames } from "@docusaurus/theme-common";
+import {
+ useDocsPreferredVersion,
+ useDocsVersion,
+} from "@docusaurus/theme-common/internal";
+let versions = require("../../../versions.json");
+const _latestVersion = versions[0];
+function UnreleasedVersionLabel({ siteTitle, versionMetadata }) {
+ return (
+ <Translate
+ id="theme.docs.versions.unreleasedVersionLabel"
+ description="The label used to tell the user that he's browsing an
unreleased doc version"
+ values={{
+ siteTitle,
+ versionLabel: <b>{versionMetadata.label}</b>,
+ }}
+ >
+ {
+ "This is unreleased documentation for {siteTitle} {versionLabel}
version."
+ }
+ </Translate>
+ );
+}
+function UnmaintainedVersionLabel({ siteTitle, versionMetadata }) {
+ return (
+ <Translate
+ id="theme.docs.versions.unmaintainedVersionLabel"
+ description="The label used to tell the user that he's browsing an
unmaintained doc version"
+ values={{
+ siteTitle,
+ versionLabel: <b>{versionMetadata.label}</b>,
+ }}
+ >
+ {
+ "This is documentation for {siteTitle} {versionLabel}, which is no
longer actively maintained."
+ }
+ </Translate>
+ );
+}
+const BannerLabelComponents = {
+ unreleased: UnreleasedVersionLabel,
+ unmaintained: UnmaintainedVersionLabel,
+};
+function BannerLabel(props) {
+ let BannerLabelComponent = null;
+ if (props.versionMetadata.version == "current") {
+ BannerLabelComponent = BannerLabelComponents.unreleased;
+ } else if (props.versionMetadata.version != _latestVersion) {
+ BannerLabelComponent = BannerLabelComponents.unmaintained;
+ } else {
+ return <></>;
+ }
+ // const BannerLabelComponent =
+ // BannerLabelComponents[props.versionMetadata.banner];
+ return <BannerLabelComponent {...props} />;
+}
+function LatestVersionSuggestionLabel({ versionLabel, to, onClick }) {
+ return (
+ <Translate
+ id="theme.docs.versions.latestVersionSuggestionLabel"
+ description="The label used to tell the user to check the latest version"
+ values={{
+ versionLabel,
+ latestVersionLink: (
+ <b>
+ <Link to={to} onClick={onClick}>
+ <Translate
+ id="theme.docs.versions.latestVersionLinkLabel"
+ description="The label used for the latest version suggestion
link label"
+ >
+ latest version
+ </Translate>
+ </Link>
+ </b>
+ ),
+ }}
+ >
+ {
+ "For up-to-date documentation, see the {latestVersionLink}
({versionLabel})."
Review Comment:
Also, this wording can be improved in the NEXT version. Because NEXT is
newer than the latest stable version.
Docusaurus's wording is for all outdated versions. Flink writes:
> This documentation is for an unreleased version of Apache Flink. We
recommend you use the latest [stable
version](https://nightlies.apache.org/flink/flink-docs-stable/).
for [the master
version](https://nightlies.apache.org/flink/flink-docs-master/); and
> This documentation is for an out-of-date version of Apache Flink. We
recommend you use [the latest stable
version](https://ci.apache.org/projects/flink/flink-docs-stable/).
for [all old
versions](https://nightlies.apache.org/flink/flink-docs-release-1.12/)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]