diff options
author | Alan Pearce | 2017-06-18 01:14:12 +0200 |
---|---|---|
committer | Alan Pearce | 2017-06-18 01:14:12 +0200 |
commit | 553a9f2f376a9d489e9096386ffec5b7732aa5e3 (patch) | |
tree | 6590a6f04d93a68e6514714c1c190173e5c5da73 /src | |
parent | a00908501a435051cd91c59562d43bb8dd7d56f5 (diff) | |
download | homestead-553a9f2f376a9d489e9096386ffec5b7732aa5e3.tar.lz homestead-553a9f2f376a9d489e9096386ffec5b7732aa5e3.tar.zst homestead-553a9f2f376a9d489e9096386ffec5b7732aa5e3.zip |
feat: Use nunjucks templates via koa-nunjucks-next
Diffstat (limited to 'src')
-rw-r--r-- | src/index.js | 10 | ||||
-rw-r--r-- | src/views/index.html | 1 |
2 files changed, 7 insertions, 4 deletions
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 |