From 0e71c2605150f4f00d95283380a236193bfad916 Mon Sep 17 00:00:00 2001 From: Mahesh Asolkar Date: Mon, 2 Jan 2023 13:29:17 -0800 Subject: [PATCH] Added support for up to 5 links in header Use SITE_LINK_NAME_n/SITE_LINK_URL_n environment variables to set the links --- package.json | 2 +- siteinfo.js | 19 +++++++++++++++++++ website.js | 13 +++++++++++-- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index a56bed3..81c9d26 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mma_website_docker", - "version": "0.1.0", + "version": "0.2.0", "description": "Generic Website", "author": "Mahesh Asolkar ", "main": "website.js", diff --git a/siteinfo.js b/siteinfo.js index 5cf0ba8..ef41acf 100644 --- a/siteinfo.js +++ b/siteinfo.js @@ -18,6 +18,25 @@ module.exports = { ret.title = process.env.SITE_TITLE; } + // Links on the site header + var links = []; + if (("SITE_LINK_NAME_1" in process.env) && ("SITE_LINK_URL_1" in process.env)) { + links.push({'name': process.env.SITE_LINK_NAME_1, 'url': process.env.SITE_LINK_URL_1}); + } + if (("SITE_LINK_NAME_2" in process.env) && ("SITE_LINK_URL_2" in process.env)) { + links.push({'name': process.env.SITE_LINK_NAME_2, 'url': process.env.SITE_LINK_URL_2}); + } + if (("SITE_LINK_NAME_3" in process.env) && ("SITE_LINK_URL_3" in process.env)) { + links.push({'name': process.env.SITE_LINK_NAME_3, 'url': process.env.SITE_LINK_URL_3}); + } + if (("SITE_LINK_NAME_4" in process.env) && ("SITE_LINK_URL_4" in process.env)) { + links.push({'name': process.env.SITE_LINK_NAME_4, 'url': process.env.SITE_LINK_URL_4}); + } + if (("SITE_LINK_NAME_5" in process.env) && ("SITE_LINK_URL_5" in process.env)) { + links.push({'name': process.env.SITE_LINK_NAME_5, 'url': process.env.SITE_LINK_URL_5}); + } + ret.links = links; + return ret; }, site_ga_stub: function (req) { diff --git a/website.js b/website.js index e1696be..ae0c6af 100644 --- a/website.js +++ b/website.js @@ -17,7 +17,7 @@ function getPage(req) { console.log(`Serving route ${route}`); - return ` + var page = ` ${website.title} @@ -255,7 +255,14 @@ function toggle_play () {
${website.name} @@ -280,6 +287,8 @@ ${ga_tracking_stub} `; + + return page; } // ----------------------------------------------------------------------