diff --git a/build.js b/build.js index feb36d0..4b7436f 100644 --- a/build.js +++ b/build.js @@ -199,7 +199,8 @@ function generateEntryPage(entry, template) { title: `${entry.title} | Ursprung Sverige`, subtitle: entry.title, content: entryHtml, - year: new Date().getFullYear() + year: new Date().getFullYear(), + footer: getFooter('../') }); } @@ -275,6 +276,19 @@ function generateFilterHTML(filters) { `; } +// Load footer partial +function getFooter(rootPath = '') { + const footerPath = path.join(TEMPLATE_DIR, 'partials', 'footer.html'); + if (!fs.existsSync(footerPath)) { + return ''; + } + const footerTemplate = fs.readFileSync(footerPath, 'utf-8'); + return renderTemplate(footerTemplate, { + year: new Date().getFullYear(), + rootPath + }); +} + // Main build function function build() { console.log('Building site...'); @@ -313,28 +327,31 @@ function build() { filters: generateFilterHTML(filters), entries: generateEntryCards(entries), entryCount: entries.length, - year: new Date().getFullYear() + year: new Date().getFullYear(), + footer: getFooter('') }); // Write index.html fs.writeFileSync(path.join(DIST_DIR, 'index.html'), indexHtml); // Generate badges info page - const badgesTemplatePath = path.join(TEMPLATE_DIR, 'badges.html'); + const badgesTemplatePath = path.join(TEMPLATE_DIR, 'om-markning.html'); if (fs.existsSync(badgesTemplatePath)) { const badgesTemplate = fs.readFileSync(badgesTemplatePath, 'utf-8'); const badgesHtml = renderTemplate(badgesTemplate, { - year: new Date().getFullYear() + year: new Date().getFullYear(), + footer: getFooter('') }); fs.writeFileSync(path.join(DIST_DIR, 'om-markning.html'), badgesHtml); } // Generate about page - const aboutTemplatePath = path.join(TEMPLATE_DIR, 'about.html'); + const aboutTemplatePath = path.join(TEMPLATE_DIR, 'om-oss.html'); if (fs.existsSync(aboutTemplatePath)) { const aboutTemplate = fs.readFileSync(aboutTemplatePath, 'utf-8'); const aboutHtml = renderTemplate(aboutTemplate, { - year: new Date().getFullYear() + year: new Date().getFullYear(), + footer: getFooter('') }); fs.writeFileSync(path.join(DIST_DIR, 'om-oss.html'), aboutHtml); } diff --git a/templates/badges.html b/templates/om-markning.html similarity index 92% rename from templates/badges.html rename to templates/om-markning.html index 9047163..97fd0f0 100644 --- a/templates/badges.html +++ b/templates/om-markning.html @@ -75,15 +75,6 @@ - +{{ footer }} diff --git a/templates/about.html b/templates/om-oss.html similarity index 90% rename from templates/about.html rename to templates/om-oss.html index 9abf20f..e3c255e 100644 --- a/templates/about.html +++ b/templates/om-oss.html @@ -65,15 +65,6 @@ - +{{ footer }} diff --git a/templates/single.html b/templates/single.html index 34b9067..7faefe2 100644 --- a/templates/single.html +++ b/templates/single.html @@ -21,15 +21,6 @@ - +{{ footer }} diff --git a/templates/template.html b/templates/template.html index 3a9bdb4..afdc284 100644 --- a/templates/template.html +++ b/templates/template.html @@ -43,16 +43,7 @@ - +{{ footer }}