From c061f9214724cbaf3bdfe4a3a36764afaa2c73b8 Mon Sep 17 00:00:00 2001 From: Keith Kennedy Date: Fri, 3 Nov 2023 14:02:06 +0000 Subject: [PATCH 1/3] Added related links for writing a principle/standard to the respective principle/standard listing page --- docs/principles.md | 6 ++++++ docs/standards.md | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/docs/principles.md b/docs/principles.md index 3a8f6a43..d710e00f 100644 --- a/docs/principles.md +++ b/docs/principles.md @@ -8,4 +8,10 @@ paginationHeading: false pagination: data: collections.getAllPrinciplesOrderedByTitle size: 10 +related: + sections: + - title: Related links + items: + - text: Writing a principle + href: /standards/writing-a-principle/ --- diff --git a/docs/standards.md b/docs/standards.md index 3d13e51a..956dff53 100644 --- a/docs/standards.md +++ b/docs/standards.md @@ -8,4 +8,10 @@ paginationHeading: false pagination: data: collections.getAllStandardsOrderedByTitle size: 10 +related: + sections: + - title: Related links + items: + - text: Writing a standard + href: /standards/writing-a-standard/ --- From 9527809a01c8d9d6b5235807b03417ed42c9897a Mon Sep 17 00:00:00 2001 From: Keith Kennedy <133027753+keithkennedyHO@users.noreply.github.com> Date: Tue, 7 Nov 2023 11:34:39 +0000 Subject: [PATCH 2/3] 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 --- .eleventy.js | 28 +++++--------------- .github/workflows/e2e-tests-on-pr.yml | 5 +--- _data/eleventyComputed.js | 38 --------------------------- _includes/layouts/collection.njk | 2 +- _includes/layouts/tags.njk | 10 +------ cypress/e2e/spec.cy.js | 4 +-- 6 files changed, 11 insertions(+), 76 deletions(-) diff --git a/.eleventy.js b/.eleventy.js index f44afb8c..114be522 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -2,8 +2,6 @@ const govukEleventyPlugin = require('@x-govuk/govuk-eleventy-plugin') const { DateTime } = require("luxon"); module.exports = function(eleventyConfig) { - // Set custom variable to decide the path prefix as it is used in a couple of places. - const _customPathPrefix = process.env.PATH_PREFIX ?? ''; const _siteRoot = process.env.SITE_ROOT ?? 'http://localhost/'; // Pass assets through to final build directory eleventyConfig.addPassthroughCopy({ "docs/assets/logos": "assets/logos"}); @@ -19,7 +17,7 @@ module.exports = function(eleventyConfig) { opengraphImageUrl: '/assets/logos/ho-opengraph-image.png', homeKey: 'Home', header: { - organisationLogo: 'Home Office Logo', + organisationLogo: 'Home Office Logo', organisationName: 'Home Office', productName: 'Engineering Guidance and Standards', search: { @@ -35,15 +33,15 @@ module.exports = function(eleventyConfig) { meta: { items: [ { - href: _customPathPrefix + '/about/', + href: '/about/', text: 'About' }, { - href: _customPathPrefix + '/cookies/', + href: '/cookies/', text: 'Cookies' }, { - href: _customPathPrefix + '/accessibility-statement/', + href: '/accessibility-statement/', text: 'Accessibility' }, { @@ -65,18 +63,6 @@ module.exports = function(eleventyConfig) { md.use(require('./lib/markdown/dl-as-govuk-summary-list')); eleventyConfig.setLibrary('md', md); - }) - - eleventyConfig.addFilter("itemsFromPaginationWithPathPrefix", (pagination) => { - const items = [] - pagination.pages.forEach((item, index) => { - items.push({ - current: index === pagination.pageNumber, - number: index + 1, - href: _customPathPrefix + pagination.hrefs[index] - }) - }) - return items; }); eleventyConfig.addFilter("postDate", (dateObj) => { @@ -142,11 +128,10 @@ module.exports = function(eleventyConfig) { tag: { text: "Alpha" }, - html: 'This is a new service – your feedback (opens in a new tab) will help us to improve it.' + html: 'This is a new service – your feedback (opens in a new tab) will help us to improve it.' } }); - eleventyConfig.addGlobalData('pathPrefix', _customPathPrefix); eleventyConfig.addGlobalData('siteRoot', _siteRoot); return { @@ -158,7 +143,6 @@ module.exports = function(eleventyConfig) { layouts: '../_includes/layouts', includes: '../_includes', input: 'docs' - }, - pathPrefix: _customPathPrefix + } } }; diff --git a/.github/workflows/e2e-tests-on-pr.yml b/.github/workflows/e2e-tests-on-pr.yml index 9ad95d1f..8e4e1919 100644 --- a/.github/workflows/e2e-tests-on-pr.yml +++ b/.github/workflows/e2e-tests-on-pr.yml @@ -9,7 +9,6 @@ on: env: TEST_URL: localhost TEST_PORT: 8080 - TEST_PATH_PREFIX: '/test/' jobs: e2e-test: @@ -29,10 +28,8 @@ jobs: browser: chrome build: npm run build start: npm run serve -- --port ${{ env.TEST_PORT }} - wait-on: 'http://${{ env.TEST_URL }}:${{ env.TEST_PORT }}${{ env.TEST_PATH_PREFIX }}' + wait-on: 'http://${{ env.TEST_URL }}:${{ env.TEST_PORT }}' config: 'video=false,screenshotOnRunFailure=false' env: CYPRESS_TEST_URL: ${{ env.TEST_URL }} CYPRESS_TEST_PORT: ${{ env.TEST_PORT }} - CYPRESS_TEST_PATH_PREFIX: ${{ env.TEST_PATH_PREFIX }} - PATH_PREFIX: ${{ env.TEST_PATH_PREFIX }} diff --git a/_data/eleventyComputed.js b/_data/eleventyComputed.js index 109532a3..1501828e 100644 --- a/_data/eleventyComputed.js +++ b/_data/eleventyComputed.js @@ -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; } } diff --git a/_includes/layouts/collection.njk b/_includes/layouts/collection.njk index aab2d6a5..332204e4 100644 --- a/_includes/layouts/collection.njk +++ b/_includes/layouts/collection.njk @@ -50,7 +50,7 @@ next: { href: pagination.href.next }, - items: pagination | itemsFromPaginationWithPathPrefix + items: pagination | itemsFromPagination }) if pagination.pages.length > 1 }} diff --git a/_includes/layouts/tags.njk b/_includes/layouts/tags.njk index b2c6ac8a..5d7a0689 100644 --- a/_includes/layouts/tags.njk +++ b/_includes/layouts/tags.njk @@ -22,15 +22,7 @@