You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/09/08 03:07:49 UTC

[GitHub] [pulsar-site] urfreespace commented on a diff in pull request #204: Version banner in docs pages

urfreespace commented on code in PR #204:
URL: https://github.com/apache/pulsar-site/pull/204#discussion_r965460847


##########
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:
   good idea, we just need to change the translation files



-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org