From a8ebda3ed5043ebdd4889748aa0bf0c6102cacf4 Mon Sep 17 00:00:00 2001 From: Sarath Damaraju Date: Fri, 5 Oct 2018 20:00:18 +0530 Subject: [PATCH] Added side nav to glossary and archived pages --- scripts/web.js | 65 ++++++++--- static-parts/glossary-page-end.html | 18 --- static-parts/glossary-page-start.html | 108 ------------------ ...ved-page-end.html => static-page-end.html} | 0 ...page-start.html => static-page-start.html} | 30 ++--- 5 files changed, 66 insertions(+), 155 deletions(-) delete mode 100644 static-parts/glossary-page-end.html delete mode 100644 static-parts/glossary-page-start.html rename static-parts/{archived-page-end.html => static-page-end.html} (100%) rename static-parts/{archived-page-start.html => static-page-start.html} (81%) diff --git a/scripts/web.js b/scripts/web.js index 780d97f1e..232a53dfb 100644 --- a/scripts/web.js +++ b/scripts/web.js @@ -128,11 +128,7 @@ let snippets = {}, startPart = '', endPart = '', output = '', - archivedStartPart = '', - archivedEndPart = '', archivedOutput = '', - glossaryStartPart = '', - glossaryEndPart = '', glossaryOutput = '', pagesOutput = [], tagDbData = {}; @@ -145,13 +141,11 @@ glossarySnippets = util.readSnippets(glossarySnippetsPath); // Load static parts for all pages try { - [startPart, endPart, archivedStartPart, archivedEndPart, glossaryStartPart, glossaryEndPart] = [ + [startPart, endPart, staticPageStartPart, staticPageEndPart] = [ 'page-start.html', 'page-end.html', - 'archived-page-start.html', - 'archived-page-end.html', - 'glossary-page-start.html', - 'glossary-page-end.html' + 'static-page-start.html', + 'static-page-end.html' ].map(filename => fs.readFileSync(path.join(staticPartsPath, filename), 'utf8')); } catch (err) { // Handle errors (hopefully not!) @@ -243,10 +237,51 @@ try { process.exit(1); } +const staticPageStartGenerator = (staticPart, heading, description) => { + let taggedData = util.prepTaggedData(tagDbData); + // Add the start static part + let htmlCode = `${staticPart}\n`; + + // Loop over tags and snippets to create the table of contents + for (let tag of taggedData) { + htmlCode += + '

' + + md + .render(`${util.capitalize(tag, true)}\n`) + .replace(/

/g, '') + .replace(/<\/p>/g, '') + + '