From 749a62f8df8c22662121d6fdf594aa2a06b8ae8a Mon Sep 17 00:00:00 2001 From: Steven Hicks Date: Thu, 23 Jan 2025 14:56:09 -0600 Subject: [PATCH 1/3] configure two 'next' versions --- docusaurus.config.js | 4 + .../DocsVersionDropdownNavbarItem.js | 86 +++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 src/theme/NavbarItem/DocsVersionDropdownNavbarItem.js diff --git a/docusaurus.config.js b/docusaurus.config.js index 0ef57fda0d6..6525ab15769 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -397,7 +397,11 @@ module.exports = { editUrl: "https://github.com/camunda/camunda-docs/edit/main/", beforeDefaultRemarkPlugins: [versionedLinks], // 👋 When cutting a new version, remove the banner for maintained versions by adding an entry. Remove the entry to versions >18 months old. + lastVersion: "8.5", versions: { + 8.6: { + label: "8.6 (unreleased)", + }, 8.5: { banner: "none", }, diff --git a/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.js b/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.js new file mode 100644 index 00000000000..3304a56a82f --- /dev/null +++ b/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.js @@ -0,0 +1,86 @@ +import React from "react"; +import { + useVersions, + useActiveDocContext, +} from "@docusaurus/plugin-content-docs/client"; +import { useDocsPreferredVersion } from "@docusaurus/theme-common"; +import { useDocsVersionCandidates } from "@docusaurus/theme-common/internal"; +import { translate } from "@docusaurus/Translate"; +import { useLocation } from "@docusaurus/router"; +import DefaultNavbarItem from "@theme/NavbarItem/DefaultNavbarItem"; +import DropdownNavbarItem from "@theme/NavbarItem/DropdownNavbarItem"; +const getVersionMainDoc = (version) => + version.docs.find((doc) => doc.id === version.mainDocId); +export default function DocsVersionDropdownNavbarItem({ + mobile, + docsPluginId, + dropdownActiveClassDisabled, + dropdownItemsBefore, + dropdownItemsAfter, + ...props +}) { + const { search, hash } = useLocation(); + const activeDocContext = useActiveDocContext(docsPluginId); + const versions = useVersions(docsPluginId); + const { savePreferredVersionName } = useDocsPreferredVersion(docsPluginId); + 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 versionDoc = + activeDocContext.alternateDocVersions[version.name] ?? + getVersionMainDoc(version); + let actualLabel = + version.label === "Next" ? "8.7 (unreleased)" : version.label; + return { + label: actualLabel, + // preserve ?search#hash suffix on version switches + to: `${versionDoc.path}${search}${hash}`, + isActive: () => version === activeDocContext.activeVersion, + onClick: () => savePreferredVersionName(version.name), + }; + }); + const items = [ + ...dropdownItemsBefore, + ...versionLinks, + ...dropdownItemsAfter, + ]; + const dropdownVersion = useDocsVersionCandidates(docsPluginId)[0]; + // Mobile dropdown is handled a bit differently + const dropdownLabel = + mobile && items.length > 1 + ? translate({ + id: "theme.navbar.mobileVersionsDropdown.label", + message: "Versions", + description: + "The label for the navbar versions dropdown on mobile view", + }) + : dropdownVersion.label; + const dropdownTo = + mobile && items.length > 1 + ? undefined + : getVersionMainDoc(dropdownVersion).path; + // We don't want to render a version dropdown with 0 or 1 item. If we build + // the site with a single docs version (onlyIncludeVersions: ['1.0.0']), + // We'd rather render a button instead of a dropdown + if (items.length <= 1) { + return ( + false : undefined} + /> + ); + } + return ( + false : undefined} + /> + ); +} From 50074abdccfdbfc02c82bff7df8aa21d0afe3e34 Mon Sep 17 00:00:00 2001 From: Steven Hicks Date: Thu, 23 Jan 2025 16:37:07 -0600 Subject: [PATCH 2/3] redo version overriding in a more robust way --- .../DocsVersionDropdownNavbarItem.js | 86 ------------------- src/theme/NavbarItem/DropdownNavbarItem.js | 25 ++++++ 2 files changed, 25 insertions(+), 86 deletions(-) delete mode 100644 src/theme/NavbarItem/DocsVersionDropdownNavbarItem.js create mode 100644 src/theme/NavbarItem/DropdownNavbarItem.js diff --git a/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.js b/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.js deleted file mode 100644 index 3304a56a82f..00000000000 --- a/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.js +++ /dev/null @@ -1,86 +0,0 @@ -import React from "react"; -import { - useVersions, - useActiveDocContext, -} from "@docusaurus/plugin-content-docs/client"; -import { useDocsPreferredVersion } from "@docusaurus/theme-common"; -import { useDocsVersionCandidates } from "@docusaurus/theme-common/internal"; -import { translate } from "@docusaurus/Translate"; -import { useLocation } from "@docusaurus/router"; -import DefaultNavbarItem from "@theme/NavbarItem/DefaultNavbarItem"; -import DropdownNavbarItem from "@theme/NavbarItem/DropdownNavbarItem"; -const getVersionMainDoc = (version) => - version.docs.find((doc) => doc.id === version.mainDocId); -export default function DocsVersionDropdownNavbarItem({ - mobile, - docsPluginId, - dropdownActiveClassDisabled, - dropdownItemsBefore, - dropdownItemsAfter, - ...props -}) { - const { search, hash } = useLocation(); - const activeDocContext = useActiveDocContext(docsPluginId); - const versions = useVersions(docsPluginId); - const { savePreferredVersionName } = useDocsPreferredVersion(docsPluginId); - 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 versionDoc = - activeDocContext.alternateDocVersions[version.name] ?? - getVersionMainDoc(version); - let actualLabel = - version.label === "Next" ? "8.7 (unreleased)" : version.label; - return { - label: actualLabel, - // preserve ?search#hash suffix on version switches - to: `${versionDoc.path}${search}${hash}`, - isActive: () => version === activeDocContext.activeVersion, - onClick: () => savePreferredVersionName(version.name), - }; - }); - const items = [ - ...dropdownItemsBefore, - ...versionLinks, - ...dropdownItemsAfter, - ]; - const dropdownVersion = useDocsVersionCandidates(docsPluginId)[0]; - // Mobile dropdown is handled a bit differently - const dropdownLabel = - mobile && items.length > 1 - ? translate({ - id: "theme.navbar.mobileVersionsDropdown.label", - message: "Versions", - description: - "The label for the navbar versions dropdown on mobile view", - }) - : dropdownVersion.label; - const dropdownTo = - mobile && items.length > 1 - ? undefined - : getVersionMainDoc(dropdownVersion).path; - // We don't want to render a version dropdown with 0 or 1 item. If we build - // the site with a single docs version (onlyIncludeVersions: ['1.0.0']), - // We'd rather render a button instead of a dropdown - if (items.length <= 1) { - return ( - false : undefined} - /> - ); - } - return ( - false : undefined} - /> - ); -} diff --git a/src/theme/NavbarItem/DropdownNavbarItem.js b/src/theme/NavbarItem/DropdownNavbarItem.js new file mode 100644 index 00000000000..8d2caca23fe --- /dev/null +++ b/src/theme/NavbarItem/DropdownNavbarItem.js @@ -0,0 +1,25 @@ +import React from "react"; +import DropdownNavbarItem from "@theme-original/NavbarItem/DropdownNavbarItem"; + +export default function DropdownNavbarItemWrapper({ label, items, ...props }) { + if (label === "Next") { + label = "8.7 (unreleased)"; + } + + items = items.map((item) => { + let { label } = item; + if (label === "Next") { + label = "8.7 (unreleased)"; + } + return { + ...item, + label, + }; + }); + + return ( + <> + + + ); +} From a70715c30e49a83cad7a95dc05418259b9b338ff Mon Sep 17 00:00:00 2001 From: Steven Hicks Date: Thu, 23 Jan 2025 16:53:15 -0600 Subject: [PATCH 3/3] turn off link errors --- docusaurus.config.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docusaurus.config.js b/docusaurus.config.js index 6525ab15769..b9b99214aaf 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -16,8 +16,8 @@ module.exports = { customFields: { canonicalUrlRoot: docsSiteUrl, }, - onBrokenLinks: "throw", - onBrokenMarkdownLinks: "throw", + onBrokenLinks: "warn", + onBrokenMarkdownLinks: "warn", favicon: "img/favicon.ico", organizationName: "camunda", // Usually your GitHub org/user name. projectName: "camunda-docs", // Usually your repo name.