Skip to content

Commit 8db9f91

Browse files
authored
Fix doc version suggestions
1 parent 5cca27b commit 8db9f91

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

website/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"scripts": {
3+
"postinstall": "patch-package",
34
"start": "yarn api && docusaurus start",
45
"build": "yarn api && docusaurus build",
56
"deploy": "docusaurus deploy",
@@ -11,6 +12,7 @@
1112
"@docusaurus/preset-classic": "2.0.0-alpha.69",
1213
"@phenomnomnominal/tsquery": "4.1.1",
1314
"globby": "11.0.1",
15+
"patch-package": "6.2.2",
1416
"react": "17.0.1",
1517
"react-dom": "17.0.1",
1618
"remark-import-partial": "0.0.2",
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
diff --git a/node_modules/@docusaurus/theme-classic/lib/theme/DocVersionSuggestions/index.js b/node_modules/@docusaurus/theme-classic/lib/theme/DocVersionSuggestions/index.js
2+
index bc8baa7..b12bebf 100644
3+
--- a/node_modules/@docusaurus/theme-classic/lib/theme/DocVersionSuggestions/index.js
4+
+++ b/node_modules/@docusaurus/theme-classic/lib/theme/DocVersionSuggestions/index.js
5+
@@ -18,58 +18,7 @@ const getVersionMainDoc = (version) =>
6+
version.docs.find((doc) => doc.id === version.mainDocId);
7+
8+
function DocVersionSuggestions() {
9+
- const {
10+
- siteConfig: {title: siteTitle},
11+
- } = useDocusaurusContext();
12+
- const {pluginId} = useActivePlugin({
13+
- failfast: true,
14+
- });
15+
- const {savePreferredVersionName} = useDocsPreferredVersion(pluginId);
16+
- const activeVersion = useActiveVersion(pluginId);
17+
- const {
18+
- latestDocSuggestion,
19+
- latestVersionSuggestion,
20+
- } = useDocVersionSuggestions(pluginId); // No suggestion to be made
21+
-
22+
- if (!latestVersionSuggestion) {
23+
- return <></>;
24+
- } // try to link to same doc in latest version (not always possible)
25+
- // fallback to main doc of latest version
26+
-
27+
- const latestVersionSuggestedDoc =
28+
- latestDocSuggestion ?? getVersionMainDoc(latestVersionSuggestion);
29+
- return (
30+
- <div className="alert alert--warning margin-bottom--md" role="alert">
31+
- {
32+
- // TODO need refactoring
33+
- activeVersion.name === 'current' ? (
34+
- <div>
35+
- This is unreleased documentation for {siteTitle}{' '}
36+
- <strong>{activeVersion.label}</strong> version.
37+
- </div>
38+
- ) : (
39+
- <div>
40+
- This is documentation for {siteTitle}{' '}
41+
- <strong>{activeVersion.label}</strong>, which is no longer actively
42+
- maintained.
43+
- </div>
44+
- )
45+
- }
46+
- <div className="margin-top--md">
47+
- For up-to-date documentation, see the{' '}
48+
- <strong>
49+
- <Link
50+
- to={latestVersionSuggestedDoc.path}
51+
- onClick={() =>
52+
- savePreferredVersionName(latestVersionSuggestion.name)
53+
- }>
54+
- latest version
55+
- </Link>
56+
- </strong>{' '}
57+
- ({latestVersionSuggestion.label}).
58+
- </div>
59+
- </div>
60+
- );
61+
+ return null
62+
}
63+
64+
export default DocVersionSuggestions;

0 commit comments

Comments
 (0)