refactor: refactor home and about routes

This commit is contained in:
Khaled Garbaya
2017-10-23 15:31:15 +02:00
committed by Benedikt Rötsch
parent 1e94188333
commit a91e46d70b
4 changed files with 18 additions and 25 deletions

14
routes/landingPage.js Normal file
View File

@@ -0,0 +1,14 @@
const { getLandingPage } = require('../services/contentful')
const url = require('url')
exports.getLandingPage = async (req, res, next) => {
let pathname = url.parse(req.url).pathname.split('/').filter(Boolean)[0]
pathname = pathname || 'home'
const landingPage = await getLandingPage(
pathname,
res.locals.currentLocale.code,
res.locals.currentApi.id
)
res.render('landingPage', { title: pathname, landingPage })
}