update depedencies, changes to support updated authentication-module
[squeep-indie-auther] / src / template / template-helper.js
index a33c8b004a35677925ba3e1c60b0ac8034b212c4..f15d3e69a99e22dbdb0b9e4412ba82af79aa4f65 100644 (file)
@@ -47,7 +47,34 @@ function scopeCompare([aScope, aDetails], [bScope, bDetails]) {
 }
 
 
+/**
+ * Populate common navLinks for page templates.
+ * @param {Number} pagePathLevel
+ * @param {Object} ctx 
+ * @param {Object} options 
+ */
+function navLinks(pagePathLevel, ctx, options) {
+  if (!options.navLinks) {
+    options.navLinks = [];
+  }
+  const rootPath = '../'.repeat(pagePathLevel);
+
+  if (options.pageIdentifier !== 'admin') {
+    options.navLinks.push({
+      text: 'Admin',
+      href: `${rootPath}admin/`,
+    });
+  }
+  if (options.pageIdentifier !== 'ticketProffer') {
+    options.navLinks.push({
+      text: 'Ticket',
+      href: `${rootPath}admin/ticket`,
+    });
+  }
+}
+
 module.exports = Object.assign(Object.create(TemplateHelper), {
   escapeCSS,
   scopeCompare,
+  navLinks,
 });
\ No newline at end of file