mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-13 17:17:28 +02:00
feat(v2): docs version banner configuration option (#5052)
* refactor DocVersionBanner => versionMetadata prop should be forwarded instead of using "useActiveVersion" + global data * docs version banner configuration * add doc for versions.banner * fix tests * improve docs plugin option api doc
This commit is contained in:
parent
f47826297c
commit
364051f232
13 changed files with 187 additions and 83 deletions
|
@ -140,10 +140,10 @@ export const getActiveDocContext = (
|
|||
};
|
||||
|
||||
export type DocVersionSuggestions = {
|
||||
// suggest the latest version
|
||||
latestVersionSuggestion: GlobalVersion;
|
||||
// suggest the same doc, in latest version (if exist)
|
||||
latestDocSuggestion?: GlobalDoc;
|
||||
// suggest the latest version
|
||||
latestVersionSuggestion?: GlobalVersion;
|
||||
};
|
||||
|
||||
export const getDocVersionSuggestions = (
|
||||
|
@ -152,17 +152,7 @@ export const getDocVersionSuggestions = (
|
|||
): DocVersionSuggestions => {
|
||||
const latestVersion = getLatestVersion(data);
|
||||
const activeDocContext = getActiveDocContext(data, pathname);
|
||||
|
||||
// We only suggest another doc/version if user is not using the latest version
|
||||
const isNotOnLatestVersion = activeDocContext.activeVersion !== latestVersion;
|
||||
|
||||
const latestDocSuggestion: GlobalDoc | undefined = isNotOnLatestVersion
|
||||
? activeDocContext?.alternateDocVersions[latestVersion.name]
|
||||
: undefined;
|
||||
|
||||
const latestVersionSuggestion = isNotOnLatestVersion
|
||||
? latestVersion
|
||||
: undefined;
|
||||
|
||||
return {latestDocSuggestion, latestVersionSuggestion};
|
||||
const latestDocSuggestion: GlobalDoc | undefined =
|
||||
activeDocContext?.alternateDocVersions[latestVersion.name];
|
||||
return {latestDocSuggestion, latestVersionSuggestion: latestVersion};
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue