mirror of
https://github.com/facebook/docusaurus.git
synced 2025-04-29 02:08:36 +02:00
enhance: fallback sidebar title to dirname if index/readme
This commit is contained in:
parent
36db64ed1d
commit
353a12537b
1 changed files with 6 additions and 1 deletions
|
@ -238,7 +238,12 @@ async function doProcessDocMetadata({
|
|||
// 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)
|
||||
const title: string = frontMatter.title ?? contentTitle ?? baseID;
|
||||
// if filename is `index` or `readme`, then use the parent directory name
|
||||
const derivedNameFromPath = /^(?:index|readme)$/i.test(baseID)
|
||||
? path.basename(sourceDirName)
|
||||
: unprefixedFileName;
|
||||
const title: string =
|
||||
frontMatter.title ?? contentTitle ?? derivedNameFromPath;
|
||||
|
||||
const description: string = frontMatter.description ?? excerpt ?? '';
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue