-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed tech debt related to path prefix usages (#334)
* Removed path prefix usages * Removed test path prefix for e2e workflow * Removed tag page logic used to work around path prefix issue
- Loading branch information
1 parent
7809ac2
commit 9527809
Showing
6 changed files
with
11 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,6 @@ | ||
// noinspection JSUnusedGlobalSymbols | ||
const { applyBaseToUrl } = require('@11ty/eleventy/src/Plugins/HtmlBasePlugin') | ||
|
||
function mapRelatedSections(sections, pathPrefix) { | ||
return sections.map( | ||
section => ({ | ||
...section, | ||
items: (section.items ?? []).map(item => ({ | ||
...item, | ||
href: applyBaseToUrl(item.href, pathPrefix, {pathPrefix}), | ||
})), | ||
subsections: mapRelatedSections(section.subsections ?? [], pathPrefix), | ||
}) | ||
); | ||
} | ||
|
||
module.exports = { | ||
eleventyExcludeFromCollections: ({page, eleventyExcludeFromCollections}) => { | ||
return eleventyExcludeFromCollections || page.templateSyntax === 'scss'; | ||
}, | ||
// the path prefix isn't applied to related link urls by xGovukRelatedNavigation - so map them here | ||
pagination: ({pagination, pathPrefix}) => { | ||
if (!pagination || Object.keys(pagination).length === 0) { | ||
return pagination; | ||
} | ||
if (pagination.href.previous) { | ||
pagination.href.previous = applyBaseToUrl(pagination.href.previous, pathPrefix, {pathPrefix}); | ||
} | ||
if (pagination.href.next) { | ||
pagination.href.next = applyBaseToUrl(pagination.href.next, pathPrefix, {pathPrefix}); | ||
} | ||
return pagination; | ||
}, | ||
related: ({related, pathPrefix}) => { | ||
if (!related) { | ||
return related; | ||
} | ||
|
||
related.sections = mapRelatedSections(related.sections ?? [related], pathPrefix); | ||
|
||
return related; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters