-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add an archival script for updating theme components (#2230)
- Loading branch information
1 parent
7f25efe
commit d2557cd
Showing
4 changed files
with
119 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
notify "Updating theme components..." | ||
|
||
rm -rf src/theme/AnnouncementBar | ||
mkdir -p src/theme/DocVersionBanner | ||
cp hacks/isolateVersion/assets/theme/DocVersionBanner/index.js src/theme/DocVersionBanner/index.js | ||
|
||
git add src/theme | ||
git commit -m "archiving: update theme components" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# What is this folder? | ||
|
||
This folder contains assets that are used by the automated steps of the archival process. |
101 changes: 101 additions & 0 deletions
101
hacks/isolateVersion/assets/theme/DocVersionBanner/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
// Why is this swizzled? | ||
// To override the message displayed by `LatestVersionSuggestionLabel`. The built-in version | ||
// of this component can only link to another internal version, and the message includes a version | ||
// defined in this app. In an archived version of our documentation, neither of those pre-requisites are met. | ||
// In the `main` branch of these docs, this component exists in an `archive/` folder, so that it is | ||
// ignored by docusaurus. In an archived branch of these docs, the component is moved outside of the `archive/` | ||
// folder, so that it is recognized by docusaurus. | ||
// This is a very simplified version of the built-in DocVersionBanner file, not intended to support | ||
// all use cases. It's only intended to meet the needs of an archived version of the docs. | ||
// Swizzled from version 2.3.1. | ||
|
||
import React from "react"; | ||
import clsx from "clsx"; | ||
import useDocusaurusContext from "@docusaurus/useDocusaurusContext"; | ||
import Link from "@docusaurus/Link"; | ||
import Translate from "@docusaurus/Translate"; | ||
import { ThemeClassNames } from "@docusaurus/theme-common"; | ||
import { useDocsVersion } from "@docusaurus/theme-common/internal"; | ||
|
||
function UnmaintainedVersionLabel({ siteTitle, versionMetadata }) { | ||
return ( | ||
<Translate | ||
id="theme.docs.versions.unmaintainedVersionLabels" | ||
description="The label used to tell the user that they're 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> | ||
); | ||
} | ||
|
||
function BannerLabel(props) { | ||
return <UnmaintainedVersionLabel {...props} />; | ||
} | ||
|
||
function LatestVersionSuggestionLabel({ versionLabel }) { | ||
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="https://docs.camunda.io"> | ||
<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}."} | ||
</Translate> | ||
); | ||
} | ||
|
||
function DocVersionBannerEnabled({ className, versionMetadata }) { | ||
const { | ||
siteConfig: { title: siteTitle }, | ||
} = useDocusaurusContext(); | ||
return ( | ||
<div | ||
className={clsx( | ||
className, | ||
ThemeClassNames.docs.docVersionBanner, | ||
"alert alert--warning margin-bottom--md" | ||
)} | ||
role="alert" | ||
> | ||
<div> | ||
<BannerLabel siteTitle={siteTitle} versionMetadata={versionMetadata} /> | ||
</div> | ||
<div className="margin-top--md"> | ||
<LatestVersionSuggestionLabel /> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default function DocVersionBanner({ className }) { | ||
const versionMetadata = useDocsVersion(); | ||
if (versionMetadata.banner) { | ||
return ( | ||
<DocVersionBannerEnabled | ||
className={className} | ||
versionMetadata={versionMetadata} | ||
/> | ||
); | ||
} | ||
return null; | ||
} |