Enhance Breadcrumbs (#39)

* chore(localization): remove duplicated locale files

* feat(localization): add localization for breadcrumbs

* feat(localization): add beadcrumb enhancements

* feat(debugging): add npm run debug command

* chore(localization): add unit tests

* chore(breadcrumbs): fix tests and typos

* chore(localization): add docs for translationAvailable

* chore(localization): refactor translationAvailable
This commit is contained in:
David Litvak Bruno
2017-11-08 15:39:24 +01:00
committed by GitHub
parent a48fd1b63d
commit 81577c82fd
10 changed files with 67 additions and 158 deletions

View File

@@ -10,6 +10,7 @@ const {
} = require('./../services/contentful')
const attachEntryState = require('../lib/entry-state')
const enhanceBreadcrumb = require('../lib/enhance-breadcrumb')
const { updateCookie } = require('../lib/cookies')
const { translate } = require('../i18n/i18n')
@@ -69,6 +70,9 @@ module.exports.getCourse = async (request, response, next) => {
course = await attachEntryState(course)
}
// Enhance the breadcrumbs with the course
enhanceBreadcrumb(request, course)
response.render('course', {title: course.fields.title, course, lesson, lessons, lessonIndex, visitedLessons})
}
@@ -93,6 +97,10 @@ module.exports.getCoursesByCategory = async (request, response, next) => {
} catch (e) {
console.log('Error ', e)
}
// Enhance the breadcrumbs with the active category
enhanceBreadcrumb(request, activeCategory)
response.render('courses', { title: `${activeCategory.fields.title} (${courses.length})`, categories, courses })
}
@@ -123,6 +131,10 @@ module.exports.getLesson = async (request, response, next) => {
lesson = await attachEntryState(lesson)
}
// Enhance the breadcrumbs with the course and active lesson
enhanceBreadcrumb(request, course)
enhanceBreadcrumb(request, lesson)
response.render('course', {
title: `${course.fields.title} | ${lesson.fields.title}`,
course,