From c6d12b4afd83f5b9e4284c52796728aac00db071 Mon Sep 17 00:00:00 2001 From: Khaled Garbaya Date: Tue, 17 Oct 2017 11:59:09 +0200 Subject: [PATCH] fix: Fix New fields naming --- app.js | 1 - handlers/errorHandlers.js | 1 - helpers.js | 1 - package.json | 1 + services/contentful.js | 7 +++++-- variables.env | 6 +++--- views/error.pug | 5 ++++- views/landingPage.pug | 6 +++--- views/mixins/_lesson.pug | 6 +++--- 9 files changed, 19 insertions(+), 15 deletions(-) diff --git a/app.js b/app.js index b4b6ab1..e81720b 100644 --- a/app.js +++ b/app.js @@ -106,7 +106,6 @@ app.use(function (req, res, next) { // error handler app.use(function (err, req, res, next) { // set locals, only providing error in development - res.locals.message = err.message res.locals.error = req.app.get('env') === 'development' ? err : {} // render the error page diff --git a/handlers/errorHandlers.js b/handlers/errorHandlers.js index 7238d6d..9fc3ce0 100644 --- a/handlers/errorHandlers.js +++ b/handlers/errorHandlers.js @@ -8,7 +8,6 @@ exports.catchErrors = (fn) => { return function (req, res, next) { return fn(req, res, next).catch((e) => { - console.log(e) next(e) }) } diff --git a/helpers.js b/helpers.js index 3ee18aa..4044d54 100644 --- a/helpers.js +++ b/helpers.js @@ -1,5 +1,4 @@ const marked = require('marked') - // Parse markdown text exports.markdown = (content) => { content = content || '' diff --git a/package.json b/package.json index 738611b..ac8e61c 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "marked": "^0.3.6", "morgan": "~1.7.0", "pug": "~2.0.0-beta6", + "safe-json-stringify": "^1.0.4", "serve-favicon": "~2.3.0" }, "devDependencies": { diff --git a/services/contentful.js b/services/contentful.js index b470adc..bb514fd 100644 --- a/services/contentful.js +++ b/services/contentful.js @@ -48,12 +48,15 @@ exports.getCourses = assert((locale = 'en-US', api = `cda`) => { exports.getLandingPage = (slug, locale = 'en-US', api = `cda`) => { const client = api === 'cda' ? cdaClient : cpaClient return client.getEntries({ - content_type: 'landingPage', + content_type: 'layout', locale, 'fields.slug': slug, include: 10 }) - .then((response) => response.items[0]) + .then((response) => { + console.log(response.items[0]) + return response.items[0] + }) } // the SDK supports link resolution only when you call the collection endpoints diff --git a/variables.env b/variables.env index 26eaf30..8fccd0f 100644 --- a/variables.env +++ b/variables.env @@ -1,5 +1,5 @@ NODE_ENV=development -CF_SPACE=7ug04s118u1d -CF_ACCESS_TOKEN=f3388cdce19c82685bfbd4a5e20e8bd2581580d7c6e6c6aa4890d8e2e480b930 -CF_PREVIEW_ACCESS_TOKEN=eb77b8bd61d16df53bcd6cfb2b9d1e405e10241b9017550174740e5442e08443 +CF_SPACE=nr89mbmufcmp +CF_ACCESS_TOKEN=76055779832fdf2e228b0c658cc5b161873de870682e736a673c375a0d142a47 +CF_PREVIEW_ACCESS_TOKEN=f3e64121a4a3d2e1794df93cbd285c5a60f1daadfe63d295bdccc4607bfb1d4 PORT=3000 diff --git a/views/error.pug b/views/error.pug index 54fa730..8a261cc 100644 --- a/views/error.pug +++ b/views/error.pug @@ -14,7 +14,10 @@ block content li Check if there's any content for this locale li Verify credentials are correct and up to date li Check the stack trace below - + if error.response + h2 Error + pre.error__stack-trace + code.shell #{helpers.dump(error.response.data)} h2 Stack trace pre.error__stack-trace code.shell #{error.stack} diff --git a/views/landingPage.pug b/views/landingPage.pug index 88243df..4273bd4 100644 --- a/views/landingPage.pug +++ b/views/landingPage.pug @@ -12,11 +12,11 @@ block content +breadcrumb each module in landingPage.fields.contentModules case module.sys.contentType.sys.id - when 'landingPageModuleCopy' + when 'layoutCopy' +moduleCopy(module) - when 'landingPageModuleHeroImage' + when 'layoutHeroImage' +moduleHeroImage(module) - when 'landingPageModuleHighlightedCourse' + when 'layoutHighlightedCourse' +moduleHighlightedCourse(module, module.fields.course) diff --git a/views/mixins/_lesson.pug b/views/mixins/_lesson.pug index 409e14a..6cf7572 100644 --- a/views/mixins/_lesson.pug +++ b/views/mixins/_lesson.pug @@ -11,12 +11,12 @@ mixin lesson(lesson, course, nextLesson) each module in lesson.fields.modules if module.sys.contentType case module.sys.contentType.sys.id - when 'lessonModuleCodeSnippets' + when 'lessonCodeSnippets' +lessonModuleCodeSnippet(module) - when 'lessonModuleCopy' + when 'lessonCopy' +lessonModuleCopy(module) when 'lessonModuleImage' - +lessonModuleImage(module) + +lessonImage(module) else h2 ️️⚠️ Invalid lesson module p