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:
committed by
GitHub
parent
a48fd1b63d
commit
81577c82fd
13
lib/enhance-breadcrumb.js
Normal file
13
lib/enhance-breadcrumb.js
Normal file
@@ -0,0 +1,13 @@
|
||||
module.exports = (request, resource) => {
|
||||
const breadcrumbs = request.app.locals.breadcrumb
|
||||
|
||||
let enhancedBreadcrumbs = breadcrumbs.map((breadcrumb) => {
|
||||
if (breadcrumb.label.replace(/ /g, '-') == resource.fields.slug) {
|
||||
breadcrumb.label = resource.fields.title
|
||||
}
|
||||
return breadcrumb
|
||||
})
|
||||
|
||||
// We replace the breadcrumbs with the enhanced version
|
||||
request.app.locals.breadcrumb = enhancedBreadcrumbs
|
||||
}
|
||||
Reference in New Issue
Block a user