@x-govuk/govuk-eleventy-plugin 8.2.0 → 8.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@x-govuk/govuk-eleventy-plugin",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.3.1",
|
|
4
4
|
"description": "Write documentation using Markdown and publish it using GOV.UK styles",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"govuk",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"devDependencies": {
|
|
83
83
|
"@x-govuk/eslint-config": "^0.0.1",
|
|
84
84
|
"@x-govuk/govuk-eleventy-plugin": "file:./",
|
|
85
|
-
"np": "^
|
|
85
|
+
"np": "^11.0.0",
|
|
86
86
|
"prettier": "^3.1.0",
|
|
87
87
|
"stylelint": "^16.0.0",
|
|
88
88
|
"stylelint-config-gds": "^2.0.0",
|
package/src/data/options.js
CHANGED
|
@@ -27,6 +27,7 @@ const defaults = {
|
|
|
27
27
|
govspeak: true
|
|
28
28
|
},
|
|
29
29
|
opengraphImageUrl: '/assets/rebrand/images/govuk-opengraph-image.png',
|
|
30
|
+
scripts: [],
|
|
30
31
|
stylesheets: [],
|
|
31
32
|
titleSuffix: 'GOV.UK',
|
|
32
33
|
url: false,
|
|
@@ -61,5 +62,10 @@ export function defaultPluginOptions(options, pathPrefix) {
|
|
|
61
62
|
}
|
|
62
63
|
}
|
|
63
64
|
|
|
65
|
+
// Default phaseBanner classes to govuk-width-container for proper width
|
|
66
|
+
if (options.header?.phaseBanner && !options.header.phaseBanner.classes) {
|
|
67
|
+
options.header.phaseBanner.classes = 'govuk-width-container'
|
|
68
|
+
}
|
|
69
|
+
|
|
64
70
|
return deepmerge(defaults, options)
|
|
65
71
|
}
|
|
@@ -22,7 +22,8 @@ export async function generateAssets(dir, options) {
|
|
|
22
22
|
let inputFile = await fs.readFile(inputFilePath)
|
|
23
23
|
|
|
24
24
|
// Update asset path to use configured path prefix
|
|
25
|
-
|
|
25
|
+
// Use POSIX forward slash path separator for generated SCSS
|
|
26
|
+
const assetPath = path.posix.join(options.pathPrefix, '/assets/')
|
|
26
27
|
inputFile = inputFile
|
|
27
28
|
.toString()
|
|
28
29
|
.replace(
|
|
@@ -46,22 +47,25 @@ export async function generateAssets(dir, options) {
|
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
// Bundle JavaScript
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
50
|
+
// Ignored if custom scripts are used
|
|
51
|
+
if (options.scripts.length === 0) {
|
|
52
|
+
try {
|
|
53
|
+
const jsFile = `${dir.output}/assets/application.js`
|
|
54
|
+
const bundle = await rollup({
|
|
55
|
+
input: path.join(import.meta.dirname, '../application.js'),
|
|
56
|
+
context: 'window',
|
|
57
|
+
plugins: [
|
|
58
|
+
nodeResolve(),
|
|
59
|
+
commonJs(),
|
|
60
|
+
terser({ format: { comments: false } })
|
|
61
|
+
]
|
|
62
|
+
})
|
|
60
63
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
const { output } = await bundle.generate({ format: 'es' })
|
|
65
|
+
const { code } = output[0]
|
|
66
|
+
fs.writeFile(jsFile, code)
|
|
67
|
+
} catch (error) {
|
|
68
|
+
console.error(error)
|
|
69
|
+
}
|
|
66
70
|
}
|
|
67
71
|
}
|
package/src/layouts/base.njk
CHANGED
|
@@ -43,7 +43,11 @@
|
|
|
43
43
|
{% endblock %}
|
|
44
44
|
|
|
45
45
|
{% block head %}
|
|
46
|
-
|
|
46
|
+
{% for script in options.scripts %}
|
|
47
|
+
<script src="{{ script | canonicalUrl }}" type="module"></script>
|
|
48
|
+
{% else %}
|
|
49
|
+
<script src="{{ "/assets/application.js" | canonicalUrl }}" type="module"></script>
|
|
50
|
+
{% endfor %}
|
|
47
51
|
|
|
48
52
|
{% for stylesheet in options.stylesheets %}
|
|
49
53
|
<link rel="stylesheet" href="{{ stylesheet | canonicalUrl }}">
|