feat: add link helper to view globals
1 file changed, 5 insertions(+), 4 deletions(-)
changed files
M src/index.js → src/index.js
@@ -21,19 +21,20 @@ app.use( view(`${__dirname}/views`, { extname: 'njk', globals: { - site: config.site + site: config.site, + url: (...args) => router.url(...args) } }) ) const postsArray = Array.from(posts.entries()) -router.get('/', async function (ctx) { +router.get('home', '/', async function (ctx) { await ctx.render('index', { posts: postsArray }) }) -router.get('/post/:filename', async function (ctx) { +router.get('post', '/post/:filename', async function (ctx) { ctx.assert(posts.has(ctx.params.filename), 404, 'Post not found') const post = posts.get(ctx.params.filename) post.body = Posts.render(post)@@ -44,7 +45,7 @@ }) const taxonomies = Posts.taxonomise(config.taxonomies, posts) for (let [term, items] of taxonomies) { - router.get(`/${term}/:value`, async function (ctx) { + router.get(`taxon-${term}`, `/${term}/:value`, async function (ctx) { const value = ctx.params.value ctx.assert( items.has(ctx.params.value),