@x-govuk/govuk-eleventy-plugin
Version:
Write documentation using Markdown and publish it using GOV.UK styles
72 lines (63 loc) • 1.9 kB
JavaScript
import deepmerge from 'deepmerge'
/**
* Default option values
*
* @see {@link https://govuk-eleventy-plugin.x-govuk.org/get-started/options/}
*/
const defaults = {
footer: {
copyright: 'crown', // Crown copyright
licence: 'ogl' // Open Government Licence v3.0
},
header: {
homepageUrl: '/',
productName: false
},
homeKey: 'Home',
icons: {
mask: '/assets/images/govuk-icon-mask.svg',
shortcut: '/assets/images/favicon.ico',
touch: '/assets/images/govuk-icon-180.png'
},
markdown: {
calvert: true,
headingPermalinks: false,
headingsStartWith: 'xl',
govspeak: true
},
opengraphImageUrl: '/assets/images/govuk-opengraph-image.png',
scripts: [],
stylesheets: [],
titleSuffix: 'GOV.UK',
url: false,
templates: {
error404: true,
sitemap: true
}
}
export function defaultPluginOptions(options, pathPrefix) {
options.pathPrefix = pathPrefix
// Let `true` mean the default title suffix (`true` is rendered as a string)
if (options.titleSuffix === true) {
delete options.titleSuffix
}
// Add _feedPath to enable feed to be linked to from page head
if (options.templates?.feed) {
options._feedPath = options.templates?.feed?.permalink || '/feed.xml'
}
// Show message if using deprecated headingPermalinks option
if (options?.headingPermalinks) {
console.warn(
'The `headingPermalinks` option is deprecated and will be removed in a future version. Use `markdown.headingPermalinks` option instead.'
)
options.markdown = {
headingPermalinks: options.headingPermalinks,
...options.markdown
}
}
// Default phaseBanner classes to govuk-width-container for proper width
if (options.header?.phaseBanner && !options.header.phaseBanner.classes) {
options.header.phaseBanner.classes = 'govuk-width-container'
}
return deepmerge(defaults, options)
}