mirror of
https://github.com/facebook/docusaurus.git
synced 2025-04-28 17:57:48 +02:00
Add optional sidebar_title docs front matter field for sidebar titles distinct from document article titles
This commit is contained in:
parent
523d824651
commit
eccbc178e5
3 changed files with 20 additions and 7 deletions
|
@ -1,6 +1,7 @@
|
|||
---
|
||||
id: doc1
|
||||
title: Docusaurus
|
||||
sidebar_title: Docusaurus Guide
|
||||
layout: docs
|
||||
category: Docusaurus
|
||||
permalink: docs/en/doc1.html
|
||||
|
|
|
@ -69,12 +69,20 @@ class SideNav extends React.Component {
|
|||
return categoryString;
|
||||
}
|
||||
getLocalizedString(metadata) {
|
||||
let localizedString = translation[this.props.language]
|
||||
? translation[this.props.language]["localized-strings"][
|
||||
metadata.localized_id
|
||||
] || metadata.title
|
||||
: metadata.title;
|
||||
|
||||
let localizedString;
|
||||
if (metadata.sidebar_title) {
|
||||
localizedString = translation[this.props.language]
|
||||
? translation[this.props.language]["localized-strings"][
|
||||
metadata.sidebar_title
|
||||
] || metadata.sidebar_title
|
||||
: metadata.sidebar_title;
|
||||
} else {
|
||||
localizedString = translation[this.props.language]
|
||||
? translation[this.props.language]["localized-strings"][
|
||||
metadata.localized_id
|
||||
] || metadata.title
|
||||
: metadata.title;
|
||||
}
|
||||
return localizedString;
|
||||
}
|
||||
getLink(metadata) {
|
||||
|
|
|
@ -47,6 +47,11 @@ function execute() {
|
|||
|
||||
translations["localized-strings"][metadata.id] = metadata.title;
|
||||
translations["localized-strings"][metadata.category] = metadata.category;
|
||||
|
||||
if (metadata.sidebar_title) {
|
||||
translations["localized-strings"][metadata.sidebar_title] =
|
||||
metadata.sidebar_title;
|
||||
}
|
||||
}
|
||||
});
|
||||
/* look through header links for text to translate */
|
||||
|
@ -89,7 +94,6 @@ function execute() {
|
|||
});
|
||||
}
|
||||
});
|
||||
|
||||
writeFileAndCreateFolder(CWD + "/i18n/en.json", JSON.stringify(translations));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue