rename university to the app. (#4)
This commit is contained in:
committed by
Benedikt Rötsch
parent
71c0c0e95a
commit
e773c8b32d
@@ -1,2 +1,2 @@
|
|||||||
# example-contentful-university-js
|
# the-example-app.js
|
||||||
Contentful university example app
|
The Contentful example app, written in JS
|
||||||
|
|||||||
4
app.js
4
app.js
@@ -42,10 +42,10 @@ app.use(function (req, res, next) {
|
|||||||
const { space_id, preview_access_token, delivery_access_token } = req.query
|
const { space_id, preview_access_token, delivery_access_token } = req.query
|
||||||
if (space_id && preview_access_token && delivery_access_token) { // eslint-disable-line camelcase
|
if (space_id && preview_access_token && delivery_access_token) { // eslint-disable-line camelcase
|
||||||
const settings = {space: space_id, cda: delivery_access_token, cpa: preview_access_token}
|
const settings = {space: space_id, cda: delivery_access_token, cpa: preview_access_token}
|
||||||
res.cookie('universitySettings', settings, { maxAge: 900000, httpOnly: true })
|
res.cookie('theExampleAppSettings', settings, { maxAge: 900000, httpOnly: true })
|
||||||
initClient(settings)
|
initClient(settings)
|
||||||
} else {
|
} else {
|
||||||
initClient(req.cookies.universitySettings)
|
initClient(req.cookies.theExampleAppSettings)
|
||||||
}
|
}
|
||||||
|
|
||||||
next()
|
next()
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "example-contentful-university-js",
|
"name": "example-contentful-theExampleApp-js",
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ const router = express.Router()
|
|||||||
|
|
||||||
/* GET settings page. */
|
/* GET settings page. */
|
||||||
router.get('/', function (req, res, next) {
|
router.get('/', function (req, res, next) {
|
||||||
const cookie = req.cookies.universitySettings
|
const cookie = req.cookies.theExampleAppSettings
|
||||||
const settings = cookie || { cpa: '', cda: '', space: '' }
|
const settings = cookie || { cpa: '', cda: '', space: '' }
|
||||||
res.render('settings', { title: 'Settings', settings })
|
res.render('settings', { title: 'Settings', settings })
|
||||||
})
|
})
|
||||||
@@ -11,7 +11,7 @@ router.get('/', function (req, res, next) {
|
|||||||
/* POST settings page. */
|
/* POST settings page. */
|
||||||
router.post('/', function (req, res, next) {
|
router.post('/', function (req, res, next) {
|
||||||
const settings = {space: req.body.space, cda: req.body.cda, cpa: req.body.cpa}
|
const settings = {space: req.body.space, cda: req.body.cda, cpa: req.body.cpa}
|
||||||
res.cookie('universitySettings', settings, { maxAge: 900000, httpOnly: true })
|
res.cookie('theExampleAppSettings', settings, { maxAge: 900000, httpOnly: true })
|
||||||
res.render('settings', settings)
|
res.render('settings', settings)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ exports.getCourses = (locale = 'en-US', api = `cda`) => {
|
|||||||
exports.getLandingPage = (locale = 'en-US', api = `cda`) => {
|
exports.getLandingPage = (locale = 'en-US', api = `cda`) => {
|
||||||
// our Home page is fully configureable via contentful
|
// our Home page is fully configureable via contentful
|
||||||
const client = api === 'cda' ? cdaClient : cpaClient
|
const client = api === 'cda' ? cdaClient : cpaClient
|
||||||
|
// TODO slug should be renamed to `contentful-the-example-app` or something ....
|
||||||
return client.getEntries({content_type: 'landingPage', locale, 'fields.slug': 'contentful-university', include: 10})
|
return client.getEntries({content_type: 'landingPage', locale, 'fields.slug': 'contentful-university', include: 10})
|
||||||
.then((response) => response.items[0])
|
.then((response) => response.items[0])
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user