fix(v2): use frontmatter title at first for paginated links (#4859)

This commit is contained in:
Alexey Pyltsyn 2021-06-02 18:02:48 +03:00 committed by GitHub
parent 08b94580e9
commit 0417ab9532
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 6 deletions

View file

@ -4,6 +4,8 @@ title: baz
slug: bazSlug.html
---
# Baz markdown title
## Images
Like links, Images also have a footnote style syntax

View file

@ -190,7 +190,7 @@ Object {
\\"unversionedId\\": \\"foo/baz\\",
\\"id\\": \\"foo/baz\\",
\\"isDocsHomePage\\": false,
\\"title\\": \\"baz\\",
\\"title\\": \\"Baz markdown title\\",
\\"description\\": \\"Images\\",
\\"source\\": \\"@site/docs/foo/baz.md\\",
\\"sourceDirName\\": \\"foo\\",
@ -204,7 +204,7 @@ Object {
},
\\"sidebar\\": \\"docs\\",
\\"previous\\": {
\\"title\\": \\"Remarkable\\",
\\"title\\": \\"Bar\\",
\\"permalink\\": \\"/docs/foo/bar\\"
},
\\"next\\": {
@ -423,7 +423,7 @@ Object {
},
{
\\"type\\": \\"link\\",
\\"label\\": \\"baz\\",
\\"label\\": \\"Baz markdown title\\",
\\"href\\": \\"/docs/foo/bazSlug.html\\"
}
]

View file

@ -286,7 +286,7 @@ describe('simple site', () => {
isDocsHomePage: false,
permalink: '/docs/foo/bazSlug.html',
slug: '/foo/bazSlug.html',
title: 'baz',
title: 'Baz markdown title',
editUrl:
'https://github.com/facebook/docusaurus/edit/master/website/docs/foo/baz.md',
description: 'Images',
@ -345,7 +345,7 @@ describe('simple site', () => {
isDocsHomePage: false,
permalink: '/docs/foo/bazSlug.html',
slug: '/foo/bazSlug.html',
title: 'baz',
title: 'Baz markdown title',
editUrl: hardcodedEditUrl,
description: 'Images',
frontMatter: {

View file

@ -199,7 +199,11 @@ export default function pluginContentDocs(
nextId,
} = sidebarsUtils.getDocNavigation(doc.id);
const toDocNavLink = (navDocId: string): DocNavLink => ({
title: docsBaseById[navDocId].title,
// Use frontMatter.title in priority over a potential # title found in markdown
// See https://github.com/facebook/docusaurus/issues/4665#issuecomment-825831367
title:
docsBaseById[navDocId].frontMatter.title ||
docsBaseById[navDocId].title,
permalink: docsBaseById[navDocId].permalink,
});
return {