mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 23:57:22 +02:00
Add previous and next titles to metadata props
This commit is contained in:
parent
429ffda351
commit
7b2e950a4c
2 changed files with 14 additions and 3 deletions
|
@ -17,7 +17,7 @@ class DocsLayout extends React.Component {
|
|||
render() {
|
||||
const metadata = this.props.metadata;
|
||||
const content = this.props.children;
|
||||
const i18n = translation[this.props.metadata.language];
|
||||
const i18n = false; //translation[this.props.metadata.language];
|
||||
let DocComponent = Doc;
|
||||
if (this.props.Doc) {
|
||||
DocComponent = this.props.Doc;
|
||||
|
@ -68,7 +68,7 @@ class DocsLayout extends React.Component {
|
|||
"localized-strings"
|
||||
]["previous"] ||
|
||||
"Previous"
|
||||
: metadata[metadata.previous_id].title || "Previous"
|
||||
: metadata.previous_title || "Previous"
|
||||
}
|
||||
</a>
|
||||
)}
|
||||
|
@ -84,7 +84,7 @@ class DocsLayout extends React.Component {
|
|||
"localized-strings"
|
||||
]["next"] ||
|
||||
"Next"
|
||||
: metadata[metadata.next_id].title || "Next"
|
||||
: metadata.next_title || "Next"
|
||||
}{" "}
|
||||
→
|
||||
</a>
|
||||
|
|
|
@ -289,6 +289,17 @@ function generateMetadataDocs() {
|
|||
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(
|
||||
__dirname + "/../core/metadata.js",
|
||||
"/**\n" +
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue