From e13c5726846a89df4196f6abc9fc98d99d48305b Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Sun, 18 Jun 2017 18:23:28 +0200 Subject: Rename templates to njk It's specified in the nunjucks documentation. Using it allows editors to understand the syntax better --- src/index.js | 6 +++++- src/views/index.html | 5 ----- src/views/index.njk | 5 +++++ src/views/post.html | 3 --- src/views/post.njk | 3 +++ src/views/tag.html | 3 --- src/views/tag.njk | 3 +++ 7 files changed, 16 insertions(+), 12 deletions(-) delete mode 100644 src/views/index.html create mode 100644 src/views/index.njk delete mode 100644 src/views/post.html create mode 100644 src/views/post.njk delete mode 100644 src/views/tag.html create mode 100644 src/views/tag.njk (limited to 'src') diff --git a/src/index.js b/src/index.js index fce4c09..242b298 100644 --- a/src/index.js +++ b/src/index.js @@ -13,7 +13,11 @@ const view = require('koa-nunjucks-next') const Posts = require('./modules/posts.js') const posts = Posts.getFolder(process.env.POST_DIR) -app.use(view(`${__dirname}/views`)) +app.use( + view(`${__dirname}/views`, { + extname: 'njk' + }) +) const postsArray = Array.from(posts.entries()) router.get('/', async function (ctx) { diff --git a/src/views/index.html b/src/views/index.html deleted file mode 100644 index dcc142c..0000000 --- a/src/views/index.html +++ /dev/null @@ -1,5 +0,0 @@ -hello world - -{% for filename, post in posts %} - {{ post.data.get('title') }} -{% endfor %} diff --git a/src/views/index.njk b/src/views/index.njk new file mode 100644 index 0000000..dcc142c --- /dev/null +++ b/src/views/index.njk @@ -0,0 +1,5 @@ +hello world + +{% for filename, post in posts %} + {{ post.data.get('title') }} +{% endfor %} diff --git a/src/views/post.html b/src/views/post.html deleted file mode 100644 index 81f7e3d..0000000 --- a/src/views/post.html +++ /dev/null @@ -1,3 +0,0 @@ -{{ post.data.title }} - -{{ post.body | safe }} diff --git a/src/views/post.njk b/src/views/post.njk new file mode 100644 index 0000000..81f7e3d --- /dev/null +++ b/src/views/post.njk @@ -0,0 +1,3 @@ +{{ post.data.title }} + +{{ post.body | safe }} diff --git a/src/views/tag.html b/src/views/tag.html deleted file mode 100644 index 7ff9871..0000000 --- a/src/views/tag.html +++ /dev/null @@ -1,3 +0,0 @@ -{% for post in posts %} - {{ post.data.get('title') }} -{% endfor %} diff --git a/src/views/tag.njk b/src/views/tag.njk new file mode 100644 index 0000000..7ff9871 --- /dev/null +++ b/src/views/tag.njk @@ -0,0 +1,3 @@ +{% for post in posts %} + {{ post.data.get('title') }} +{% endfor %} -- cgit 1.4.1