mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 15:47:23 +02:00
feat(v2): add docs pagination_label frontmatter (#4982)
* feat(v2): add docs pagination_label frontmatter * feat(v2): add docs pagination_label frontmatter * feat(v2): add docs pagination_label frontmatter
This commit is contained in:
parent
41d9288e3d
commit
32e76f1cc0
8 changed files with 25 additions and 10 deletions
|
@ -2,6 +2,7 @@
|
||||||
id: baz
|
id: baz
|
||||||
title: baz
|
title: baz
|
||||||
slug: bazSlug.html
|
slug: bazSlug.html
|
||||||
|
pagination_label: baz pagination_label
|
||||||
---
|
---
|
||||||
|
|
||||||
# Baz markdown title
|
# Baz markdown title
|
||||||
|
@ -36,7 +37,7 @@ Duplicated footnote reference[^second].
|
||||||
|
|
||||||
[^first]: Footnote **can have markup**
|
[^first]: Footnote **can have markup**
|
||||||
|
|
||||||
and multiple paragraphs.
|
and multiple paragraphs.
|
||||||
|
|
||||||
[^second]: Footnote text.
|
[^second]: Footnote text.
|
||||||
|
|
||||||
|
|
|
@ -182,7 +182,7 @@ Object {
|
||||||
},
|
},
|
||||||
\\"sidebar\\": \\"docs\\",
|
\\"sidebar\\": \\"docs\\",
|
||||||
\\"next\\": {
|
\\"next\\": {
|
||||||
\\"title\\": \\"baz\\",
|
\\"title\\": \\"baz pagination_label\\",
|
||||||
\\"permalink\\": \\"/docs/foo/bazSlug.html\\"
|
\\"permalink\\": \\"/docs/foo/bazSlug.html\\"
|
||||||
}
|
}
|
||||||
}",
|
}",
|
||||||
|
@ -200,7 +200,8 @@ Object {
|
||||||
\\"frontMatter\\": {
|
\\"frontMatter\\": {
|
||||||
\\"id\\": \\"baz\\",
|
\\"id\\": \\"baz\\",
|
||||||
\\"title\\": \\"baz\\",
|
\\"title\\": \\"baz\\",
|
||||||
\\"slug\\": \\"bazSlug.html\\"
|
\\"slug\\": \\"bazSlug.html\\",
|
||||||
|
\\"pagination_label\\": \\"baz pagination_label\\"
|
||||||
},
|
},
|
||||||
\\"sidebar\\": \\"docs\\",
|
\\"sidebar\\": \\"docs\\",
|
||||||
\\"previous\\": {
|
\\"previous\\": {
|
||||||
|
@ -243,7 +244,7 @@ Object {
|
||||||
},
|
},
|
||||||
\\"sidebar\\": \\"docs\\",
|
\\"sidebar\\": \\"docs\\",
|
||||||
\\"previous\\": {
|
\\"previous\\": {
|
||||||
\\"title\\": \\"baz\\",
|
\\"title\\": \\"baz pagination_label\\",
|
||||||
\\"permalink\\": \\"/docs/foo/bazSlug.html\\"
|
\\"permalink\\": \\"/docs/foo/bazSlug.html\\"
|
||||||
}
|
}
|
||||||
}",
|
}",
|
||||||
|
|
|
@ -296,6 +296,7 @@ describe('simple site', () => {
|
||||||
id: 'baz',
|
id: 'baz',
|
||||||
slug: 'bazSlug.html',
|
slug: 'bazSlug.html',
|
||||||
title: 'baz',
|
title: 'baz',
|
||||||
|
pagination_label: 'baz pagination_label',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -354,6 +355,7 @@ describe('simple site', () => {
|
||||||
id: 'baz',
|
id: 'baz',
|
||||||
slug: 'bazSlug.html',
|
slug: 'bazSlug.html',
|
||||||
title: 'baz',
|
title: 'baz',
|
||||||
|
pagination_label: 'baz pagination_label',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -360,6 +360,7 @@ describe('simple website', () => {
|
||||||
id: 'baz',
|
id: 'baz',
|
||||||
title: 'baz',
|
title: 'baz',
|
||||||
slug: 'bazSlug.html',
|
slug: 'bazSlug.html',
|
||||||
|
pagination_label: 'baz pagination_label',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -373,7 +374,7 @@ describe('simple website', () => {
|
||||||
permalink: '/docs/',
|
permalink: '/docs/',
|
||||||
slug: '/',
|
slug: '/',
|
||||||
previous: {
|
previous: {
|
||||||
title: 'baz',
|
title: 'baz pagination_label',
|
||||||
permalink: '/docs/foo/bazSlug.html',
|
permalink: '/docs/foo/bazSlug.html',
|
||||||
},
|
},
|
||||||
sidebar: 'docs',
|
sidebar: 'docs',
|
||||||
|
@ -399,7 +400,7 @@ describe('simple website', () => {
|
||||||
sourceDirName: 'foo',
|
sourceDirName: 'foo',
|
||||||
isDocsHomePage: false,
|
isDocsHomePage: false,
|
||||||
next: {
|
next: {
|
||||||
title: 'baz',
|
title: 'baz pagination_label',
|
||||||
permalink: '/docs/foo/bazSlug.html',
|
permalink: '/docs/foo/bazSlug.html',
|
||||||
},
|
},
|
||||||
permalink: '/docs/foo/bar',
|
permalink: '/docs/foo/bar',
|
||||||
|
|
|
@ -28,6 +28,7 @@ const DocFrontMatterSchema = Joi.object<DocFrontMatter>({
|
||||||
slug: Joi.string(),
|
slug: Joi.string(),
|
||||||
sidebar_label: Joi.string(),
|
sidebar_label: Joi.string(),
|
||||||
sidebar_position: Joi.number().min(0),
|
sidebar_position: Joi.number().min(0),
|
||||||
|
pagination_label: Joi.string(),
|
||||||
custom_edit_url: Joi.string().uri({allowRelative: true}).allow('', null),
|
custom_edit_url: Joi.string().uri({allowRelative: true}).allow('', null),
|
||||||
parse_number_prefixes: Joi.boolean(),
|
parse_number_prefixes: Joi.boolean(),
|
||||||
}).unknown();
|
}).unknown();
|
||||||
|
|
|
@ -204,7 +204,10 @@ export default function pluginContentDocs(
|
||||||
const toDocNavLink = (navDocId: string): DocNavLink => {
|
const toDocNavLink = (navDocId: string): DocNavLink => {
|
||||||
const {title, permalink, frontMatter} = docsBaseById[navDocId];
|
const {title, permalink, frontMatter} = docsBaseById[navDocId];
|
||||||
return {
|
return {
|
||||||
title: frontMatter.sidebar_label ?? title,
|
title:
|
||||||
|
frontMatter.pagination_label ??
|
||||||
|
frontMatter.sidebar_label ??
|
||||||
|
title,
|
||||||
permalink,
|
permalink,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -192,6 +192,7 @@ export type DocFrontMatter = {
|
||||||
slug?: string;
|
slug?: string;
|
||||||
sidebar_label?: string;
|
sidebar_label?: string;
|
||||||
sidebar_position?: number;
|
sidebar_position?: number;
|
||||||
|
pagination_label?: string;
|
||||||
custom_edit_url?: string | null;
|
custom_edit_url?: string | null;
|
||||||
parse_number_prefixes?: boolean;
|
parse_number_prefixes?: boolean;
|
||||||
};
|
};
|
||||||
|
|
|
@ -199,8 +199,9 @@ Markdown documents can use the following Markdown FrontMatter metadata fields, e
|
||||||
- `title`: The text title of your document. Used for the page metadata and as a fallback value in multiple places (sidebar, next/previous buttons...). Automatically added at the top of your doc if it does not contain any Markdown title. Default value: Markdown title or doc `id`
|
- `title`: The text title of your document. Used for the page metadata and as a fallback value in multiple places (sidebar, next/previous buttons...). Automatically added at the top of your doc if it does not contain any Markdown title. Default value: Markdown title or doc `id`
|
||||||
- `hide_title`: Whether to hide the title at the top of the doc. It only hides a title declared through the frontmatter, and have no effect on a Markdown title at the top of your document. Default value: `false`
|
- `hide_title`: Whether to hide the title at the top of the doc. It only hides a title declared through the frontmatter, and have no effect on a Markdown title at the top of your document. Default value: `false`
|
||||||
- `hide_table_of_contents`: Whether to hide the table of contents to the right. Default value: `false`
|
- `hide_table_of_contents`: Whether to hide the table of contents to the right. Default value: `false`
|
||||||
- `sidebar_label`: The text shown in the document sidebar and in the next/previous button for this document. Default value: doc `title`
|
- `sidebar_label`: The text shown in the document sidebar for this document. Default value: `title`
|
||||||
- `sidebar_position`: Permits to control the position of a doc inside the generated sidebar slice, when using `autogenerated` sidebar items. Can be Int or Float.
|
- `sidebar_position`: Permits to control the position of a doc inside the generated sidebar slice, when using `autogenerated` sidebar items. Can be Int or Float.
|
||||||
|
- `pagination_label`: The text used in the document next/previous buttons for this document. Default value: `sidebar_label`, or `title`
|
||||||
- `parse_number_prefixes`: When a document has a number prefix (`001 - My Doc.md`, `2. MyDoc.md`...), it is automatically parsed and extracted by the plugin `numberPrefixParser`, and the number prefix is used as `sidebar_position`. Use `parse_number_prefixes: false` to disable number prefix parsing on this doc. Default value: `parse_number_prefixes` plugin option
|
- `parse_number_prefixes`: When a document has a number prefix (`001 - My Doc.md`, `2. MyDoc.md`...), it is automatically parsed and extracted by the plugin `numberPrefixParser`, and the number prefix is used as `sidebar_position`. Use `parse_number_prefixes: false` to disable number prefix parsing on this doc. Default value: `parse_number_prefixes` plugin option
|
||||||
- `custom_edit_url`: The URL for editing this document. Default value: computed using the `editUrl` plugin options
|
- `custom_edit_url`: The URL for editing this document. Default value: computed using the `editUrl` plugin options
|
||||||
- `keywords`: Keywords meta tag for the document page, for search engines
|
- `keywords`: Keywords meta tag for the document page, for search engines
|
||||||
|
@ -213,10 +214,12 @@ Example:
|
||||||
```yml
|
```yml
|
||||||
---
|
---
|
||||||
id: doc-markdown
|
id: doc-markdown
|
||||||
title: Markdown Features
|
title: Docs Markdown Features
|
||||||
hide_title: false
|
hide_title: false
|
||||||
hide_table_of_contents: false
|
hide_table_of_contents: false
|
||||||
sidebar_label: Markdown :)
|
sidebar_label: Markdown
|
||||||
|
sidebar_position: 3
|
||||||
|
pagination_label: Markdown features
|
||||||
custom_edit_url: https://github.com/facebook/docusaurus/edit/master/docs/api-doc-markdown.md
|
custom_edit_url: https://github.com/facebook/docusaurus/edit/master/docs/api-doc-markdown.md
|
||||||
description: How do I find you when I cannot solve this problem
|
description: How do I find you when I cannot solve this problem
|
||||||
keywords:
|
keywords:
|
||||||
|
@ -225,6 +228,8 @@ keywords:
|
||||||
image: https://i.imgur.com/mErPwqL.png
|
image: https://i.imgur.com/mErPwqL.png
|
||||||
slug: /myDoc
|
slug: /myDoc
|
||||||
---
|
---
|
||||||
|
# Markdown Features
|
||||||
|
|
||||||
My Document Markdown content
|
My Document Markdown content
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue