mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-25 14:07:50 +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
|
id: doc1
|
||||||
title: Docusaurus
|
title: Docusaurus
|
||||||
|
sidebar_title: Docusaurus Guide
|
||||||
layout: docs
|
layout: docs
|
||||||
category: Docusaurus
|
category: Docusaurus
|
||||||
permalink: docs/en/doc1.html
|
permalink: docs/en/doc1.html
|
||||||
|
|
|
@ -69,12 +69,20 @@ class SideNav extends React.Component {
|
||||||
return categoryString;
|
return categoryString;
|
||||||
}
|
}
|
||||||
getLocalizedString(metadata) {
|
getLocalizedString(metadata) {
|
||||||
let localizedString = translation[this.props.language]
|
let localizedString;
|
||||||
? translation[this.props.language]["localized-strings"][
|
if (metadata.sidebar_title) {
|
||||||
metadata.localized_id
|
localizedString = translation[this.props.language]
|
||||||
] || metadata.title
|
? translation[this.props.language]["localized-strings"][
|
||||||
: metadata.title;
|
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;
|
return localizedString;
|
||||||
}
|
}
|
||||||
getLink(metadata) {
|
getLink(metadata) {
|
||||||
|
|
|
@ -47,6 +47,11 @@ function execute() {
|
||||||
|
|
||||||
translations["localized-strings"][metadata.id] = metadata.title;
|
translations["localized-strings"][metadata.id] = metadata.title;
|
||||||
translations["localized-strings"][metadata.category] = metadata.category;
|
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 */
|
/* look through header links for text to translate */
|
||||||
|
@ -89,7 +94,6 @@ function execute() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
writeFileAndCreateFolder(CWD + "/i18n/en.json", JSON.stringify(translations));
|
writeFileAndCreateFolder(CWD + "/i18n/en.json", JSON.stringify(translations));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue