mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-20 12:37:01 +02:00
feat(v2): persist docs preferred version (#3543)
* persist docs preferred version * add proper implementation for useDocsPreferredVersion * add proper implementation for useDocsPreferredVersion * useDocsPreferredVersion => make localstorage read only after mount * why @docusaurus/constants can't work? * fix weird TS issue when not duplicating constants * add basic @docusaurus/constants doc * attempt to fix docs-only mode where we should not call useDocs hooks * attempt to fix docs-only mode where we should not call useDocs hooks * fix children * encapsulate hacky isDocsPluginEnabled in docsUtils * use same priority order for all navbar items: activeVersion ?? preferredVersion ?? latestVersion
This commit is contained in:
parent
d1510770f4
commit
4130f1a195
15 changed files with 344 additions and 12 deletions
|
@ -8,6 +8,15 @@
|
|||
const Joi = require('@hapi/joi');
|
||||
const {URISchema} = require('@docusaurus/utils-validation');
|
||||
|
||||
const DEFAULT_DOCS_CONFIG = {
|
||||
versionPersistence: 'localStorage',
|
||||
};
|
||||
const DocsSchema = Joi.object({
|
||||
versionPersistence: Joi.string()
|
||||
.equal('localStorage', 'none')
|
||||
.default(DEFAULT_DOCS_CONFIG.versionPersistence),
|
||||
}).default(DEFAULT_DOCS_CONFIG);
|
||||
|
||||
const DEFAULT_COLOR_MODE_CONFIG = {
|
||||
defaultMode: 'light',
|
||||
disableSwitch: false,
|
||||
|
@ -22,6 +31,7 @@ const DEFAULT_COLOR_MODE_CONFIG = {
|
|||
|
||||
const DEFAULT_CONFIG = {
|
||||
colorMode: DEFAULT_COLOR_MODE_CONFIG,
|
||||
docs: DEFAULT_DOCS_CONFIG,
|
||||
metadatas: [],
|
||||
prism: {
|
||||
additionalLanguages: [],
|
||||
|
@ -206,6 +216,7 @@ const ThemeConfigSchema = Joi.object({
|
|||
customCss: CustomCssSchema,
|
||||
colorMode: ColorModeSchema,
|
||||
image: Joi.string(),
|
||||
docs: DocsSchema,
|
||||
metadatas: Joi.array()
|
||||
.items(HtmlMetadataSchema)
|
||||
.default(DEFAULT_CONFIG.metadatas),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue