Skip to content

Commit

Permalink
Allow titleSuffix option to accept boolean
Browse files Browse the repository at this point in the history
  • Loading branch information
paulrobertlloyd committed Jul 23, 2024
1 parent e8260a7 commit aa275e0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion docs/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ module.exports = function(eleventyConfig) {
],
[
{ text: "titleSuffix" },
{ text: "string" },
{ text: "string or boolean" },
{ text: "Value to show at the end of the document title (default is `GOV.UK`)." | markdown }
],
[
Expand Down
4 changes: 1 addition & 3 deletions layouts/base.njk
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@
{{- title if title -}}
{{- " (page " + pageNumber + " of " + pageCount + ")" if pageCount > 1 -}}
{{- " - " + options.header.productName if options.header.productName -}}
{%- if options.titleSuffix or options.header.organisationName %}
{{- " - " + (options.titleSuffix if options.titleSuffix else options.header.organisationName) -}}
{%- endif %}
{{- " - " + options.titleSuffix if options.titleSuffix -}}
{% endblock %}

{% block header %}
Expand Down
15 changes: 12 additions & 3 deletions lib/data/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,31 @@ const defaultOptions = {
copyright: 'crown', // Crown copyright
licence: 'ogl' // Open Government Licence v3.0
},
titleSuffix: 'GOV.UK',
header: {
homepageUrl: '/',
organisationLogo: 'crown',
organisationName: 'GOV.UK', // Deprecated: will be removed in v7.0
productName: false
},
homeKey: 'Home',
parentSite: false,
search: false,
stylesheets: [],
titleSuffix: 'GOV.UK',
url: false
}

module.exports = function (options, pathPrefix) {
options.pathPrefix = pathPrefix

// Support former `header.organisationName` option
// Deprecated: will be removed in v7.0
if (options.header?.organisationName) {
options.titleSuffix = options.header.organisationName
}

// Let `true` mean the default title suffix (`true` is rendered as a string)
if (options.titleSuffix === true) {
delete options.titleSuffix
}

return deepmerge(defaultOptions, options)
}

0 comments on commit aa275e0

Please sign in to comment.