X-Git-Url: http://git.squeep.com/?p=squeep-indie-auther;a=blobdiff_plain;f=src%2Ftemplate%2Ftemplate-helper.js;fp=src%2Ftemplate%2Ftemplate-helper.js;h=f15d3e69a99e22dbdb0b9e4412ba82af79aa4f65;hp=a33c8b004a35677925ba3e1c60b0ac8034b212c4;hb=fba42a499fe1af051b0982c1f3e8b3873c9ed2fb;hpb=e8dccf76ec2776f07eddd1ce2f1c4fc150a6f790 diff --git a/src/template/template-helper.js b/src/template/template-helper.js index a33c8b0..f15d3e6 100644 --- a/src/template/template-helper.js +++ b/src/template/template-helper.js @@ -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