@x-govuk/nhsuk-eleventy-plugin 1.0.2 → 1.0.4

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/nhsuk-eleventy-plugin",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Write documentation using Markdown and publish it using NHS.UK styles",
5
5
  "keywords": [
6
6
  "nhsuk",
@@ -28,13 +28,13 @@
28
28
  "url": "git+https://github.com/x-govuk/nhsuk-eleventy-plugin.git"
29
29
  },
30
30
  "scripts": {
31
- "prebuild": "rimraf _site",
32
- "postbuild": "npm run build:example",
33
31
  "build": "eleventy",
32
+ "postbuild": "npm run build:example",
34
33
  "build:example": "eleventy --config=example.config.js",
35
34
  "predev": "npm run build",
36
35
  "dev": "eleventy --serve --watch",
37
36
  "dev:example": "eleventy --config=example.config.js --serve --watch",
37
+ "prestart": "npm run build",
38
38
  "start": "eleventy --serve",
39
39
  "lint:prettier": "prettier . --check",
40
40
  "lint:prettier:fix": "prettier . --write",
@@ -57,7 +57,7 @@
57
57
  "@rollup/plugin-commonjs": "^28.0.0",
58
58
  "@rollup/plugin-node-resolve": "^16.0.0",
59
59
  "@rollup/plugin-terser": "^0.4.4",
60
- "@x-govuk/govuk-eleventy-plugin": "^8.0.0",
60
+ "@x-govuk/govuk-eleventy-plugin": "^8.0.4",
61
61
  "accessible-autocomplete": "^3.0.1",
62
62
  "deepmerge": "^4.2.2",
63
63
  "markdown-it-abbr": "^2.0.0",
@@ -73,9 +73,8 @@
73
73
  "markdown-it-mark": "^4.0.0",
74
74
  "markdown-it-sub": "^2.0.0",
75
75
  "markdown-it-sup": "^2.0.0",
76
- "markdown-it-table-of-contents": "^0.9.0",
76
+ "markdown-it-table-of-contents": "^1.0.0",
77
77
  "nhsuk-frontend": "^10.0.0",
78
- "rimraf": "^6.0.0",
79
78
  "rollup": "^4.1.0",
80
79
  "sass": "^1.45.1"
81
80
  },
@@ -2,11 +2,11 @@
2
2
  {% set size = params.size or "xl" %}
3
3
  {% if params.caption %}
4
4
  <span class="nhsuk-caption-{{ size }}">
5
- {{- params.caption -}}
5
+ {{- params.caption | smart -}}
6
6
  </span>
7
7
  {% endif %}
8
8
  <h{{level}} class="nhsuk-heading-{{ size }}{%- if params.classes %} {{ params.classes }}{% endif %}">
9
- {{- params.title | safe -}}
9
+ {{- params.title | smart | safe -}}
10
10
  </h{{level}}>
11
11
  {% if params.description -%}
12
12
  <p class="{{ "nhsuk-lede-text" if level == 1 else "nhsuk-body nhsuk-u-reading-width" }}">
@@ -8,10 +8,15 @@ import deepmerge from 'deepmerge'
8
8
  const defaults = {
9
9
  homeKey: 'Home',
10
10
  icons: {
11
- mask: '/assets/favicons/favicon.svg',
12
- shortcut: '/assets/favicons/favicon.ico',
13
- touch: '/assets/favicons/apple-touch-icon.png'
11
+ mask: '/assets/images/nhsuk-icon-mask.svg',
12
+ shortcut: '/assets/images/favicon.ico',
13
+ touch: '/assets/images/nhsuk-icon-180.png'
14
14
  },
15
+ markdown: {
16
+ headingPermalinks: false,
17
+ headingsStartWith: 'xl'
18
+ },
19
+ opengraphImageUrl: '/assets/images/nhsuk-opengraph-image.png',
15
20
  stylesheets: [],
16
21
  titleSuffix: 'NHS',
17
22
  url: false,
@@ -45,5 +50,17 @@ export function defaultPluginOptions(options, pathPrefix) {
45
50
  options._feedPath = options.templates?.feed?.permalink || '/feed.xml'
46
51
  }
47
52
 
53
+ // Show message if using deprecated headingPermalinks option
54
+ if (options?.headingPermalinks) {
55
+ console.warn(
56
+ 'The `headingPermalinks` option is deprecated and will be removed in a future version. Use `markdown.headingPermalinks` option instead.'
57
+ )
58
+
59
+ options.markdown = {
60
+ headingPermalinks: options.headingPermalinks,
61
+ ...options.markdown
62
+ }
63
+ }
64
+
48
65
  return deepmerge(defaults, options)
49
66
  }
@@ -13,6 +13,7 @@ export {
13
13
  noOrphans,
14
14
  pretty,
15
15
  sliceFromCollection,
16
+ sortCollection,
16
17
  smart,
17
18
  tokenize
18
19
  } from '@x-govuk/govuk-eleventy-plugin/filters'
@@ -3,6 +3,7 @@ import {
3
3
  markdown,
4
4
  nhsukDate,
5
5
  sliceFromCollection,
6
+ sortCollection,
6
7
  smart
7
8
  } from './index.js'
8
9
 
@@ -50,6 +51,8 @@ function getDescriptionHtml(item) {
50
51
  */
51
52
  export function itemsFromCollection(array, n) {
52
53
  if (isCollectionData(array)) {
54
+ array = sortCollection(array, true)
55
+
53
56
  array = array.map((item) => {
54
57
  return {
55
58
  href: item.url,
package/src/index.js CHANGED
@@ -45,7 +45,7 @@ export async function nhsukEleventyPlugin(eleventyConfig, pluginOptions = {}) {
45
45
  const options = defaultPluginOptions(pluginOptions, pathPrefix)
46
46
 
47
47
  // Libraries
48
- eleventyConfig.setLibrary('md', md(options))
48
+ eleventyConfig.setLibrary('md', md(options.markdown))
49
49
  eleventyConfig.setLibrary('njk', nunjucksConfig(eleventyConfig))
50
50
 
51
51
  // Collections
@@ -19,7 +19,7 @@
19
19
  {% endif %}
20
20
  {{ collections.sitemap | eleventyNavigation(item.key) | eleventyNavigationToHtml({
21
21
  listElement: "ol"
22
- }) | safe }}
22
+ }) | smart | safe }}
23
23
  </nav>
24
24
  {% endfor %}
25
25
  {% endblock %}
@@ -26,27 +26,28 @@ import { tableRules } from './markdown-it/table.js'
26
26
  * Configure markdown-it
27
27
  *
28
28
  * @see {@link https://markdown-it.github.io/markdown-it/}
29
- * @param {object} [options] - Plugin options
29
+ * @param {object} [markdownOptions] - Plugin Markdown options
30
30
  * @returns {Function} markdown-it instance
31
31
  */
32
- export function md(options = {}) {
32
+ export function md(markdownOptions = {}) {
33
33
  const opts = {
34
34
  breaks: true,
35
35
  highlight,
36
36
  html: true,
37
37
  linkify: false,
38
- typographer: true
38
+ typographer: true,
39
+ ...markdownOptions
39
40
  }
40
41
 
41
42
  const md = new MarkdownIt(opts)
42
43
  .use(markdownItGovuk, {
43
44
  brand: 'nhsuk',
44
45
  calvert: true,
45
- headingsStartWith: 'xl'
46
+ headingsStartWith: markdownOptions.headingsStartWith
46
47
  })
47
48
  .use(markdownItAbbr)
48
49
  .use(markdownItAnchor, {
49
- permalink: options.headingPermalinks
50
+ permalink: markdownOptions.headingPermalinks
50
51
  ? markdownItAnchor.permalink.headerLink({
51
52
  class: 'app-link--heading',
52
53
  safariReaderFix: true