From 7c1b48b92cd42ec1920be45f5776761328b7a5c0 Mon Sep 17 00:00:00 2001 From: Joel Marcey Date: Tue, 24 Oct 2017 15:35:56 -0700 Subject: [PATCH 1/5] Show doc names instead of previous and next Use the previous and next doc metadata to show docs in the buttons --- lib/core/DocsLayout.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/core/DocsLayout.js b/lib/core/DocsLayout.js index bf0bea199f..50d74ae953 100644 --- a/lib/core/DocsLayout.js +++ b/lib/core/DocsLayout.js @@ -63,7 +63,7 @@ class DocsLayout extends React.Component { {i18n ? translation[this.props.metadata.language][ "localized-strings" - ]["previous"] || "Previous" + ][metadata.previous_id] || metadata.previous_id : "Previous"} )} @@ -74,7 +74,7 @@ class DocsLayout extends React.Component { {i18n ? translation[this.props.metadata.language][ "localized-strings" - ]["next"] || "Next" + ][metadata.next_id] || metadata.next_id : "Next"}{" "} → From 78bd09dec30b55abfb0958af60325944ec1ed958 Mon Sep 17 00:00:00 2001 From: Joel Marcey Date: Tue, 24 Oct 2017 16:35:32 -0700 Subject: [PATCH 2/5] Better logic --- lib/core/DocsLayout.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/core/DocsLayout.js b/lib/core/DocsLayout.js index 50d74ae953..5cc4cdfeb2 100644 --- a/lib/core/DocsLayout.js +++ b/lib/core/DocsLayout.js @@ -63,8 +63,13 @@ class DocsLayout extends React.Component { {i18n ? translation[this.props.metadata.language][ "localized-strings" - ][metadata.previous_id] || metadata.previous_id - : "Previous"} + ][metadata.previous_id] || + translation[this.props.metadata.language][ + "localized-strings" + ]["previous"] || + "Previous" + : metadata.previous_id || "Previous" + } )} {metadata.next_id && ( @@ -74,8 +79,13 @@ class DocsLayout extends React.Component { {i18n ? translation[this.props.metadata.language][ "localized-strings" - ][metadata.next_id] || metadata.next_id - : "Next"}{" "} + ][metadata.next_id] || + translation[this.props.metadata.language][ + "localized-strings" + ]["next"] || + "Next" + : metadata.next_id || "Next" + }{" "} → )} From 429ffda35106638c16924464fad83a1611c6e3d5 Mon Sep 17 00:00:00 2001 From: Joel Marcey Date: Tue, 24 Oct 2017 16:42:31 -0700 Subject: [PATCH 3/5] Use title of previous and next if no i18n --- lib/core/DocsLayout.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/core/DocsLayout.js b/lib/core/DocsLayout.js index 5cc4cdfeb2..194360ad2e 100644 --- a/lib/core/DocsLayout.js +++ b/lib/core/DocsLayout.js @@ -68,7 +68,7 @@ class DocsLayout extends React.Component { "localized-strings" ]["previous"] || "Previous" - : metadata.previous_id || "Previous" + : metadata[metadata.previous_id].title || "Previous" } )} @@ -84,7 +84,7 @@ class DocsLayout extends React.Component { "localized-strings" ]["next"] || "Next" - : metadata.next_id || "Next" + : metadata[metadata.next_id].title || "Next" }{" "} → From 7b2e950a4c35538fc359d7106022403e96883bca Mon Sep 17 00:00:00 2001 From: Joel Marcey Date: Tue, 24 Oct 2017 19:09:34 -0700 Subject: [PATCH 4/5] Add previous and next titles to metadata props --- lib/core/DocsLayout.js | 6 +++--- lib/server/readMetadata.js | 11 +++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/core/DocsLayout.js b/lib/core/DocsLayout.js index 194360ad2e..1ae8f84214 100644 --- a/lib/core/DocsLayout.js +++ b/lib/core/DocsLayout.js @@ -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" } )} @@ -84,7 +84,7 @@ class DocsLayout extends React.Component { "localized-strings" ]["next"] || "Next" - : metadata[metadata.next_id].title || "Next" + : metadata.next_title || "Next" }{" "} → diff --git a/lib/server/readMetadata.js b/lib/server/readMetadata.js index 792afc9a5c..cf60cc2736 100644 --- a/lib/server/readMetadata.js +++ b/lib/server/readMetadata.js @@ -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" + From 0df005484c80cbf98190c1811f307d1c979342d4 Mon Sep 17 00:00:00 2001 From: Joel Marcey Date: Tue, 24 Oct 2017 19:10:29 -0700 Subject: [PATCH 5/5] Oops - forgot to remove debugging statement --- lib/core/DocsLayout.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/core/DocsLayout.js b/lib/core/DocsLayout.js index 1ae8f84214..117202dcd3 100644 --- a/lib/core/DocsLayout.js +++ b/lib/core/DocsLayout.js @@ -17,7 +17,7 @@ class DocsLayout extends React.Component { render() { const metadata = this.props.metadata; const content = this.props.children; - const i18n = false; //translation[this.props.metadata.language]; + const i18n = translation[this.props.metadata.language]; let DocComponent = Doc; if (this.props.Doc) { DocComponent = this.props.Doc;