From 553a9f2f376a9d489e9096386ffec5b7732aa5e3 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Sun, 18 Jun 2017 01:14:12 +0200 Subject: feat: Use nunjucks templates via koa-nunjucks-next --- src/index.js | 10 ++++++---- src/views/index.html | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 src/views/index.html (limited to 'src') diff --git a/src/index.js b/src/index.js index 9ba74de..630ac08 100644 --- a/src/index.js +++ b/src/index.js @@ -8,10 +8,12 @@ const app = new Koa() const Router = require('koa-router') const router = new Router() -router.get('/', function (ctx, next) { - ctx.status = 200 - ctx.body = 'hello world' - next() +const view = require('koa-nunjucks-next') + +app.use(view(`${__dirname}/views`)) + +router.get('/', async function (ctx, next) { + await ctx.render('index') }) app.use(router.routes()).use(router.allowedMethods()) diff --git a/src/views/index.html b/src/views/index.html new file mode 100644 index 0000000..3b18e51 --- /dev/null +++ b/src/views/index.html @@ -0,0 +1 @@ +hello world -- cgit 1.4.1