Use SITE_LINK_NAME_n/SITE_LINK_URL_n environment variables to set the links
68 lines
2.5 KiB
JavaScript
68 lines
2.5 KiB
JavaScript
// Exported functions
|
|
module.exports = {
|
|
site_info: function (req) {
|
|
|
|
var ret = {
|
|
"name": "Website Template",
|
|
"url": "https://website.template",
|
|
"title": "Title of website",
|
|
};
|
|
|
|
if ("SITE_NAME" in process.env) {
|
|
ret.name = process.env.SITE_NAME;
|
|
}
|
|
if ("SITE_URL" in process.env) {
|
|
ret.url = process.env.SITE_URL;
|
|
}
|
|
if ("SITE_TITLE" in process.env) {
|
|
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) {
|
|
// Tracking disabled by DNT
|
|
if (("dnt" in req.headers) && (req.headers["dnt"] == 1)) {
|
|
return `<!-- DNT - Tracking disabled -->`;
|
|
}
|
|
|
|
// Google Analytics stub
|
|
if ("SITE_GA_ID" in process.env) {
|
|
return `
|
|
<!-- Google Analytics stuff -->
|
|
<script type="text/javascript">
|
|
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
|
|
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
|
|
</script>
|
|
<script type="text/javascript">
|
|
try {
|
|
var pageTracker = _gat._getTracker("${process.env.SITE_GA_ID}");
|
|
pageTracker._trackPageview();
|
|
} catch(err) {}</script>`;
|
|
}
|
|
|
|
// Default - no tracking information provided
|
|
return "<!-- No GA Tracking -->";
|
|
|
|
}
|
|
}
|