You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by ur...@apache.org on 2022/12/06 02:01:56 UTC
[pulsar-site] 01/01: revert #288
This is an automated email from the ASF dual-hosted git repository.
urfree pushed a commit to branch revert-alias-search-issue
in repository https://gitbox.apache.org/repos/asf/pulsar-site.git
commit 486e8465380f21ca4ba66e612eef64faf1a202d4
Author: Li Li <ur...@apache.org>
AuthorDate: Tue Dec 6 09:59:43 2022 +0800
revert #288
Signed-off-by: Li Li <ur...@apache.org>
---
site2/website-next/docusaurus.config.js | 28 ++++++-----------
site2/website-next/preview.sh | 2 +-
.../src/theme/DocsVersionDropdownNavbarItem.js | 36 +++++++++++++++-------
3 files changed, 36 insertions(+), 30 deletions(-)
diff --git a/site2/website-next/docusaurus.config.js b/site2/website-next/docusaurus.config.js
index 46d550d8c80..0b7b1ba5eca 100644
--- a/site2/website-next/docusaurus.config.js
+++ b/site2/website-next/docusaurus.config.js
@@ -5,7 +5,7 @@ const linkifyRegex = require("./plugins/remark-linkify-regex");
const versions = require("./versions.json");
const versionsMap = {
..._.keyBy(
- versions.map((item) => {
+ versions.slice(1).map((item) => {
return {
label: item,
path: item,
@@ -153,7 +153,7 @@ module.exports = {
navbar: {
title: "",
logo: {
- alt: "pulsar logo",
+ alt: "pulasr logo",
src: "img/logo.svg",
},
items: [
@@ -178,7 +178,7 @@ module.exports = {
],
},
{
- to: `/docs/${versions[0]}/`,
+ href: "/docs/",
position: "right",
label: "Docs",
},
@@ -399,21 +399,13 @@ module.exports = {
],
],
plugins: [
- [
- '@docusaurus/plugin-client-redirects',
- /** @type {import('@docusaurus/plugin-client-redirects').Options} */
- {
- createRedirects(existingPath) {
- const latestVersion = versions[0];
- if (existingPath.includes(`/docs/${latestVersion}`)) {
- return [
- existingPath.replace(`/docs/${latestVersion}`, '/docs/'),
- ];
- }
- return undefined;
- },
- },
- ],
+ // [
+ // "client-redirects",
+ // /** @type {import('@docusaurus/plugin-client-redirects').Options} */
+ // ({
+ // fromExtensions: ["html"],
+ // }),
+ // ],
"./postcss-tailwind-loader",
[
'@docusaurus/plugin-content-docs',
diff --git a/site2/website-next/preview.sh b/site2/website-next/preview.sh
index 3ec43eebb98..8d332813d4a 100755
--- a/site2/website-next/preview.sh
+++ b/site2/website-next/preview.sh
@@ -8,4 +8,4 @@ BUILD_VERSIONS=$BUILD_VERSIONS"]"
echo $BUILD_VERSIONS >.build-versions.json
yarn install
-yarn start
+yarn start
\ No newline at end of file
diff --git a/site2/website-next/src/theme/DocsVersionDropdownNavbarItem.js b/site2/website-next/src/theme/DocsVersionDropdownNavbarItem.js
index 35bff76814f..d0fbd614815 100644
--- a/site2/website-next/src/theme/DocsVersionDropdownNavbarItem.js
+++ b/site2/website-next/src/theme/DocsVersionDropdownNavbarItem.js
@@ -4,21 +4,25 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
-import React from "react";
+import React, { version } from "react";
import DefaultNavbarItem from "@theme/NavbarItem/DefaultNavbarItem";
import DropdownNavbarItem from "@theme/NavbarItem/DropdownNavbarItem";
-import {useActiveDocContext, useLatestVersion,} from "@docusaurus/plugin-content-docs/client";
-import {useDocsPreferredVersion} from "@docusaurus/theme-common";
-import {translate} from "@docusaurus/Translate";
-
+import {
+ useVersions,
+ useLatestVersion,
+ useActiveDocContext,
+} from "@docusaurus/plugin-content-docs/client";
+import { useDocsPreferredVersion } from "@docusaurus/theme-common";
+import { translate } from "@docusaurus/Translate";
let versions = require("../../versions.json");
+const _latestVersion = versions[0];
versions = [{ name: "current", label: "Next", path: "/docs/next" }]
.concat(
versions.map((item) => {
return {
label: item,
name: item,
- path: "/docs/" + item,
+ path: item == _latestVersion ? "/docs" : "/docs/" + item,
};
})
)
@@ -41,6 +45,7 @@ export default function DocsVersionDropdownNavbarItem({
...props
}) {
const activeDocContext = useActiveDocContext(docsPluginId);
+ const _versions = useVersions(docsPluginId);
const latestVersion = useLatestVersion(docsPluginId);
const { preferredVersion, savePreferredVersionName } =
useDocsPreferredVersion(docsPluginId);
@@ -48,19 +53,28 @@ export default function DocsVersionDropdownNavbarItem({
const versionLinks = versions.map((version) => {
// We try to link to the same doc, in another version
// When not possible, fallback to the "main doc" of the version
- const _version = version.name === "current" ? "/next" : "/" + version.name;
- const _docId = activeDocContext.activeDoc.id === "about" ? "/" : "/" + activeDocContext.activeDoc.id;
+ const _version =
+ version.name == _latestVersion
+ ? ""
+ : version.name == "current"
+ ? "next/"
+ : version.name + "/";
+ const _docId =
+ activeDocContext.activeDoc.id == "about"
+ ? ""
+ : activeDocContext.activeDoc.id;
const versionDoc = {
- path: "/docs" + _version + _docId,
+ path: "/docs/" + _version + _docId,
};
return {
isNavLink: true,
label: version.label,
- to: "",
+ to: "", //iiversion.name == "others" ? "/versions" : versionDoc.path,
isActive: () => version.name === activeDocContext.activeVersion.name,
onClick: () => {
savePreferredVersionName(version.name);
- window.location.href = version.name === "others" ? "/versions" : versionDoc.path;
+ window.location.href =
+ version.name == "others" ? "/versions" : versionDoc.path;
},
};
});