From 50224c3aec0c3931c0172293622e1d7bd9cad60b Mon Sep 17 00:00:00 2001 From: Frankie Roberto Date: Tue, 23 Jul 2024 19:26:05 +0100 Subject: [PATCH] Add `titleSuffix` as future replacement for `header.organisationName` option (#298) Adds `titleSuffix` option to replace the undocumented `header.organisationName` option as this value is now only used in the document title. --------- Co-authored-by: Paul Robert Lloyd --- docs/options.md | 5 +++++ eleventy.config.js | 2 +- layouts/base.njk | 4 +++- lib/data/options.js | 3 ++- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/docs/options.md b/docs/options.md index 89bd087a..0291f5f1 100644 --- a/docs/options.md +++ b/docs/options.md @@ -102,6 +102,11 @@ module.exports = function(eleventyConfig) { { text: "string" }, { text: "Browser theme colour. Must be a hex value, i.e. `#0b0c0c`" | markdown } ], + [ + { text: "titleSuffix" }, + { text: "string" }, + { text: "Value to show at the end of the document title (default is `GOV.UK`)." | markdown } + ], [ { text: "url" }, { text: "string" }, diff --git a/eleventy.config.js b/eleventy.config.js index 5067dbb5..8468800f 100644 --- a/eleventy.config.js +++ b/eleventy.config.js @@ -20,6 +20,7 @@ module.exports = function (eleventyConfig) { url: 'https://x-govuk.github.io/#projects', name: 'X-GOVUK projects' }, + titleSuffix: 'X-GOVUK', url: process.env.GITHUB_ACTIONS && 'https://x-govuk.github.io/govuk-eleventy-plugin/', @@ -27,7 +28,6 @@ module.exports = function (eleventyConfig) { header: { logotype: 'x-govuk', productName: 'Eleventy Plugin', - organisationName: 'X-GOVUK', search: { indexPath: '/search.json', sitemapPath: '/sitemap' diff --git a/layouts/base.njk b/layouts/base.njk index 447179c9..3d4a21db 100644 --- a/layouts/base.njk +++ b/layouts/base.njk @@ -61,7 +61,9 @@ {{- title if title -}} {{- " (page " + pageNumber + " of " + pageCount + ")" if pageCount > 1 -}} {{- " - " + options.header.productName if options.header.productName -}} - {{- " - " + options.header.organisationName -}} + {%- if options.titleSuffix or options.header.organisationName %} + {{- " - " + (options.titleSuffix if options.titleSuffix else options.header.organisationName) -}} + {%- endif %} {% endblock %} {% block header %} diff --git a/lib/data/options.js b/lib/data/options.js index 96646cb8..7a8ba669 100644 --- a/lib/data/options.js +++ b/lib/data/options.js @@ -17,10 +17,11 @@ const defaultOptions = { copyright: 'crown', // Crown copyright licence: 'ogl' // Open Government Licence v3.0 }, + titleSuffix: 'GOV.UK', header: { homepageUrl: '/', organisationLogo: 'crown', - organisationName: 'GOV.UK', + organisationName: 'GOV.UK', // Deprecated: will be removed in v7.0 productName: false }, homeKey: 'Home',