Added support for up to 5 links in header
Use SITE_LINK_NAME_n/SITE_LINK_URL_n environment variables to set the links
This commit is contained in:
parent
a0e4db0d08
commit
0e71c26051
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "mma_website_docker",
|
||||
"version": "0.1.0",
|
||||
"version": "0.2.0",
|
||||
"description": "Generic Website",
|
||||
"author": "Mahesh Asolkar <mahesh@mahesha.com>",
|
||||
"main": "website.js",
|
||||
|
19
siteinfo.js
19
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) {
|
||||
|
13
website.js
13
website.js
@ -17,7 +17,7 @@ function getPage(req) {
|
||||
|
||||
console.log(`Serving route ${route}`);
|
||||
|
||||
return `<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
var page = `<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head>
|
||||
<title>${website.title}</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
@ -255,7 +255,14 @@ function toggle_play () {
|
||||
</script>
|
||||
</head><body onload="initialize()">
|
||||
<div id="nav_strip">
|
||||
<a href="${website.url}" title="Home">Home</a>
|
||||
<a href="${website.url}" title="Home">Home</a>`;
|
||||
|
||||
website.links.forEach((lnk) => {
|
||||
page += `
|
||||
• <a href="${lnk.url}" title="${lnk.name}">${lnk.name}</a>`;
|
||||
});
|
||||
|
||||
page += `
|
||||
</div>
|
||||
<div id="osc_txt">
|
||||
${website.name}
|
||||
@ -280,6 +287,8 @@ ${ga_tracking_stub}
|
||||
|
||||
</body>
|
||||
</html>`;
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user