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:
Sébastien Lorber 2021-06-16 12:03:46 +02:00 committed by GitHub
parent 41d9288e3d
commit 32e76f1cc0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 25 additions and 10 deletions

View file

@ -2,6 +2,7 @@
id: baz
title: baz
slug: bazSlug.html
pagination_label: baz pagination_label
---
# Baz markdown title
@ -36,7 +37,7 @@ Duplicated footnote reference[^second].
[^first]: Footnote **can have markup**
and multiple paragraphs.
and multiple paragraphs.
[^second]: Footnote text.

View file

@ -182,7 +182,7 @@ Object {
},
\\"sidebar\\": \\"docs\\",
\\"next\\": {
\\"title\\": \\"baz\\",
\\"title\\": \\"baz pagination_label\\",
\\"permalink\\": \\"/docs/foo/bazSlug.html\\"
}
}",
@ -200,7 +200,8 @@ Object {
\\"frontMatter\\": {
\\"id\\": \\"baz\\",
\\"title\\": \\"baz\\",
\\"slug\\": \\"bazSlug.html\\"
\\"slug\\": \\"bazSlug.html\\",
\\"pagination_label\\": \\"baz pagination_label\\"
},
\\"sidebar\\": \\"docs\\",
\\"previous\\": {
@ -243,7 +244,7 @@ Object {
},
\\"sidebar\\": \\"docs\\",
\\"previous\\": {
\\"title\\": \\"baz\\",
\\"title\\": \\"baz pagination_label\\",
\\"permalink\\": \\"/docs/foo/bazSlug.html\\"
}
}",

View file

@ -296,6 +296,7 @@ describe('simple site', () => {
id: 'baz',
slug: 'bazSlug.html',
title: 'baz',
pagination_label: 'baz pagination_label',
},
});
});
@ -354,6 +355,7 @@ describe('simple site', () => {
id: 'baz',
slug: 'bazSlug.html',
title: 'baz',
pagination_label: 'baz pagination_label',
},
});

View file

@ -360,6 +360,7 @@ describe('simple website', () => {
id: 'baz',
title: 'baz',
slug: 'bazSlug.html',
pagination_label: 'baz pagination_label',
},
});
@ -373,7 +374,7 @@ describe('simple website', () => {
permalink: '/docs/',
slug: '/',
previous: {
title: 'baz',
title: 'baz pagination_label',
permalink: '/docs/foo/bazSlug.html',
},
sidebar: 'docs',
@ -399,7 +400,7 @@ describe('simple website', () => {
sourceDirName: 'foo',
isDocsHomePage: false,
next: {
title: 'baz',
title: 'baz pagination_label',
permalink: '/docs/foo/bazSlug.html',
},
permalink: '/docs/foo/bar',

View file

@ -28,6 +28,7 @@ const DocFrontMatterSchema = Joi.object<DocFrontMatter>({
slug: Joi.string(),
sidebar_label: Joi.string(),
sidebar_position: Joi.number().min(0),
pagination_label: Joi.string(),
custom_edit_url: Joi.string().uri({allowRelative: true}).allow('', null),
parse_number_prefixes: Joi.boolean(),
}).unknown();

View file

@ -204,7 +204,10 @@ export default function pluginContentDocs(
const toDocNavLink = (navDocId: string): DocNavLink => {
const {title, permalink, frontMatter} = docsBaseById[navDocId];
return {
title: frontMatter.sidebar_label ?? title,
title:
frontMatter.pagination_label ??
frontMatter.sidebar_label ??
title,
permalink,
};
};

View file

@ -192,6 +192,7 @@ export type DocFrontMatter = {
slug?: string;
sidebar_label?: string;
sidebar_position?: number;
pagination_label?: string;
custom_edit_url?: string | null;
parse_number_prefixes?: boolean;
};

View file

@ -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`
- `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`
- `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.
- `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
- `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
@ -213,10 +214,12 @@ Example:
```yml
---
id: doc-markdown
title: Markdown Features
title: Docs Markdown Features
hide_title: 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
description: How do I find you when I cannot solve this problem
keywords:
@ -225,6 +228,8 @@ keywords:
image: https://i.imgur.com/mErPwqL.png
slug: /myDoc
---
# Markdown Features
My Document Markdown content
```