From 265d2685c01946890ab5f9bfa48eb62c062d368f Mon Sep 17 00:00:00 2001 From: Jeroen van den Hout Date: Sat, 12 Aug 2023 14:39:45 +0200 Subject: [PATCH 01/14] Swizzle version banner --- src/theme/DocVersionBanner/index.tsx | 176 +++++++++++++++++++++++++++ 1 file changed, 176 insertions(+) create mode 100644 src/theme/DocVersionBanner/index.tsx diff --git a/src/theme/DocVersionBanner/index.tsx b/src/theme/DocVersionBanner/index.tsx new file mode 100644 index 00000000000..e7110db9110 --- /dev/null +++ b/src/theme/DocVersionBanner/index.tsx @@ -0,0 +1,176 @@ +import React, { type ComponentType } from 'react'; +import clsx from 'clsx'; +import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; +import Link from '@docusaurus/Link'; +import Translate from '@docusaurus/Translate'; +import { + useActivePlugin, + useDocVersionSuggestions, + type GlobalVersion, +} from '@docusaurus/plugin-content-docs/client'; +import { ThemeClassNames } from '@docusaurus/theme-common'; +import { + useDocsPreferredVersion, + useDocsVersion, +} from '@docusaurus/theme-common/internal'; +import type { Props } from '@theme/DocVersionBanner'; +import type { + VersionBanner, + PropVersionMetadata, +} from '@docusaurus/plugin-content-docs'; + +type BannerLabelComponentProps = { + siteTitle: string; + versionMetadata: PropVersionMetadata; +}; + +function UnreleasedVersionLabel({ + siteTitle, + versionMetadata, +}: BannerLabelComponentProps) { + return ( + {versionMetadata.label}, + }} + > + { + 'This is unreleased documentation for {siteTitle} {versionLabel} version.' + } + + ); +} + +function UnmaintainedVersionLabel({ + siteTitle, + versionMetadata, +}: BannerLabelComponentProps) { + return ( + {versionMetadata.label}, + }} + > + { + 'This is documentation for {siteTitle} {versionLabel}, which is no longer actively maintained.' + } + + ); +} + +const BannerLabelComponents: { + [banner in VersionBanner]: ComponentType; +} = { + unreleased: UnreleasedVersionLabel, + unmaintained: UnmaintainedVersionLabel, +}; + +function BannerLabel(props: BannerLabelComponentProps) { + const BannerLabelComponent = + BannerLabelComponents[props.versionMetadata.banner!]; + return ; +} + +function LatestVersionSuggestionLabel({ + versionLabel, + to, + onClick, +}: { + to: string; + onClick: () => void; + versionLabel: string; +}) { + return ( + + + + latest version + + + + ), + }} + > + { + 'For up-to-date documentation, see the {latestVersionLink} ({versionLabel}).' + } + + ); +} + +function DocVersionBannerEnabled({ + className, + versionMetadata, +}: Props & { + versionMetadata: PropVersionMetadata; +}): JSX.Element { + const { + siteConfig: { title: siteTitle }, + } = useDocusaurusContext(); + const { pluginId } = useActivePlugin({ failfast: true })!; + + const getVersionMainDoc = (version: GlobalVersion) => + version.docs.find((doc) => doc.id === version.mainDocId)!; + + const { savePreferredVersionName } = useDocsPreferredVersion(pluginId); + + const { latestDocSuggestion, latestVersionSuggestion } = + useDocVersionSuggestions(pluginId); + + // Try to link to same doc in latest version (not always possible), falling + // back to main doc of latest version + const latestVersionSuggestedDoc = + latestDocSuggestion ?? getVersionMainDoc(latestVersionSuggestion); + + return ( +
+
+ +
+
+ savePreferredVersionName(latestVersionSuggestion.name)} + /> +
+
+ ); +} + +export default function DocVersionBanner({ + className, +}: Props): JSX.Element | null { + const versionMetadata = useDocsVersion(); + if (versionMetadata.banner) { + return ( + + ); + } + return null; +} From f288acf4a8da7b9dd8839629068d7e4e25ee1e79 Mon Sep 17 00:00:00 2001 From: Jeroen van den Hout Date: Sat, 12 Aug 2023 14:51:22 +0200 Subject: [PATCH 02/14] Adjust deprecation message --- src/theme/DocVersionBanner/index.tsx | 30 ++++++++++++++-------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/theme/DocVersionBanner/index.tsx b/src/theme/DocVersionBanner/index.tsx index e7110db9110..a17b194bd96 100644 --- a/src/theme/DocVersionBanner/index.tsx +++ b/src/theme/DocVersionBanner/index.tsx @@ -57,9 +57,7 @@ function UnmaintainedVersionLabel({ versionLabel: {versionMetadata.label}, }} > - { - 'This is documentation for {siteTitle} {versionLabel}, which is no longer actively maintained.' - } + {'Version {versionLabel} is being deprecated.'} ); } @@ -91,24 +89,22 @@ function LatestVersionSuggestionLabel({ id='theme.docs.versions.latestVersionSuggestionLabel' description='The label used to tell the user to check the latest version' values={{ - versionLabel, latestVersionLink: ( - latest version + {'{versionLabel}'} ), }} > - { - 'For up-to-date documentation, see the {latestVersionLink} ({versionLabel}).' - } + {'The latest version is {latestVersionLink}.'} ); } @@ -149,13 +145,17 @@ function DocVersionBannerEnabled({
-
- savePreferredVersionName(latestVersionSuggestion.name)} - /> -
+ {latestVersionSuggestion.label !== versionMetadata.label && ( +
+ + savePreferredVersionName(latestVersionSuggestion.name) + } + /> +
+ )} ); } From 67f701dc0230694554d58ad7d2f37aab56bf2cf5 Mon Sep 17 00:00:00 2001 From: Jeroen van den Hout Date: Mon, 14 Aug 2023 08:42:50 +0200 Subject: [PATCH 03/14] Reswizzle version banner --- src/theme/DocVersionBanner/index.tsx | 30 ++++++++++++++-------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/theme/DocVersionBanner/index.tsx b/src/theme/DocVersionBanner/index.tsx index a17b194bd96..e7110db9110 100644 --- a/src/theme/DocVersionBanner/index.tsx +++ b/src/theme/DocVersionBanner/index.tsx @@ -57,7 +57,9 @@ function UnmaintainedVersionLabel({ versionLabel: {versionMetadata.label}, }} > - {'Version {versionLabel} is being deprecated.'} + { + 'This is documentation for {siteTitle} {versionLabel}, which is no longer actively maintained.' + } ); } @@ -89,22 +91,24 @@ function LatestVersionSuggestionLabel({ id='theme.docs.versions.latestVersionSuggestionLabel' description='The label used to tell the user to check the latest version' values={{ + versionLabel, latestVersionLink: ( - {'{versionLabel}'} + latest version ), }} > - {'The latest version is {latestVersionLink}.'} + { + 'For up-to-date documentation, see the {latestVersionLink} ({versionLabel}).' + } ); } @@ -145,17 +149,13 @@ function DocVersionBannerEnabled({
- {latestVersionSuggestion.label !== versionMetadata.label && ( -
- - savePreferredVersionName(latestVersionSuggestion.name) - } - /> -
- )} +
+ savePreferredVersionName(latestVersionSuggestion.name)} + /> +
); } From 0f6a8cf19525d9ef2607c65dd85974bb13c30025 Mon Sep 17 00:00:00 2001 From: Jeroen van den Hout Date: Tue, 15 Aug 2023 15:38:44 +0200 Subject: [PATCH 04/14] Allow custom banner components --- plugins/docs/src/index.ts | 44 ++++++++++++++++++++++++++-- src/theme/DocVersionBanner/index.tsx | 41 +++++++++++++++++++------- 2 files changed, 72 insertions(+), 13 deletions(-) diff --git a/plugins/docs/src/index.ts b/plugins/docs/src/index.ts index bc27d7b5875..350dad5a3e5 100644 --- a/plugins/docs/src/index.ts +++ b/plugins/docs/src/index.ts @@ -105,10 +105,48 @@ export function validateOptions({ validate, options, }: OptionValidationContext): PluginOptions { - const { bannerPath, globalSidebars = [], ...docsOptions } = options; + const { versions = {}, globalSidebars = [], ...docsOptions } = options; + + const versionEntries = Object.entries(versions); + if (versionEntries.length > 1) + throw 'Multiple Docusuaurus doc versions not allowed in the Wiki'; + + // Handle version banner. + const versionBannerMap = {}; + const docsVersionEntries = versionEntries.map( + ([versionLabel, versionOptions]) => { + // TODO: validate banner + const { banner, ...docsVersionOptions } = versionOptions; + versionBannerMap[versionLabel] = banner; + return [versionLabel, docsVersionOptions]; + }, + ); + + const validatedDocsOptions = docsValidateOptions({ + validate, + options: { + ...docsOptions, + versions: Object.fromEntries(docsVersionEntries), + }, + }); + + // Re-add banner. + validatedDocsOptions.versions = Object.fromEntries( + Object.entries(validatedDocsOptions.versions).map( + ([versionLabel, versionOptions]) => { + return [ + versionLabel, + { + ...versionOptions, + banner: versionBannerMap[versionLabel], + }, + ]; + }, + ), + ); + return { - ...docsValidateOptions({ validate, options: docsOptions }), + ...validatedDocsOptions, globalSidebars, - bannerPath, }; } diff --git a/src/theme/DocVersionBanner/index.tsx b/src/theme/DocVersionBanner/index.tsx index e7110db9110..d7732d612d1 100644 --- a/src/theme/DocVersionBanner/index.tsx +++ b/src/theme/DocVersionBanner/index.tsx @@ -1,3 +1,11 @@ +/** + * SWIZZLED VERSION: 2.4.1 + * REASONS: + * - Remove use of siteTitle as it is irrelevant in our setup. + * - Link to our own latest version. + * - Add `deprecated` banner. + */ + import React, { type ComponentType } from 'react'; import clsx from 'clsx'; import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; @@ -19,13 +27,14 @@ import type { PropVersionMetadata, } from '@docusaurus/plugin-content-docs'; +type WikiVersionBanner = VersionBanner & 'deprecated'; + type BannerLabelComponentProps = { siteTitle: string; versionMetadata: PropVersionMetadata; }; function UnreleasedVersionLabel({ - siteTitle, versionMetadata, }: BannerLabelComponentProps) { return ( @@ -33,19 +42,15 @@ function UnreleasedVersionLabel({ id='theme.docs.versions.unreleasedVersionLabel' description="The label used to tell the user that he's browsing an unreleased doc version" values={{ - siteTitle, versionLabel: {versionMetadata.label}, }} > - { - 'This is unreleased documentation for {siteTitle} {versionLabel} version.' - } + {'This is unreleased documentation for {versionLabel} version.'} ); } function UnmaintainedVersionLabel({ - siteTitle, versionMetadata, }: BannerLabelComponentProps) { return ( @@ -53,22 +58,38 @@ function UnmaintainedVersionLabel({ id='theme.docs.versions.unmaintainedVersionLabel' description="The label used to tell the user that he's browsing an unmaintained doc version" values={{ - siteTitle, versionLabel: {versionMetadata.label}, }} > { - 'This is documentation for {siteTitle} {versionLabel}, which is no longer actively maintained.' + 'This is documentation for {versionLabel}, which is no longer actively maintained.' } ); } +function DeprecatedVersionLabel({ + versionMetadata, +}: BannerLabelComponentProps) { + return ( + {versionMetadata.label}, + }} + > + {'This is documentation for {versionLabel}, which is being deprecated.'} + + ); +} + const BannerLabelComponents: { - [banner in VersionBanner]: ComponentType; + [banner in WikiVersionBanner]: ComponentType; } = { unreleased: UnreleasedVersionLabel, unmaintained: UnmaintainedVersionLabel, + deprecated: DeprecatedVersionLabel, }; function BannerLabel(props: BannerLabelComponentProps) { @@ -149,7 +170,7 @@ function DocVersionBannerEnabled({
-
+
Date: Tue, 28 May 2024 00:34:16 +0200 Subject: [PATCH 05/14] Fix config generator --- src/utils/pluginConfigGenerators.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/utils/pluginConfigGenerators.js b/src/utils/pluginConfigGenerators.js index 864841a20a6..48d4d344755 100644 --- a/src/utils/pluginConfigGenerators.js +++ b/src/utils/pluginConfigGenerators.js @@ -23,7 +23,7 @@ function generatePluginConfig(pluginConfig, basePath) { return doc.versions.map((version) => { // eslint-disable-next-line @typescript-eslint/no-unused-vars - const { label, badges, ...rest } = version; + const { label, badges, banner, ...rest } = version; // TODO: This could be removed once we don't use points in paths anymore. const plugin_name_path = doc.routeBasePath ? doc.routeBasePath : doc.id; @@ -43,6 +43,7 @@ function generatePluginConfig(pluginConfig, basePath) { label, path: mainVersion.label === label ? undefined : label, badge: true, + banner: banner, }, }, } From 25ae3dfe5db33efb381c62ed1c968f9b8a17266a Mon Sep 17 00:00:00 2001 From: Dr-Electron Date: Tue, 28 May 2024 00:42:14 +0200 Subject: [PATCH 06/14] Re-swizzle version banner --- src/theme/DocVersionBanner/index.tsx | 80 ++++++++++------------------ 1 file changed, 27 insertions(+), 53 deletions(-) diff --git a/src/theme/DocVersionBanner/index.tsx b/src/theme/DocVersionBanner/index.tsx index d7732d612d1..ba20ad5a0c3 100644 --- a/src/theme/DocVersionBanner/index.tsx +++ b/src/theme/DocVersionBanner/index.tsx @@ -1,12 +1,4 @@ -/** - * SWIZZLED VERSION: 2.4.1 - * REASONS: - * - Remove use of siteTitle as it is irrelevant in our setup. - * - Link to our own latest version. - * - Add `deprecated` banner. - */ - -import React, { type ComponentType } from 'react'; +import React, {type ComponentType} from 'react'; import clsx from 'clsx'; import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; import Link from '@docusaurus/Link'; @@ -16,80 +8,65 @@ import { useDocVersionSuggestions, type GlobalVersion, } from '@docusaurus/plugin-content-docs/client'; -import { ThemeClassNames } from '@docusaurus/theme-common'; +import {ThemeClassNames} from '@docusaurus/theme-common'; import { useDocsPreferredVersion, useDocsVersion, } from '@docusaurus/theme-common/internal'; -import type { Props } from '@theme/DocVersionBanner'; +import type {Props} from '@theme/DocVersionBanner'; import type { VersionBanner, PropVersionMetadata, } from '@docusaurus/plugin-content-docs'; -type WikiVersionBanner = VersionBanner & 'deprecated'; - type BannerLabelComponentProps = { siteTitle: string; versionMetadata: PropVersionMetadata; }; function UnreleasedVersionLabel({ + siteTitle, versionMetadata, }: BannerLabelComponentProps) { return ( {versionMetadata.label}, - }} - > - {'This is unreleased documentation for {versionLabel} version.'} + }}> + { + 'This is unreleased documentation for {siteTitle} {versionLabel} version.' + } ); } function UnmaintainedVersionLabel({ + siteTitle, versionMetadata, }: BannerLabelComponentProps) { return ( {versionMetadata.label}, - }} - > + }}> { - 'This is documentation for {versionLabel}, which is no longer actively maintained.' + 'This is documentation for {siteTitle} {versionLabel}, which is no longer actively maintained.' } ); } -function DeprecatedVersionLabel({ - versionMetadata, -}: BannerLabelComponentProps) { - return ( - {versionMetadata.label}, - }} - > - {'This is documentation for {versionLabel}, which is being deprecated.'} - - ); -} - const BannerLabelComponents: { - [banner in WikiVersionBanner]: ComponentType; + [banner in VersionBanner]: ComponentType; } = { unreleased: UnreleasedVersionLabel, unmaintained: UnmaintainedVersionLabel, - deprecated: DeprecatedVersionLabel, }; function BannerLabel(props: BannerLabelComponentProps) { @@ -109,24 +86,22 @@ function LatestVersionSuggestionLabel({ }) { return ( + id="theme.docs.versions.latestVersionLinkLabel" + description="The label used for the latest version suggestion link label"> latest version ), - }} - > + }}> { 'For up-to-date documentation, see the {latestVersionLink} ({versionLabel}).' } @@ -141,16 +116,16 @@ function DocVersionBannerEnabled({ versionMetadata: PropVersionMetadata; }): JSX.Element { const { - siteConfig: { title: siteTitle }, + siteConfig: {title: siteTitle}, } = useDocusaurusContext(); - const { pluginId } = useActivePlugin({ failfast: true })!; + const {pluginId} = useActivePlugin({failfast: true})!; const getVersionMainDoc = (version: GlobalVersion) => version.docs.find((doc) => doc.id === version.mainDocId)!; - const { savePreferredVersionName } = useDocsPreferredVersion(pluginId); + const {savePreferredVersionName} = useDocsPreferredVersion(pluginId); - const { latestDocSuggestion, latestVersionSuggestion } = + const {latestDocSuggestion, latestVersionSuggestion} = useDocVersionSuggestions(pluginId); // Try to link to same doc in latest version (not always possible), falling @@ -165,12 +140,11 @@ function DocVersionBannerEnabled({ ThemeClassNames.docs.docVersionBanner, 'alert alert--warning margin-bottom--md', )} - role='alert' - > + role="alert">
-
+
Date: Tue, 28 May 2024 14:43:32 +0200 Subject: [PATCH 07/14] Format --- src/theme/DocVersionBanner/index.tsx | 41 ++++++++++++++++------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/src/theme/DocVersionBanner/index.tsx b/src/theme/DocVersionBanner/index.tsx index ba20ad5a0c3..e7110db9110 100644 --- a/src/theme/DocVersionBanner/index.tsx +++ b/src/theme/DocVersionBanner/index.tsx @@ -1,4 +1,4 @@ -import React, {type ComponentType} from 'react'; +import React, { type ComponentType } from 'react'; import clsx from 'clsx'; import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; import Link from '@docusaurus/Link'; @@ -8,12 +8,12 @@ import { useDocVersionSuggestions, type GlobalVersion, } from '@docusaurus/plugin-content-docs/client'; -import {ThemeClassNames} from '@docusaurus/theme-common'; +import { ThemeClassNames } from '@docusaurus/theme-common'; import { useDocsPreferredVersion, useDocsVersion, } from '@docusaurus/theme-common/internal'; -import type {Props} from '@theme/DocVersionBanner'; +import type { Props } from '@theme/DocVersionBanner'; import type { VersionBanner, PropVersionMetadata, @@ -30,12 +30,13 @@ function UnreleasedVersionLabel({ }: BannerLabelComponentProps) { return ( {versionMetadata.label}, - }}> + }} + > { 'This is unreleased documentation for {siteTitle} {versionLabel} version.' } @@ -49,12 +50,13 @@ function UnmaintainedVersionLabel({ }: BannerLabelComponentProps) { return ( {versionMetadata.label}, - }}> + }} + > { 'This is documentation for {siteTitle} {versionLabel}, which is no longer actively maintained.' } @@ -86,22 +88,24 @@ function LatestVersionSuggestionLabel({ }) { return ( + id='theme.docs.versions.latestVersionLinkLabel' + description='The label used for the latest version suggestion link label' + > latest version ), - }}> + }} + > { 'For up-to-date documentation, see the {latestVersionLink} ({versionLabel}).' } @@ -116,16 +120,16 @@ function DocVersionBannerEnabled({ versionMetadata: PropVersionMetadata; }): JSX.Element { const { - siteConfig: {title: siteTitle}, + siteConfig: { title: siteTitle }, } = useDocusaurusContext(); - const {pluginId} = useActivePlugin({failfast: true})!; + const { pluginId } = useActivePlugin({ failfast: true })!; const getVersionMainDoc = (version: GlobalVersion) => version.docs.find((doc) => doc.id === version.mainDocId)!; - const {savePreferredVersionName} = useDocsPreferredVersion(pluginId); + const { savePreferredVersionName } = useDocsPreferredVersion(pluginId); - const {latestDocSuggestion, latestVersionSuggestion} = + const { latestDocSuggestion, latestVersionSuggestion } = useDocVersionSuggestions(pluginId); // Try to link to same doc in latest version (not always possible), falling @@ -140,11 +144,12 @@ function DocVersionBannerEnabled({ ThemeClassNames.docs.docVersionBanner, 'alert alert--warning margin-bottom--md', )} - role="alert"> + role='alert' + >
-
+
Date: Tue, 28 May 2024 14:43:54 +0200 Subject: [PATCH 08/14] Link to our own latest version --- src/theme/DocVersionBanner/index.tsx | 34 +++++++++++++++++----------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/src/theme/DocVersionBanner/index.tsx b/src/theme/DocVersionBanner/index.tsx index e7110db9110..aadee9e1623 100644 --- a/src/theme/DocVersionBanner/index.tsx +++ b/src/theme/DocVersionBanner/index.tsx @@ -1,23 +1,27 @@ +/** + * SWIZZLED VERSION: 2.4.3 + * REASONS: + * - Link to our own latest version. + */ import React, { type ComponentType } from 'react'; import clsx from 'clsx'; import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; import Link from '@docusaurus/Link'; import Translate from '@docusaurus/Translate'; -import { - useActivePlugin, - useDocVersionSuggestions, - type GlobalVersion, -} from '@docusaurus/plugin-content-docs/client'; +import { type GlobalVersion } from '@docusaurus/plugin-content-docs/client'; import { ThemeClassNames } from '@docusaurus/theme-common'; -import { - useDocsPreferredVersion, - useDocsVersion, -} from '@docusaurus/theme-common/internal'; +import { useDocsVersion } from '@docusaurus/theme-common/internal'; import type { Props } from '@theme/DocVersionBanner'; import type { VersionBanner, PropVersionMetadata, } from '@docusaurus/plugin-content-docs'; +import { useWikiPreferredVersion } from '@site/src/utils/wikiPreferredVersion'; +import { useLocation } from '@docusaurus/router'; +import { + useAllLatestVersion, + useCurrentDocPlugins, +} from '@site/src/utils/wikiVersion'; type BannerLabelComponentProps = { siteTitle: string; @@ -122,15 +126,19 @@ function DocVersionBannerEnabled({ const { siteConfig: { title: siteTitle }, } = useDocusaurusContext(); - const { pluginId } = useActivePlugin({ failfast: true })!; + const { pathname } = useLocation(); + const pluginIds = useCurrentDocPlugins(pathname); const getVersionMainDoc = (version: GlobalVersion) => version.docs.find((doc) => doc.id === version.mainDocId)!; - const { savePreferredVersionName } = useDocsPreferredVersion(pluginId); + const { savePreferredVersionName } = useWikiPreferredVersion( + pathname, + pluginIds, + ); - const { latestDocSuggestion, latestVersionSuggestion } = - useDocVersionSuggestions(pluginId); + const latestVersionSuggestion = useAllLatestVersion(pluginIds); + const latestDocSuggestion = getVersionMainDoc(latestVersionSuggestion); // Try to link to same doc in latest version (not always possible), falling // back to main doc of latest version From d6e483396786a7424caf6021d6b9d9ad054570ba Mon Sep 17 00:00:00 2001 From: Dr-Electron Date: Tue, 28 May 2024 15:27:14 +0200 Subject: [PATCH 09/14] Remove siteTitle --- src/theme/DocVersionBanner/index.tsx | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/theme/DocVersionBanner/index.tsx b/src/theme/DocVersionBanner/index.tsx index aadee9e1623..fa251eff7c9 100644 --- a/src/theme/DocVersionBanner/index.tsx +++ b/src/theme/DocVersionBanner/index.tsx @@ -1,6 +1,7 @@ /** * SWIZZLED VERSION: 2.4.3 * REASONS: + * - Remove use of siteTitle as it is irrelevant in our setup. * - Link to our own latest version. */ import React, { type ComponentType } from 'react'; @@ -29,7 +30,6 @@ type BannerLabelComponentProps = { }; function UnreleasedVersionLabel({ - siteTitle, versionMetadata, }: BannerLabelComponentProps) { return ( @@ -37,19 +37,17 @@ function UnreleasedVersionLabel({ id='theme.docs.versions.unreleasedVersionLabel' description="The label used to tell the user that he's browsing an unreleased doc version" values={{ - siteTitle, versionLabel: {versionMetadata.label}, }} > { - 'This is unreleased documentation for {siteTitle} {versionLabel} version.' + 'This is unreleased documentation for {versionLabel} version.' } ); } function UnmaintainedVersionLabel({ - siteTitle, versionMetadata, }: BannerLabelComponentProps) { return ( @@ -57,12 +55,11 @@ function UnmaintainedVersionLabel({ id='theme.docs.versions.unmaintainedVersionLabel' description="The label used to tell the user that he's browsing an unmaintained doc version" values={{ - siteTitle, versionLabel: {versionMetadata.label}, }} > { - 'This is documentation for {siteTitle} {versionLabel}, which is no longer actively maintained.' + 'This is documentation for {versionLabel}, which is no longer actively maintained.' } ); From 5dea944157b5376188044c497e236670d90412c8 Mon Sep 17 00:00:00 2001 From: Dr-Electron Date: Tue, 28 May 2024 22:10:41 +0200 Subject: [PATCH 10/14] Remove banner logic --- plugins/docs/src/index.ts | 57 ++------------ plugins/docs/src/types.d.ts | 11 --- src/theme/DocItem/Layout/index.tsx | 69 ---------------- src/theme/DocItem/Layout/styles.module.css | 10 --- theme/package.json | 8 +- theme/src/theme/DocBanner/index.tsx | 17 ---- theme/src/theme/DocBanner/styles.css | 7 -- theme/src/types.d.ts | 4 - yarn.lock | 92 +--------------------- 9 files changed, 12 insertions(+), 263 deletions(-) delete mode 100644 src/theme/DocItem/Layout/index.tsx delete mode 100644 src/theme/DocItem/Layout/styles.module.css delete mode 100644 theme/src/theme/DocBanner/index.tsx delete mode 100644 theme/src/theme/DocBanner/styles.css diff --git a/plugins/docs/src/index.ts b/plugins/docs/src/index.ts index 350dad5a3e5..f41fb0be77b 100644 --- a/plugins/docs/src/index.ts +++ b/plugins/docs/src/index.ts @@ -1,59 +1,25 @@ import type { LoadContext, Plugin } from '@docusaurus/types'; -import { LoadedContent, OptionValidationContext, PluginOptions } from './types'; +import { OptionValidationContext, PluginOptions } from './types'; import docsPlugin, { validateOptions as docsValidateOptions, + LoadedContent as DocsContentLoaded, PropVersionMetadata, } from '@docusaurus/plugin-content-docs'; -import fs from 'fs/promises'; -import path from 'path'; export default async function pluginDocs( context: LoadContext, options: PluginOptions, -): Promise> { +): Promise> { // Destructure to separate the Docusaurus docs plugin options // and initialize the Docusaurus docs plugin to wrap. - const { bannerPath, globalSidebars, ...docsOptions } = options; + const { globalSidebars, ...docsOptions } = options; const plugin = await docsPlugin(context, docsOptions); return { ...plugin, - getPathsToWatch: () => { - const pathsToWatch = plugin.getPathsToWatch(); - - if (bannerPath) - pathsToWatch.push(path.resolve(context.siteDir, bannerPath)); - - return pathsToWatch; - }, - loadContent: async () => { - const docsLoadedContent = await plugin.loadContent(); - return { - ...docsLoadedContent, - // Load banner content from file - bannerContent: bannerPath - ? await fs.readFile(bannerPath, { - encoding: 'utf-8', - }) - : undefined, - }; - }, - translateContent: ({ content, ...args }) => { - // Propagate banner content - const { bannerContent, ...docsContent } = content; - const docsContentLoaded = plugin.translateContent({ - content: docsContent, - ...args, - }); - return { - ...docsContentLoaded, - bannerContent, - }; - }, // Override the `contentLoaded` function to add sidebars to the // global data exposed by the Docusaurus docs plugin. contentLoaded: async ({ actions, content, ...args }) => { - const { bannerContent, ...docsContent } = content; const globalSidebarEntries = []; const createData = async (name: string, data: string) => { @@ -67,18 +33,7 @@ export default async function pluginDocs( .forEach((entry) => globalSidebarEntries.push(entry)); } - return await actions.createData( - name, - // Expose banner content to be used by the DocBanner theme component - JSON.stringify( - { - ...versionMetadata, - bannerContent, - }, - null, - 2, - ), - ); + return await actions.createData(name, data); }; const setGlobalData = (data: object) => { @@ -90,7 +45,7 @@ export default async function pluginDocs( await plugin.contentLoaded({ ...args, - content: docsContent, + content, actions: { ...actions, createData, diff --git a/plugins/docs/src/types.d.ts b/plugins/docs/src/types.d.ts index 4e4e03b0a83..572ba55a8f7 100644 --- a/plugins/docs/src/types.d.ts +++ b/plugins/docs/src/types.d.ts @@ -1,25 +1,14 @@ import { Options as DocsOptions, PluginOptions as DocsPluginOptions, - LoadedContent as DocsLoadedContent, - DocMetadata as DocsDocMetadata, } from '@docusaurus/plugin-content-docs'; import { OptionValidationContext as DocsOptionValidationContext, Validate, } from '@docusaurus/types'; -export type DocMetadata = DocsDocMetadata & { - bannerContent?: string; -}; - -export type LoadedContent = DocsLoadedContent & { - bannerContent?: string; -}; - export type PluginOptions = DocsPluginOptions & { globalSidebars: string[]; - bannerPath?: string; }; export type Options = Partial; diff --git a/src/theme/DocItem/Layout/index.tsx b/src/theme/DocItem/Layout/index.tsx deleted file mode 100644 index bd5419b2661..00000000000 --- a/src/theme/DocItem/Layout/index.tsx +++ /dev/null @@ -1,69 +0,0 @@ -/** - * SWIZZLED VERSION: 2.4.1 - * REASONS: - * - Add custom Banner component. - */ - -import React from 'react'; -import clsx from 'clsx'; -import { useWindowSize } from '@docusaurus/theme-common'; -import { useDoc } from '@docusaurus/theme-common/internal'; -import DocItemPaginator from '@theme/DocItem/Paginator'; -import DocVersionBanner from '@theme/DocVersionBanner'; -import DocVersionBadge from '@theme/DocVersionBadge'; -import DocItemFooter from '@theme/DocItem/Footer'; -import DocItemTOCMobile from '@theme/DocItem/TOC/Mobile'; -import DocItemTOCDesktop from '@theme/DocItem/TOC/Desktop'; -import DocItemContent from '@theme/DocItem/Content'; -import DocBreadcrumbs from '@theme/DocBreadcrumbs'; -import type { Props } from '@theme/DocItem/Layout'; -import DocBanner from '@theme/DocBanner'; - -import styles from './styles.module.css'; - -/** - * Decide if the toc should be rendered, on mobile or desktop viewports - */ -function useDocTOC() { - const { frontMatter, toc } = useDoc(); - const windowSize = useWindowSize(); - - const hidden = frontMatter.hide_table_of_contents; - const canRender = !hidden && toc.length > 0; - - const mobile = canRender ? : undefined; - - const desktop = - canRender && (windowSize === 'desktop' || windowSize === 'ssr') ? ( - - ) : undefined; - - return { - hidden, - mobile, - desktop, - }; -} - -export default function DocItemLayout({ children }: Props): JSX.Element { - const docTOC = useDocTOC(); - return ( -
-
- - -
-
- - - {docTOC.mobile} - {children} - -
- -
-
- {docTOC.desktop &&
{docTOC.desktop}
} -
- ); -} diff --git a/src/theme/DocItem/Layout/styles.module.css b/src/theme/DocItem/Layout/styles.module.css deleted file mode 100644 index d5aaec1322c..00000000000 --- a/src/theme/DocItem/Layout/styles.module.css +++ /dev/null @@ -1,10 +0,0 @@ -.docItemContainer header + *, -.docItemContainer article > *:first-child { - margin-top: 0; -} - -@media (min-width: 997px) { - .docItemCol { - max-width: 75% !important; - } -} diff --git a/theme/package.json b/theme/package.json index a6cefe462c0..20157c633d4 100644 --- a/theme/package.json +++ b/theme/package.json @@ -6,8 +6,7 @@ "types": "src/types.d.ts", "license": "MIT", "scripts": { - "copy": "copyfiles -u 1 \"./src/**/*.css\" \"./dist\"", - "build": "tsc --build && yarn copy && prettier --config ../.prettierrc.json --write \"dist/theme/**/*.js\"", + "build": "tsc --build && prettier --config ../.prettierrc.json --write \"dist/theme/**/*.js\"", "watch": "nodemon --watch src --ext '*' --exec yarn build", "prepack": "yarn build", "test": "jest" @@ -15,12 +14,9 @@ "dependencies": { "@artsy/to-title-case": "^1.1.0", "@docusaurus/theme-classic": "2.4.3", - "@docusaurus/theme-common": "2.4.3", - "@iota-wiki/plugin-docs": "workspace:^", "@metamask/providers": "^10.2.1", "clsx": "^1.2.1", - "html-react-parser": "^4.2.10", - "react-markdown": "6", + "html-react-parser": "^4.0.0", "web3": "^4.2.2" }, "devDependencies": { diff --git a/theme/src/theme/DocBanner/index.tsx b/theme/src/theme/DocBanner/index.tsx deleted file mode 100644 index 7e01bbf6946..00000000000 --- a/theme/src/theme/DocBanner/index.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import React from 'react'; -import { useDoc } from '@docusaurus/theme-common/internal'; -import { DocMetadata } from '@iota-wiki/plugin-docs'; -import ReactMarkdown from 'react-markdown'; -import './styles.css'; - -export default function DocBanner() { - const { bannerContent } = useDoc().metadata as DocMetadata; - - if (!bannerContent) return null; - - return ( - - {bannerContent} - - ); -} diff --git a/theme/src/theme/DocBanner/styles.css b/theme/src/theme/DocBanner/styles.css deleted file mode 100644 index 6af2f55eacf..00000000000 --- a/theme/src/theme/DocBanner/styles.css +++ /dev/null @@ -1,7 +0,0 @@ -.doc-banner p { - margin: 0; -} - -.doc-banner p + p { - margin: var(--ifm-paragraph-margin-bottom) 0 0; -} diff --git a/theme/src/types.d.ts b/theme/src/types.d.ts index e6678212569..6c936e73358 100644 --- a/theme/src/types.d.ts +++ b/theme/src/types.d.ts @@ -17,10 +17,6 @@ declare module '@theme/AddToMetaMaskButton' { export default function AddToMetaMaskButton(): JSX.Element; } -declare module '@theme/DocBanner' { - export default function DocBanner(): JSX.Element; -} - declare module '@theme/NetworkInfo' { export default { IOTA: JSX.Element, diff --git a/yarn.lock b/yarn.lock index 8e3516a2cec..d12e1b0a632 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2918,18 +2918,15 @@ __metadata: dependencies: "@artsy/to-title-case": ^1.1.0 "@docusaurus/theme-classic": 2.4.3 - "@docusaurus/theme-common": 2.4.3 "@docusaurus/types": 2.4.3 - "@iota-wiki/plugin-docs": "workspace:^" "@metamask/providers": ^10.2.1 "@types/react": 18.2.71 clsx: ^1.2.1 copyfiles: ^2.4.1 - html-react-parser: ^4.2.10 + html-react-parser: ^4.0.0 nodemon: ^2.0.16 prettier: ^2.8.8 react: 18.2.0 - react-markdown: 6 typescript: ^4.9 web3: ^4.2.2 peerDependencies: @@ -11209,7 +11206,7 @@ __metadata: languageName: node linkType: hard -"html-react-parser@npm:^4.2.10": +"html-react-parser@npm:^4.0.0": version: 4.2.10 resolution: "html-react-parser@npm:4.2.10" dependencies: @@ -13378,19 +13375,6 @@ __metadata: languageName: node linkType: hard -"mdast-util-from-markdown@npm:^0.8.0": - version: 0.8.5 - resolution: "mdast-util-from-markdown@npm:0.8.5" - dependencies: - "@types/mdast": ^3.0.0 - mdast-util-to-string: ^2.0.0 - micromark: ~2.11.0 - parse-entities: ^2.0.0 - unist-util-stringify-position: ^2.0.0 - checksum: 5a9d0d753a42db763761e874c22365d0c7c9934a5a18b5ff76a0643610108a208a041ffdb2f3d3dd1863d3d915225a4020a0aade282af0facfd0df110601eee6 - languageName: node - linkType: hard - "mdast-util-from-markdown@npm:^1.0.0": version: 1.3.1 resolution: "mdast-util-from-markdown@npm:1.3.1" @@ -13437,22 +13421,6 @@ __metadata: languageName: node linkType: hard -"mdast-util-to-hast@npm:^10.2.0": - version: 10.2.0 - resolution: "mdast-util-to-hast@npm:10.2.0" - dependencies: - "@types/mdast": ^3.0.0 - "@types/unist": ^2.0.0 - mdast-util-definitions: ^4.0.0 - mdurl: ^1.0.0 - unist-builder: ^2.0.0 - unist-util-generated: ^1.0.0 - unist-util-position: ^3.0.0 - unist-util-visit: ^2.0.0 - checksum: 72df2dd9bfa2d07b4750a333444f82e0f3752dae75b6e300cf0a716407a185eb75095a54ecad90cbd6f6d133b20dea8844ff76c1ea78612550de170b43d4fa85 - languageName: node - linkType: hard - "mdast-util-to-hast@npm:^12.1.0": version: 12.3.0 resolution: "mdast-util-to-hast@npm:12.3.0" @@ -13834,16 +13802,6 @@ __metadata: languageName: node linkType: hard -"micromark@npm:~2.11.0": - version: 2.11.4 - resolution: "micromark@npm:2.11.4" - dependencies: - debug: ^4.0.0 - parse-entities: ^2.0.0 - checksum: f8a5477d394908a5d770227aea71657a76423d420227c67ea0699e659a5f62eb39d504c1f7d69ec525a6af5aaeb6a7bffcdba95614968c03d41d3851edecb0d6 - languageName: node - linkType: hard - "micromatch@npm:4.0.5, micromatch@npm:^4.0.2, micromatch@npm:^4.0.4, micromatch@npm:^4.0.5": version: 4.0.5 resolution: "micromatch@npm:4.0.5" @@ -16472,7 +16430,7 @@ plugin-image-zoom@flexanalytics/plugin-image-zoom: languageName: node linkType: hard -"react-is@npm:^17.0.0, react-is@npm:^17.0.2": +"react-is@npm:^17.0.2": version: 17.0.2 resolution: "react-is@npm:17.0.2" checksum: 9d6d111d8990dc98bc5402c1266a808b0459b5d54830bbea24c12d908b536df7883f268a7868cfaedde3dd9d4e0d574db456f84d2e6df9c4526f99bb4b5344d8 @@ -16541,30 +16499,6 @@ plugin-image-zoom@flexanalytics/plugin-image-zoom: languageName: node linkType: hard -"react-markdown@npm:6": - version: 6.0.3 - resolution: "react-markdown@npm:6.0.3" - dependencies: - "@types/hast": ^2.0.0 - "@types/unist": ^2.0.3 - comma-separated-tokens: ^1.0.0 - prop-types: ^15.7.2 - property-information: ^5.3.0 - react-is: ^17.0.0 - remark-parse: ^9.0.0 - remark-rehype: ^8.0.0 - space-separated-tokens: ^1.1.0 - style-to-object: ^0.3.0 - unified: ^9.0.0 - unist-util-visit: ^2.0.0 - vfile: ^4.0.0 - peerDependencies: - "@types/react": ">=16" - react: ">=16" - checksum: 5176e6a314a397b4747570213ae6c092f76c5c3dc67c748731243a0d4108e002134a9061cea87df1bea00db46cc7d238e092bae1609de74983c844e8386c0554 - languageName: node - linkType: hard - "react-markdown@npm:^8.0.1": version: 8.0.7 resolution: "react-markdown@npm:8.0.7" @@ -17240,15 +17174,6 @@ plugin-image-zoom@flexanalytics/plugin-image-zoom: languageName: node linkType: hard -"remark-parse@npm:^9.0.0": - version: 9.0.0 - resolution: "remark-parse@npm:9.0.0" - dependencies: - mdast-util-from-markdown: ^0.8.0 - checksum: 50104880549639b7dd7ae6f1e23c214915fe9c054f02f3328abdaee3f6de6d7282bf4357c3c5b106958fe75e644a3c248c2197755df34f9955e8e028fc74868f - languageName: node - linkType: hard - "remark-rehype@npm:^10.0.0": version: 10.1.0 resolution: "remark-rehype@npm:10.1.0" @@ -17261,15 +17186,6 @@ plugin-image-zoom@flexanalytics/plugin-image-zoom: languageName: node linkType: hard -"remark-rehype@npm:^8.0.0": - version: 8.1.0 - resolution: "remark-rehype@npm:8.1.0" - dependencies: - mdast-util-to-hast: ^10.2.0 - checksum: e1152464cfa83c14b570b1cb85eb9b3667795b5bed2f6b16d1c6e96c369816b07945a3c04eb0e1fd57a19cc1837969527d0056d5b6d179f1290688db2a7e2c5f - languageName: node - linkType: hard - "remark-remove-comments@npm:^0.2.0": version: 0.2.0 resolution: "remark-remove-comments@npm:0.2.0" @@ -18317,7 +18233,7 @@ plugin-image-zoom@flexanalytics/plugin-image-zoom: languageName: node linkType: hard -"space-separated-tokens@npm:^1.0.0, space-separated-tokens@npm:^1.1.0": +"space-separated-tokens@npm:^1.0.0": version: 1.1.5 resolution: "space-separated-tokens@npm:1.1.5" checksum: 8ef68f1cfa8ccad316b7f8d0df0919d0f1f6d32101e8faeee34ea3a923ce8509c1ad562f57388585ee4951e92d27afa211ed0a077d3d5995b5ba9180331be708 From bb6118254680713986d888de5d70b64da4681560 Mon Sep 17 00:00:00 2001 From: Dr-Electron Date: Tue, 28 May 2024 22:35:11 +0200 Subject: [PATCH 11/14] Format --- src/plugins/docs/index.js | 111 +++++++++++++++++---------- src/theme/DocVersionBanner/index.tsx | 4 +- 2 files changed, 71 insertions(+), 44 deletions(-) diff --git a/src/plugins/docs/index.js b/src/plugins/docs/index.js index 8d8f807fd66..fa2630add3d 100644 --- a/src/plugins/docs/index.js +++ b/src/plugins/docs/index.js @@ -1,30 +1,53 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function (o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function () { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function (o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function (o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function (o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -Object.defineProperty(exports, "__esModule", { value: true }); +'use strict'; +var __createBinding = + (this && this.__createBinding) || + (Object.create + ? function (o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if ( + !desc || + ('get' in desc ? !m.__esModule : desc.writable || desc.configurable) + ) { + desc = { + enumerable: true, + get: function () { + return m[k]; + }, + }; + } + Object.defineProperty(o, k2, desc); + } + : function (o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; + }); +var __setModuleDefault = + (this && this.__setModuleDefault) || + (Object.create + ? function (o, v) { + Object.defineProperty(o, 'default', { enumerable: true, value: v }); + } + : function (o, v) { + o['default'] = v; + }); +var __importStar = + (this && this.__importStar) || + function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) + for (var k in mod) + if (k !== 'default' && Object.prototype.hasOwnProperty.call(mod, k)) + __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; + }; +Object.defineProperty(exports, '__esModule', { value: true }); exports.validateOptions = void 0; -const plugin_content_docs_1 = __importStar(require("@docusaurus/plugin-content-docs")); +const plugin_content_docs_1 = __importStar( + require('@docusaurus/plugin-content-docs'), +); async function pluginDocs(context, options) { // Destructure to separate the Docusaurus docs plugin options // and initialize the Docusaurus docs plugin to wrap. @@ -67,19 +90,21 @@ async function pluginDocs(context, options) { }; } exports.default = pluginDocs; -function validateOptions({ validate, options, }) { +function validateOptions({ validate, options }) { const { versions = {}, globalSidebars = [], ...docsOptions } = options; const versionEntries = Object.entries(versions); if (versionEntries.length > 1) throw 'Multiple Docusuaurus doc versions not allowed in the Wiki'; // Handle version banner. const versionBannerMap = {}; - const docsVersionEntries = versionEntries.map(([versionLabel, versionOptions]) => { - // TODO: validate banner - const { banner, ...docsVersionOptions } = versionOptions; - versionBannerMap[versionLabel] = banner; - return [versionLabel, docsVersionOptions]; - }); + const docsVersionEntries = versionEntries.map( + ([versionLabel, versionOptions]) => { + // TODO: validate banner + const { banner, ...docsVersionOptions } = versionOptions; + versionBannerMap[versionLabel] = banner; + return [versionLabel, docsVersionOptions]; + }, + ); const validatedDocsOptions = (0, plugin_content_docs_1.validateOptions)({ validate, options: { @@ -88,15 +113,19 @@ function validateOptions({ validate, options, }) { }, }); // Re-add banner. - validatedDocsOptions.versions = Object.fromEntries(Object.entries(validatedDocsOptions.versions).map(([versionLabel, versionOptions]) => { - return [ - versionLabel, - { - ...versionOptions, - banner: versionBannerMap[versionLabel], + validatedDocsOptions.versions = Object.fromEntries( + Object.entries(validatedDocsOptions.versions).map( + ([versionLabel, versionOptions]) => { + return [ + versionLabel, + { + ...versionOptions, + banner: versionBannerMap[versionLabel], + }, + ]; }, - ]; - })); + ), + ); return { ...validatedDocsOptions, globalSidebars, diff --git a/src/theme/DocVersionBanner/index.tsx b/src/theme/DocVersionBanner/index.tsx index fa251eff7c9..c570a641447 100644 --- a/src/theme/DocVersionBanner/index.tsx +++ b/src/theme/DocVersionBanner/index.tsx @@ -40,9 +40,7 @@ function UnreleasedVersionLabel({ versionLabel: {versionMetadata.label}, }} > - { - 'This is unreleased documentation for {versionLabel} version.' - } + {'This is unreleased documentation for {versionLabel} version.'} ); } From c405e5522a8ac617326045a8e1e9eb45da530470 Mon Sep 17 00:00:00 2001 From: Dr-Electron Date: Wed, 29 May 2024 23:26:30 +0200 Subject: [PATCH 12/14] Apply suggestions from code review Co-authored-by: Jeroen van den Hout --- src/theme/DocVersionBanner/index.tsx | 3 ++- src/utils/pluginConfigGenerators.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/theme/DocVersionBanner/index.tsx b/src/theme/DocVersionBanner/index.tsx index c570a641447..6ee49ba11b3 100644 --- a/src/theme/DocVersionBanner/index.tsx +++ b/src/theme/DocVersionBanner/index.tsx @@ -3,6 +3,7 @@ * REASONS: * - Remove use of siteTitle as it is irrelevant in our setup. * - Link to our own latest version. + * - Update text pointing to latest version */ import React, { type ComponentType } from 'react'; import clsx from 'clsx'; @@ -106,7 +107,7 @@ function LatestVersionSuggestionLabel({ }} > { - 'For up-to-date documentation, see the {latestVersionLink} ({versionLabel}).' + 'For the latest stable release, see the {latestVersionLink} ({versionLabel}).' } ); diff --git a/src/utils/pluginConfigGenerators.js b/src/utils/pluginConfigGenerators.js index 48d4d344755..fc7c0685bfb 100644 --- a/src/utils/pluginConfigGenerators.js +++ b/src/utils/pluginConfigGenerators.js @@ -43,7 +43,7 @@ function generatePluginConfig(pluginConfig, basePath) { label, path: mainVersion.label === label ? undefined : label, badge: true, - banner: banner, + banner, }, }, } From 62b763500c9a2076ed871f8e8b31e5faddd8e74d Mon Sep 17 00:00:00 2001 From: Dr-Electron Date: Fri, 31 May 2024 16:44:51 +0200 Subject: [PATCH 13/14] Add staging banner --- src/theme/DocVersionBanner/index.tsx | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/theme/DocVersionBanner/index.tsx b/src/theme/DocVersionBanner/index.tsx index 6ee49ba11b3..79c7a7c110d 100644 --- a/src/theme/DocVersionBanner/index.tsx +++ b/src/theme/DocVersionBanner/index.tsx @@ -4,6 +4,7 @@ * - Remove use of siteTitle as it is irrelevant in our setup. * - Link to our own latest version. * - Update text pointing to latest version + * - Add `staging` banner. */ import React, { type ComponentType } from 'react'; import clsx from 'clsx'; @@ -25,6 +26,8 @@ import { useCurrentDocPlugins, } from '@site/src/utils/wikiVersion'; +type WikiVersionBanner = VersionBanner & 'staging'; + type BannerLabelComponentProps = { siteTitle: string; versionMetadata: PropVersionMetadata; @@ -46,6 +49,24 @@ function UnreleasedVersionLabel({ ); } +function StagingVersionLabel({ + versionMetadata, +}: BannerLabelComponentProps) { + return ( + {versionMetadata.label}, + }} + > + { + 'This is documentation for {versionLabel} version wich is currently running on our staging network.' + } + + ); +} + function UnmaintainedVersionLabel({ versionMetadata, }: BannerLabelComponentProps) { @@ -65,9 +86,10 @@ function UnmaintainedVersionLabel({ } const BannerLabelComponents: { - [banner in VersionBanner]: ComponentType; + [banner in WikiVersionBanner]: ComponentType; } = { unreleased: UnreleasedVersionLabel, + staging: StagingVersionLabel, unmaintained: UnmaintainedVersionLabel, }; From 110316eff56fdeb9be0574c38bf1473f107efc8c Mon Sep 17 00:00:00 2001 From: Dr-Electron Date: Fri, 31 May 2024 20:41:35 +0200 Subject: [PATCH 14/14] Format --- src/theme/DocVersionBanner/index.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/theme/DocVersionBanner/index.tsx b/src/theme/DocVersionBanner/index.tsx index 79c7a7c110d..90bbff23f15 100644 --- a/src/theme/DocVersionBanner/index.tsx +++ b/src/theme/DocVersionBanner/index.tsx @@ -49,9 +49,7 @@ function UnreleasedVersionLabel({ ); } -function StagingVersionLabel({ - versionMetadata, -}: BannerLabelComponentProps) { +function StagingVersionLabel({ versionMetadata }: BannerLabelComponentProps) { return (