mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-13 00:57:53 +02:00
refactor: remove deprecated docs homePageId option (#6065)
This commit is contained in:
parent
c64987e2c8
commit
f96a051fbe
17 changed files with 96 additions and 175 deletions
|
@ -37,7 +37,6 @@ module.exports = {
|
||||||
'@docusaurus/preset-classic',
|
'@docusaurus/preset-classic',
|
||||||
{
|
{
|
||||||
docs: {
|
docs: {
|
||||||
homePageId: 'installation',
|
|
||||||
showLastUpdateAuthor: true,
|
showLastUpdateAuthor: true,
|
||||||
showLastUpdateTime: true,
|
showLastUpdateTime: true,
|
||||||
editUrl: 'https://github.com/facebook/docusaurus/edit/main/docs/',
|
editUrl: 'https://github.com/facebook/docusaurus/edit/main/docs/',
|
||||||
|
@ -53,7 +52,7 @@ module.exports = {
|
||||||
title: 'Docusaurus',
|
title: 'Docusaurus',
|
||||||
logo: {src: 'img/docusaurus.svg'},
|
logo: {src: 'img/docusaurus.svg'},
|
||||||
items: [
|
items: [
|
||||||
{to: 'docs/', label: 'Docs', position: 'left'},
|
{to: 'docs/installation', label: 'Docs', position: 'left'},
|
||||||
{to: 'docs/tutorial-setup', label: 'Tutorial', position: 'left'},
|
{to: 'docs/tutorial-setup', label: 'Tutorial', position: 'left'},
|
||||||
{to: '/users', label: 'Users', position: 'left'},
|
{to: '/users', label: 'Users', position: 'left'},
|
||||||
{
|
{
|
||||||
|
|
|
@ -226,9 +226,6 @@ export function createConfigFile({
|
||||||
'v1Config' | 'siteDir' | 'newDir'
|
'v1Config' | 'siteDir' | 'newDir'
|
||||||
>): VersionTwoConfig {
|
>): VersionTwoConfig {
|
||||||
const siteConfig = v1Config;
|
const siteConfig = v1Config;
|
||||||
const homePageId = siteConfig.headerLinks?.filter((value) => value.doc)[0]
|
|
||||||
.doc;
|
|
||||||
|
|
||||||
const customConfigFields: Record<string, unknown> = {};
|
const customConfigFields: Record<string, unknown> = {};
|
||||||
// add fields that are unknown to v2 to customConfigFields
|
// add fields that are unknown to v2 to customConfigFields
|
||||||
Object.keys(siteConfig).forEach((key) => {
|
Object.keys(siteConfig).forEach((key) => {
|
||||||
|
@ -309,7 +306,6 @@ export function createConfigFile({
|
||||||
{
|
{
|
||||||
docs: {
|
docs: {
|
||||||
...(v2DocsPath && {path: v2DocsPath}),
|
...(v2DocsPath && {path: v2DocsPath}),
|
||||||
homePageId,
|
|
||||||
showLastUpdateAuthor: true,
|
showLastUpdateAuthor: true,
|
||||||
showLastUpdateTime: true,
|
showLastUpdateTime: true,
|
||||||
editUrl: siteConfig.editUrl,
|
editUrl: siteConfig.editUrl,
|
||||||
|
@ -334,7 +330,7 @@ export function createConfigFile({
|
||||||
const position = 'left';
|
const position = 'left';
|
||||||
if (doc) {
|
if (doc) {
|
||||||
return {
|
return {
|
||||||
to: `docs/${doc === homePageId ? '' : doc}`,
|
to: `docs/${doc}`,
|
||||||
label,
|
label,
|
||||||
position,
|
position,
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,6 +3,7 @@ id: hello
|
||||||
title: Hello, World !
|
title: Hello, World !
|
||||||
sidebar_label: Hello sidebar_label
|
sidebar_label: Hello sidebar_label
|
||||||
tags: [tag-1, tag 3]
|
tags: [tag-1, tag 3]
|
||||||
|
slug: /
|
||||||
---
|
---
|
||||||
|
|
||||||
Hi, Endilie here :)
|
Hi, Endilie here :)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
---
|
---
|
||||||
id: hello-1
|
id: hello-1
|
||||||
title: Hello 1
|
title: Hello 1
|
||||||
|
slug: /
|
||||||
---
|
---
|
||||||
|
|
||||||
Hello World 1!
|
Hello World 1!
|
||||||
|
|
|
@ -1 +1,4 @@
|
||||||
|
---
|
||||||
|
slug: /
|
||||||
|
---
|
||||||
Hello `next` !
|
Hello `next` !
|
||||||
|
|
|
@ -1 +1,4 @@
|
||||||
|
---
|
||||||
|
slug: /
|
||||||
|
---
|
||||||
Hello `1.0.0` ! (translated en)
|
Hello `1.0.0` ! (translated en)
|
||||||
|
|
|
@ -1 +1,4 @@
|
||||||
|
---
|
||||||
|
slug: /
|
||||||
|
---
|
||||||
Hello `1.0.0` ! (translated fr)
|
Hello `1.0.0` ! (translated fr)
|
||||||
|
|
|
@ -1 +1,4 @@
|
||||||
|
---
|
||||||
|
slug: /
|
||||||
|
---
|
||||||
Hello `1.0.0` !
|
Hello `1.0.0` !
|
||||||
|
|
|
@ -1 +1,4 @@
|
||||||
|
---
|
||||||
|
slug: /
|
||||||
|
---
|
||||||
Hello `1.0.1` !
|
Hello `1.0.1` !
|
||||||
|
|
|
@ -25,7 +25,7 @@ Array [
|
||||||
Array [
|
Array [
|
||||||
undefined,
|
undefined,
|
||||||
Object {
|
Object {
|
||||||
"permalink": "/docs/hello",
|
"permalink": "/docs/",
|
||||||
"title": "Hello sidebar_label",
|
"title": "Hello sidebar_label",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -41,7 +41,7 @@ Array [
|
||||||
],
|
],
|
||||||
Array [
|
Array [
|
||||||
Object {
|
Object {
|
||||||
"permalink": "/docs/hello",
|
"permalink": "/docs/",
|
||||||
"title": "Hello sidebar_label",
|
"title": "Hello sidebar_label",
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
|
|
|
@ -314,7 +314,8 @@ Object {
|
||||||
\\"tags\\": [
|
\\"tags\\": [
|
||||||
\\"tag-1\\",
|
\\"tag-1\\",
|
||||||
\\"tag 3\\"
|
\\"tag 3\\"
|
||||||
]
|
],
|
||||||
|
\\"slug\\": \\"/\\"
|
||||||
},
|
},
|
||||||
\\"sidebar\\": \\"docs\\",
|
\\"sidebar\\": \\"docs\\",
|
||||||
\\"previous\\": {
|
\\"previous\\": {
|
||||||
|
@ -1528,7 +1529,9 @@ Object {
|
||||||
\\"permalink\\": \\"/docs/next/\\",
|
\\"permalink\\": \\"/docs/next/\\",
|
||||||
\\"tags\\": [],
|
\\"tags\\": [],
|
||||||
\\"version\\": \\"current\\",
|
\\"version\\": \\"current\\",
|
||||||
\\"frontMatter\\": {},
|
\\"frontMatter\\": {
|
||||||
|
\\"slug\\": \\"/\\"
|
||||||
|
},
|
||||||
\\"sidebar\\": \\"docs\\",
|
\\"sidebar\\": \\"docs\\",
|
||||||
\\"previous\\": {
|
\\"previous\\": {
|
||||||
\\"title\\": \\"bar\\",
|
\\"title\\": \\"bar\\",
|
||||||
|
@ -1606,7 +1609,9 @@ Object {
|
||||||
\\"permalink\\": \\"/docs/1.0.0/\\",
|
\\"permalink\\": \\"/docs/1.0.0/\\",
|
||||||
\\"tags\\": [],
|
\\"tags\\": [],
|
||||||
\\"version\\": \\"1.0.0\\",
|
\\"version\\": \\"1.0.0\\",
|
||||||
\\"frontMatter\\": {},
|
\\"frontMatter\\": {
|
||||||
|
\\"slug\\": \\"/\\"
|
||||||
|
},
|
||||||
\\"sidebar\\": \\"version-1.0.0/docs\\",
|
\\"sidebar\\": \\"version-1.0.0/docs\\",
|
||||||
\\"previous\\": {
|
\\"previous\\": {
|
||||||
\\"title\\": \\"baz\\",
|
\\"title\\": \\"baz\\",
|
||||||
|
@ -1684,7 +1689,9 @@ Object {
|
||||||
\\"permalink\\": \\"/docs/\\",
|
\\"permalink\\": \\"/docs/\\",
|
||||||
\\"tags\\": [],
|
\\"tags\\": [],
|
||||||
\\"version\\": \\"1.0.1\\",
|
\\"version\\": \\"1.0.1\\",
|
||||||
\\"frontMatter\\": {},
|
\\"frontMatter\\": {
|
||||||
|
\\"slug\\": \\"/\\"
|
||||||
|
},
|
||||||
\\"sidebar\\": \\"VersionedSideBarNameDoesNotMatter/docs\\",
|
\\"sidebar\\": \\"VersionedSideBarNameDoesNotMatter/docs\\",
|
||||||
\\"previous\\": {
|
\\"previous\\": {
|
||||||
\\"title\\": \\"bar\\",
|
\\"title\\": \\"bar\\",
|
||||||
|
|
|
@ -236,14 +236,15 @@ describe('simple site', () => {
|
||||||
id: 'hello',
|
id: 'hello',
|
||||||
unversionedId: 'hello',
|
unversionedId: 'hello',
|
||||||
sourceDirName: '.',
|
sourceDirName: '.',
|
||||||
permalink: '/docs/hello',
|
permalink: '/docs/',
|
||||||
slug: '/hello',
|
slug: '/',
|
||||||
title: 'Hello, World !',
|
title: 'Hello, World !',
|
||||||
description: `Hi, Endilie here :)`,
|
description: `Hi, Endilie here :)`,
|
||||||
frontMatter: {
|
frontMatter: {
|
||||||
id: 'hello',
|
id: 'hello',
|
||||||
title: 'Hello, World !',
|
title: 'Hello, World !',
|
||||||
sidebar_label: 'Hello sidebar_label',
|
sidebar_label: 'Hello sidebar_label',
|
||||||
|
slug: '/',
|
||||||
tags: ['tag-1', 'tag 3'],
|
tags: ['tag-1', 'tag 3'],
|
||||||
},
|
},
|
||||||
tags: [
|
tags: [
|
||||||
|
@ -259,76 +260,6 @@ describe('simple site', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('homePageId doc', async () => {
|
|
||||||
const {siteDir, context, options, currentVersion} = await loadSite({
|
|
||||||
options: {homePageId: 'hello'},
|
|
||||||
});
|
|
||||||
|
|
||||||
const testUtilsLocal = createTestUtils({
|
|
||||||
siteDir,
|
|
||||||
context,
|
|
||||||
options,
|
|
||||||
versionMetadata: currentVersion,
|
|
||||||
});
|
|
||||||
|
|
||||||
await testUtilsLocal.testMeta(path.join('hello.md'), {
|
|
||||||
version: 'current',
|
|
||||||
id: 'hello',
|
|
||||||
unversionedId: 'hello',
|
|
||||||
sourceDirName: '.',
|
|
||||||
permalink: '/docs/',
|
|
||||||
slug: '/',
|
|
||||||
title: 'Hello, World !',
|
|
||||||
description: `Hi, Endilie here :)`,
|
|
||||||
frontMatter: {
|
|
||||||
id: 'hello',
|
|
||||||
title: 'Hello, World !',
|
|
||||||
sidebar_label: 'Hello sidebar_label',
|
|
||||||
tags: ['tag-1', 'tag 3'],
|
|
||||||
},
|
|
||||||
tags: [
|
|
||||||
{
|
|
||||||
label: 'tag-1',
|
|
||||||
permalink: '/docs/tags/tag-1',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'tag 3',
|
|
||||||
permalink: '/docs/tags/tag-3',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
test('homePageId doc nested', async () => {
|
|
||||||
const {siteDir, context, options, currentVersion} = await loadSite({
|
|
||||||
options: {homePageId: 'foo/bar'},
|
|
||||||
});
|
|
||||||
|
|
||||||
const testUtilsLocal = createTestUtils({
|
|
||||||
siteDir,
|
|
||||||
context,
|
|
||||||
options,
|
|
||||||
versionMetadata: currentVersion,
|
|
||||||
});
|
|
||||||
|
|
||||||
await testUtilsLocal.testMeta(path.join('foo', 'bar.md'), {
|
|
||||||
version: 'current',
|
|
||||||
id: 'foo/bar',
|
|
||||||
unversionedId: 'foo/bar',
|
|
||||||
sourceDirName: 'foo',
|
|
||||||
permalink: '/docs/',
|
|
||||||
slug: '/',
|
|
||||||
title: 'Bar',
|
|
||||||
description: 'This is custom description',
|
|
||||||
frontMatter: {
|
|
||||||
description: 'This is custom description',
|
|
||||||
id: 'bar',
|
|
||||||
title: 'Bar',
|
|
||||||
},
|
|
||||||
tags: [],
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
test('docs with editUrl', async () => {
|
test('docs with editUrl', async () => {
|
||||||
const {siteDir, context, options, currentVersion} = await loadSite({
|
const {siteDir, context, options, currentVersion} = await loadSite({
|
||||||
options: {
|
options: {
|
||||||
|
@ -550,33 +481,6 @@ describe('simple site', () => {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('docs with slug on doc home', async () => {
|
|
||||||
const {siteDir, context, options, currentVersion} = await loadSite({
|
|
||||||
options: {
|
|
||||||
homePageId: 'homePageId',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const testUtilsLocal = createTestUtils({
|
|
||||||
siteDir,
|
|
||||||
context,
|
|
||||||
options,
|
|
||||||
versionMetadata: currentVersion,
|
|
||||||
});
|
|
||||||
expect(() => {
|
|
||||||
testUtilsLocal.processDocFile(
|
|
||||||
createFakeDocFile({
|
|
||||||
source: 'homePageId',
|
|
||||||
frontmatter: {
|
|
||||||
slug: '/x/y',
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}).toThrowErrorMatchingInlineSnapshot(
|
|
||||||
`"The docs homepage (homePageId=homePageId) is not allowed to have a frontmatter slug=/x/y => you have to choose either homePageId or slug, not both"`,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('custom pagination', async () => {
|
test('custom pagination', async () => {
|
||||||
const {defaultTestUtils, options, versionsMetadata} = await loadSite();
|
const {defaultTestUtils, options, versionsMetadata} = await loadSite();
|
||||||
const docs = await readVersionDocs(versionsMetadata[0], options);
|
const docs = await readVersionDocs(versionsMetadata[0], options);
|
||||||
|
@ -706,11 +610,13 @@ describe('versioned site', () => {
|
||||||
version: 'current',
|
version: 'current',
|
||||||
unversionedId: 'hello',
|
unversionedId: 'hello',
|
||||||
sourceDirName: '.',
|
sourceDirName: '.',
|
||||||
permalink: '/docs/next/hello',
|
permalink: '/docs/next/',
|
||||||
slug: '/hello',
|
slug: '/',
|
||||||
title: 'hello',
|
title: 'hello',
|
||||||
description: 'Hello next !',
|
description: 'Hello next !',
|
||||||
frontMatter: {},
|
frontMatter: {
|
||||||
|
slug: '/',
|
||||||
|
},
|
||||||
tags: [],
|
tags: [],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -734,11 +640,13 @@ describe('versioned site', () => {
|
||||||
id: 'version-1.0.0/hello',
|
id: 'version-1.0.0/hello',
|
||||||
unversionedId: 'hello',
|
unversionedId: 'hello',
|
||||||
sourceDirName: '.',
|
sourceDirName: '.',
|
||||||
permalink: '/docs/1.0.0/hello',
|
permalink: '/docs/1.0.0/',
|
||||||
slug: '/hello',
|
slug: '/',
|
||||||
title: 'hello',
|
title: 'hello',
|
||||||
description: 'Hello 1.0.0 ! (translated en)',
|
description: 'Hello 1.0.0 ! (translated en)',
|
||||||
frontMatter: {},
|
frontMatter: {
|
||||||
|
slug: '/',
|
||||||
|
},
|
||||||
version: '1.0.0',
|
version: '1.0.0',
|
||||||
source:
|
source:
|
||||||
'@site/i18n/en/docusaurus-plugin-content-docs/version-1.0.0/hello.md',
|
'@site/i18n/en/docusaurus-plugin-content-docs/version-1.0.0/hello.md',
|
||||||
|
@ -760,12 +668,14 @@ describe('versioned site', () => {
|
||||||
id: 'version-1.0.1/hello',
|
id: 'version-1.0.1/hello',
|
||||||
unversionedId: 'hello',
|
unversionedId: 'hello',
|
||||||
sourceDirName: '.',
|
sourceDirName: '.',
|
||||||
permalink: '/docs/hello',
|
permalink: '/docs/',
|
||||||
slug: '/hello',
|
slug: '/',
|
||||||
title: 'hello',
|
title: 'hello',
|
||||||
description: 'Hello 1.0.1 !',
|
description: 'Hello 1.0.1 !',
|
||||||
version: '1.0.1',
|
version: '1.0.1',
|
||||||
frontMatter: {},
|
frontMatter: {
|
||||||
|
slug: '/',
|
||||||
|
},
|
||||||
tags: [],
|
tags: [],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -851,11 +761,13 @@ describe('versioned site', () => {
|
||||||
id: 'version-1.0.0/hello',
|
id: 'version-1.0.0/hello',
|
||||||
unversionedId: 'hello',
|
unversionedId: 'hello',
|
||||||
sourceDirName: '.',
|
sourceDirName: '.',
|
||||||
permalink: '/docs/1.0.0/hello',
|
permalink: '/docs/1.0.0/',
|
||||||
slug: '/hello',
|
slug: '/',
|
||||||
title: 'hello',
|
title: 'hello',
|
||||||
description: 'Hello 1.0.0 ! (translated en)',
|
description: 'Hello 1.0.0 ! (translated en)',
|
||||||
frontMatter: {},
|
frontMatter: {
|
||||||
|
slug: '/',
|
||||||
|
},
|
||||||
version: '1.0.0',
|
version: '1.0.0',
|
||||||
source:
|
source:
|
||||||
'@site/i18n/en/docusaurus-plugin-content-docs/version-1.0.0/hello.md',
|
'@site/i18n/en/docusaurus-plugin-content-docs/version-1.0.0/hello.md',
|
||||||
|
@ -868,7 +780,7 @@ describe('versioned site', () => {
|
||||||
version: '1.0.0',
|
version: '1.0.0',
|
||||||
versionDocsDirPath: 'versioned_docs/version-1.0.0',
|
versionDocsDirPath: 'versioned_docs/version-1.0.0',
|
||||||
docPath: path.join('hello.md'),
|
docPath: path.join('hello.md'),
|
||||||
permalink: '/docs/1.0.0/hello',
|
permalink: '/docs/1.0.0/',
|
||||||
locale: 'en',
|
locale: 'en',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -892,11 +804,13 @@ describe('versioned site', () => {
|
||||||
id: 'version-1.0.0/hello',
|
id: 'version-1.0.0/hello',
|
||||||
unversionedId: 'hello',
|
unversionedId: 'hello',
|
||||||
sourceDirName: '.',
|
sourceDirName: '.',
|
||||||
permalink: '/docs/1.0.0/hello',
|
permalink: '/docs/1.0.0/',
|
||||||
slug: '/hello',
|
slug: '/',
|
||||||
title: 'hello',
|
title: 'hello',
|
||||||
description: 'Hello 1.0.0 ! (translated en)',
|
description: 'Hello 1.0.0 ! (translated en)',
|
||||||
frontMatter: {},
|
frontMatter: {
|
||||||
|
slug: '/',
|
||||||
|
},
|
||||||
version: '1.0.0',
|
version: '1.0.0',
|
||||||
source:
|
source:
|
||||||
'@site/i18n/en/docusaurus-plugin-content-docs/version-1.0.0/hello.md',
|
'@site/i18n/en/docusaurus-plugin-content-docs/version-1.0.0/hello.md',
|
||||||
|
@ -925,11 +839,13 @@ describe('versioned site', () => {
|
||||||
id: 'version-1.0.0/hello',
|
id: 'version-1.0.0/hello',
|
||||||
unversionedId: 'hello',
|
unversionedId: 'hello',
|
||||||
sourceDirName: '.',
|
sourceDirName: '.',
|
||||||
permalink: '/docs/1.0.0/hello',
|
permalink: '/docs/1.0.0/',
|
||||||
slug: '/hello',
|
slug: '/',
|
||||||
title: 'hello',
|
title: 'hello',
|
||||||
description: 'Hello 1.0.0 ! (translated en)',
|
description: 'Hello 1.0.0 ! (translated en)',
|
||||||
frontMatter: {},
|
frontMatter: {
|
||||||
|
slug: '/',
|
||||||
|
},
|
||||||
version: '1.0.0',
|
version: '1.0.0',
|
||||||
source:
|
source:
|
||||||
'@site/i18n/en/docusaurus-plugin-content-docs/version-1.0.0/hello.md',
|
'@site/i18n/en/docusaurus-plugin-content-docs/version-1.0.0/hello.md',
|
||||||
|
@ -959,11 +875,13 @@ describe('versioned site', () => {
|
||||||
id: 'version-1.0.0/hello',
|
id: 'version-1.0.0/hello',
|
||||||
unversionedId: 'hello',
|
unversionedId: 'hello',
|
||||||
sourceDirName: '.',
|
sourceDirName: '.',
|
||||||
permalink: '/fr/docs/1.0.0/hello',
|
permalink: '/fr/docs/1.0.0/',
|
||||||
slug: '/hello',
|
slug: '/',
|
||||||
title: 'hello',
|
title: 'hello',
|
||||||
description: 'Hello 1.0.0 ! (translated fr)',
|
description: 'Hello 1.0.0 ! (translated fr)',
|
||||||
frontMatter: {},
|
frontMatter: {
|
||||||
|
slug: '/',
|
||||||
|
},
|
||||||
version: '1.0.0',
|
version: '1.0.0',
|
||||||
source:
|
source:
|
||||||
'@site/i18n/fr/docusaurus-plugin-content-docs/version-1.0.0/hello.md',
|
'@site/i18n/fr/docusaurus-plugin-content-docs/version-1.0.0/hello.md',
|
||||||
|
@ -994,11 +912,13 @@ describe('versioned site', () => {
|
||||||
id: 'version-1.0.0/hello',
|
id: 'version-1.0.0/hello',
|
||||||
unversionedId: 'hello',
|
unversionedId: 'hello',
|
||||||
sourceDirName: '.',
|
sourceDirName: '.',
|
||||||
permalink: '/fr/docs/1.0.0/hello',
|
permalink: '/fr/docs/1.0.0/',
|
||||||
slug: '/hello',
|
slug: '/',
|
||||||
title: 'hello',
|
title: 'hello',
|
||||||
description: 'Hello 1.0.0 ! (translated fr)',
|
description: 'Hello 1.0.0 ! (translated fr)',
|
||||||
frontMatter: {},
|
frontMatter: {
|
||||||
|
slug: '/',
|
||||||
|
},
|
||||||
version: '1.0.0',
|
version: '1.0.0',
|
||||||
source:
|
source:
|
||||||
'@site/i18n/fr/docusaurus-plugin-content-docs/version-1.0.0/hello.md',
|
'@site/i18n/fr/docusaurus-plugin-content-docs/version-1.0.0/hello.md',
|
||||||
|
|
|
@ -247,7 +247,6 @@ describe('simple website', () => {
|
||||||
normalizePluginOptions(OptionsSchema, {
|
normalizePluginOptions(OptionsSchema, {
|
||||||
path: 'docs',
|
path: 'docs',
|
||||||
sidebarPath,
|
sidebarPath,
|
||||||
homePageId: 'hello',
|
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
const pluginContentDir = path.join(context.generatedFilesDir, plugin.name);
|
const pluginContentDir = path.join(context.generatedFilesDir, plugin.name);
|
||||||
|
@ -405,6 +404,7 @@ describe('simple website', () => {
|
||||||
id: 'hello',
|
id: 'hello',
|
||||||
title: 'Hello, World !',
|
title: 'Hello, World !',
|
||||||
sidebar_label: 'Hello sidebar_label',
|
sidebar_label: 'Hello sidebar_label',
|
||||||
|
slug: '/',
|
||||||
tags: ['tag-1', 'tag 3'],
|
tags: ['tag-1', 'tag 3'],
|
||||||
},
|
},
|
||||||
tags: [
|
tags: [
|
||||||
|
@ -476,7 +476,6 @@ describe('versioned website', () => {
|
||||||
normalizePluginOptions(OptionsSchema, {
|
normalizePluginOptions(OptionsSchema, {
|
||||||
routeBasePath,
|
routeBasePath,
|
||||||
sidebarPath,
|
sidebarPath,
|
||||||
homePageId: 'hello',
|
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
const pluginContentDir = path.join(context.generatedFilesDir, plugin.name);
|
const pluginContentDir = path.join(context.generatedFilesDir, plugin.name);
|
||||||
|
@ -654,7 +653,9 @@ describe('versioned website', () => {
|
||||||
),
|
),
|
||||||
title: 'hello',
|
title: 'hello',
|
||||||
description: 'Hello next !',
|
description: 'Hello next !',
|
||||||
frontMatter: {},
|
frontMatter: {
|
||||||
|
slug: '/',
|
||||||
|
},
|
||||||
version: 'current',
|
version: 'current',
|
||||||
sidebar: 'docs',
|
sidebar: 'docs',
|
||||||
previous: {
|
previous: {
|
||||||
|
@ -676,7 +677,9 @@ describe('versioned website', () => {
|
||||||
),
|
),
|
||||||
title: 'hello',
|
title: 'hello',
|
||||||
description: 'Hello 1.0.1 !',
|
description: 'Hello 1.0.1 !',
|
||||||
frontMatter: {},
|
frontMatter: {
|
||||||
|
slug: '/',
|
||||||
|
},
|
||||||
version: '1.0.1',
|
version: '1.0.1',
|
||||||
sidebar: 'VersionedSideBarNameDoesNotMatter/docs',
|
sidebar: 'VersionedSideBarNameDoesNotMatter/docs',
|
||||||
previous: {
|
previous: {
|
||||||
|
@ -892,7 +895,6 @@ describe('site with doc label', () => {
|
||||||
normalizePluginOptions(OptionsSchema, {
|
normalizePluginOptions(OptionsSchema, {
|
||||||
path: 'docs',
|
path: 'docs',
|
||||||
sidebarPath,
|
sidebarPath,
|
||||||
homePageId: 'hello-1',
|
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,6 @@ describe('normalizeDocsPluginOptions', () => {
|
||||||
path: 'my-docs', // Path to data on filesystem, relative to site dir.
|
path: 'my-docs', // Path to data on filesystem, relative to site dir.
|
||||||
routeBasePath: 'my-docs', // URL Route.
|
routeBasePath: 'my-docs', // URL Route.
|
||||||
tagsBasePath: 'tags', // URL Tags Route.
|
tagsBasePath: 'tags', // URL Tags Route.
|
||||||
homePageId: 'home', // Document id for docs home page.
|
|
||||||
include: ['**/*.{md,mdx}'], // Extensions to include.
|
include: ['**/*.{md,mdx}'], // Extensions to include.
|
||||||
exclude: GlobExcludeDefault,
|
exclude: GlobExcludeDefault,
|
||||||
sidebarPath: 'my-sidebar', // Path to sidebar configuration for showing a list of markdown pages.
|
sidebarPath: 'my-sidebar', // Path to sidebar configuration for showing a list of markdown pages.
|
||||||
|
|
|
@ -126,7 +126,6 @@ function doProcessDocMetadata({
|
||||||
options: MetadataOptions;
|
options: MetadataOptions;
|
||||||
}): DocMetadataBase {
|
}): DocMetadataBase {
|
||||||
const {source, content, lastUpdate, contentPath, filePath} = docFile;
|
const {source, content, lastUpdate, contentPath, filePath} = docFile;
|
||||||
const {homePageId} = options;
|
|
||||||
const {siteDir, i18n} = context;
|
const {siteDir, i18n} = context;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
@ -196,24 +195,14 @@ function doProcessDocMetadata({
|
||||||
// legacy versioned id, requires a breaking change to modify this
|
// legacy versioned id, requires a breaking change to modify this
|
||||||
const id = [versionIdPrefix, unversionedId].filter(Boolean).join('/');
|
const id = [versionIdPrefix, unversionedId].filter(Boolean).join('/');
|
||||||
|
|
||||||
// TODO remove soon, deprecated homePageId
|
const docSlug = getSlug({
|
||||||
const isDocsHomePage = unversionedId === (homePageId ?? '_index');
|
baseID,
|
||||||
if (frontMatter.slug && isDocsHomePage) {
|
source,
|
||||||
throw new Error(
|
sourceDirName,
|
||||||
`The docs homepage (homePageId=${homePageId}) is not allowed to have a frontmatter slug=${frontMatter.slug} => you have to choose either homePageId or slug, not both`,
|
frontmatterSlug: frontMatter.slug,
|
||||||
);
|
stripDirNumberPrefixes: parseNumberPrefixes,
|
||||||
}
|
numberPrefixParser: options.numberPrefixParser,
|
||||||
|
});
|
||||||
const docSlug = isDocsHomePage
|
|
||||||
? '/'
|
|
||||||
: getSlug({
|
|
||||||
baseID,
|
|
||||||
source,
|
|
||||||
sourceDirName,
|
|
||||||
frontmatterSlug: frontMatter.slug,
|
|
||||||
stripDirNumberPrefixes: parseNumberPrefixes,
|
|
||||||
numberPrefixParser: options.numberPrefixParser,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Note: the title is used by default for page title, sidebar label, pagination buttons...
|
// Note: the title is used by default for page title, sidebar label, pagination buttons...
|
||||||
// frontMatter.title should be used in priority over contentTitle (because it can contain markdown/JSX syntax)
|
// frontMatter.title should be used in priority over contentTitle (because it can contain markdown/JSX syntax)
|
||||||
|
|
|
@ -30,7 +30,6 @@ export const DEFAULT_OPTIONS: Omit<PluginOptions, 'id' | 'sidebarPath'> = {
|
||||||
path: 'docs', // Path to data on filesystem, relative to site dir.
|
path: 'docs', // Path to data on filesystem, relative to site dir.
|
||||||
routeBasePath: 'docs', // URL Route.
|
routeBasePath: 'docs', // URL Route.
|
||||||
tagsBasePath: 'tags', // URL Tags Route.
|
tagsBasePath: 'tags', // URL Tags Route.
|
||||||
homePageId: undefined, // TODO remove soon, deprecated
|
|
||||||
include: ['**/*.{md,mdx}'], // Extensions to include.
|
include: ['**/*.{md,mdx}'], // Extensions to include.
|
||||||
exclude: GlobExcludeDefault,
|
exclude: GlobExcludeDefault,
|
||||||
sidebarItemsGenerator: DefaultSidebarItemsGenerator,
|
sidebarItemsGenerator: DefaultSidebarItemsGenerator,
|
||||||
|
@ -79,7 +78,11 @@ export const OptionsSchema = Joi.object({
|
||||||
// .allow('') ""
|
// .allow('') ""
|
||||||
.default(DEFAULT_OPTIONS.routeBasePath),
|
.default(DEFAULT_OPTIONS.routeBasePath),
|
||||||
tagsBasePath: Joi.string().default(DEFAULT_OPTIONS.tagsBasePath),
|
tagsBasePath: Joi.string().default(DEFAULT_OPTIONS.tagsBasePath),
|
||||||
homePageId: Joi.string().optional(),
|
homePageId: Joi.any().forbidden().messages({
|
||||||
|
'any.unknown':
|
||||||
|
'The docs plugin option homePageId is not supported anymore. To make a doc the "home", please add "slug: /" in its front matter. See: https://docusaurus.io/docs/next/docs-introduction#home-page-docs',
|
||||||
|
}),
|
||||||
|
|
||||||
include: Joi.array().items(Joi.string()).default(DEFAULT_OPTIONS.include),
|
include: Joi.array().items(Joi.string()).default(DEFAULT_OPTIONS.include),
|
||||||
exclude: Joi.array().items(Joi.string()).default(DEFAULT_OPTIONS.exclude),
|
exclude: Joi.array().items(Joi.string()).default(DEFAULT_OPTIONS.exclude),
|
||||||
sidebarPath: Joi.alternatives().try(
|
sidebarPath: Joi.alternatives().try(
|
||||||
|
@ -165,16 +168,6 @@ export function validateOptions({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO remove homePageId before end of 2020
|
|
||||||
// "slug: /" is better because the home doc can be different across versions
|
|
||||||
if (options.homePageId) {
|
|
||||||
console.log(
|
|
||||||
chalk.red(
|
|
||||||
`The docs plugin option homePageId=${options.homePageId} is deprecated. To make a doc the "home", prefer frontmatter: "slug: /"`,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const normalizedOptions = validate(OptionsSchema, options);
|
const normalizedOptions = validate(OptionsSchema, options);
|
||||||
|
|
||||||
if (normalizedOptions.admonitions) {
|
if (normalizedOptions.admonitions) {
|
||||||
|
|
|
@ -50,7 +50,6 @@ export type EditUrlFunction = (editUrlParams: {
|
||||||
|
|
||||||
export type MetadataOptions = {
|
export type MetadataOptions = {
|
||||||
routeBasePath: string;
|
routeBasePath: string;
|
||||||
homePageId?: string;
|
|
||||||
editUrl?: string | EditUrlFunction;
|
editUrl?: string | EditUrlFunction;
|
||||||
editCurrentVersion: boolean;
|
editCurrentVersion: boolean;
|
||||||
editLocalizedFiles: boolean;
|
editLocalizedFiles: boolean;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue