Add previous and next titles to metadata props

This commit is contained in:
Joel Marcey 2017-10-24 19:09:34 -07:00
parent 429ffda351
commit 7b2e950a4c
2 changed files with 14 additions and 3 deletions

View file

@ -17,7 +17,7 @@ class DocsLayout extends React.Component {
render() { render() {
const metadata = this.props.metadata; const metadata = this.props.metadata;
const content = this.props.children; const content = this.props.children;
const i18n = translation[this.props.metadata.language]; const i18n = false; //translation[this.props.metadata.language];
let DocComponent = Doc; let DocComponent = Doc;
if (this.props.Doc) { if (this.props.Doc) {
DocComponent = this.props.Doc; DocComponent = this.props.Doc;
@ -68,7 +68,7 @@ class DocsLayout extends React.Component {
"localized-strings" "localized-strings"
]["previous"] || ]["previous"] ||
"Previous" "Previous"
: metadata[metadata.previous_id].title || "Previous" : metadata.previous_title || "Previous"
} }
</a> </a>
)} )}
@ -84,7 +84,7 @@ class DocsLayout extends React.Component {
"localized-strings" "localized-strings"
]["next"] || ]["next"] ||
"Next" "Next"
: metadata[metadata.next_id].title || "Next" : metadata.next_title || "Next"
}{" "} }{" "}
</a> </a>

View file

@ -289,6 +289,17 @@ function generateMetadataDocs() {
metadatas[metadata.id] = metadata; metadatas[metadata.id] = metadata;
}); });
// Get the titles of the previous and next ids so that we can use them in
// navigation buttons in DocsLayout.js
Object.keys(metadatas).forEach(function(metadata) {
if (metadatas[metadata].previous) {
metadatas[metadata].previous_title = metadatas[metadatas[metadata].previous].title;
}
if (metadatas[metadata].next) {
metadatas[metadata].next_title = metadatas[metadatas[metadata].next].title;
}
});
fs.writeFileSync( fs.writeFileSync(
__dirname + "/../core/metadata.js", __dirname + "/../core/metadata.js",
"/**\n" + "/**\n" +