From 7455233d74ffe056c4a5927c9272516fdc0e5dfc Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Sun, 18 Jun 2017 22:12:48 +0200 Subject: feat: make templates extend common layout --- src/index.js | 5 ++++- src/views/index.njk | 6 ++++++ src/views/layouts/main.njk | 13 +++++++++++++ src/views/post.njk | 5 +++++ src/views/term.njk | 4 ++++ 5 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 src/views/layouts/main.njk (limited to 'src') diff --git a/src/index.js b/src/index.js index ae277d6..6622a79 100644 --- a/src/index.js +++ b/src/index.js @@ -17,7 +17,10 @@ const posts = Posts.getFolder(config.posts.folder) app.use( view(`${__dirname}/views`, { - extname: 'njk' + extname: 'njk', + globals: { + site: config.site + } }) ) diff --git a/src/views/index.njk b/src/views/index.njk index dcc142c..1bf275e 100644 --- a/src/views/index.njk +++ b/src/views/index.njk @@ -1,5 +1,11 @@ +{% extends "layouts/main.njk" %} + +{% block body %} + hello world {% for filename, post in posts %} {{ post.data.get('title') }} {% endfor %} + +{% endblock %} diff --git a/src/views/layouts/main.njk b/src/views/layouts/main.njk new file mode 100644 index 0000000..1fe1a93 --- /dev/null +++ b/src/views/layouts/main.njk @@ -0,0 +1,13 @@ + + +
+ +