mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-03 16:59:06 +02:00
Merge pull request #19 from facebookexperimental/sidebar-titles
Add optional sidebar_title docs front matter field for sidebar title distinct from document article titles
This commit is contained in:
commit
07001fafdc
3 changed files with 19 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,19 @@ 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;
|
||||
const i18n = translation[this.props.language];
|
||||
const sbTitle = metadata.sidebar_title;
|
||||
|
||||
if (sbTitle) {
|
||||
localizedString = i18n
|
||||
? i18n["localized-strings"][sbTitle] || sbTitle
|
||||
: sbTitle;
|
||||
} else {
|
||||
localizedString = i18n
|
||||
? i18n["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
Add a link
Reference in a new issue