feat(entry-states): display entity state for editors

This commit is contained in:
Benedikt Rötsch
2017-10-24 15:12:26 +02:00
parent 63ff3e0426
commit fd52efd625
8 changed files with 77 additions and 4 deletions

View File

@@ -1,14 +1,21 @@
const { getLandingPage } = require('../services/contentful')
const attachEntryState = require('./../lib/entry-state')
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(
let landingPage = await getLandingPage(
pathname,
res.locals.currentLocale.code,
res.locals.currentApi.id
)
// Attach entry state flags when using preview APIgs
if (res.locals.settings.editorialFeatures && res.locals.currentApi.id === 'cpa') {
landingPage = await attachEntryState(landingPage)
}
res.render('landingPage', { title: pathname, landingPage })
}