update dependencies, fixes to support new authentication features
[websub-hub] / src / template / template-helper.js
index f891e4fe65949633d7326d0dd644b9e85510fb52..5850fc1256604c955fdf973931b0e93ed97d2734 100644 (file)
@@ -134,10 +134,33 @@ function xmlEscape(string) {
   }[c]));
 }
 
+
+/**
+ * Add common site links to navigation header.
+ * @param {number} pagePathLevel depth from root
+ * @param {object} ctx context
+ * @param {object} options 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/`,
+    });
+  }
+}
+
+
 module.exports = Object.assign(Object.create(TemplateHelper), {
+  navLinks,
   xmlEscape,
   renderTopicRowHeader,
   renderTopicRow,
   renderSubscriptionRowHeader,
   renderSubscriptionRow,
-});
\ No newline at end of file
+});