From 2e27f19e20367267b958e0f76190bb4604355797 Mon Sep 17 00:00:00 2001 From: Paul Robert Lloyd Date: Mon, 18 Dec 2023 22:40:48 +0000 Subject: [PATCH] Control whitespace in component examples --- .editorconfig | 3 +++ docs/examples/autocomplete.njk | 3 +-- docs/examples/masthead.njk | 3 +-- docs/examples/primary-navigation.njk | 9 ++++----- docs/examples/related-navigation.njk | 3 +-- docs/examples/sub-navigation.njk | 3 +-- eleventy.config.js | 2 +- 7 files changed, 12 insertions(+), 14 deletions(-) diff --git a/.editorconfig b/.editorconfig index 50ff45f..d80d1bc 100644 --- a/.editorconfig +++ b/.editorconfig @@ -8,3 +8,6 @@ charset = utf-8 end_of_line = lf insert_final_newline = true trim_trailing_whitespace = true + +[*.njk] +insert_final_newline = false diff --git a/docs/examples/autocomplete.njk b/docs/examples/autocomplete.njk index fb6b07e..02b4308 100644 --- a/docs/examples/autocomplete.njk +++ b/docs/examples/autocomplete.njk @@ -4,7 +4,6 @@ layout: example.njk title: Autocomplete example --- {% from "x-govuk/components/autocomplete/macro.njk" import xGovukAutocomplete %} - {{ xGovukAutocomplete({ id: "country", name: "country", @@ -43,4 +42,4 @@ title: Autocomplete example { text: "Spain" }, { text: "Sweden" } ] -}) }} +}) }} \ No newline at end of file diff --git a/docs/examples/masthead.njk b/docs/examples/masthead.njk index 88bb916..f77cd75 100644 --- a/docs/examples/masthead.njk +++ b/docs/examples/masthead.njk @@ -4,7 +4,6 @@ layout: example.njk title: Masthead example --- {% from "x-govuk/components/masthead/macro.njk" import xGovukMasthead %} - {{ xGovukMasthead({ classes: "x-govuk-masthead--large", phaseBanner: { @@ -25,4 +24,4 @@ title: Masthead example startButton: { href: "/get-started/" } -}) }} +}) }} \ No newline at end of file diff --git a/docs/examples/primary-navigation.njk b/docs/examples/primary-navigation.njk index 71a622c..9534c98 100644 --- a/docs/examples/primary-navigation.njk +++ b/docs/examples/primary-navigation.njk @@ -4,24 +4,23 @@ layout: example.njk title: Primary navigation --- {% from "x-govuk/components/primary-navigation/macro.njk" import xGovukPrimaryNavigation %} - {{ xGovukPrimaryNavigation({ visuallyHiddenTitle: "Navigation", items: [{ text: "Home", href: "#", current: true - },{ + }, { text: "Support", href: "#" - },{ + }, { text: "Features", href: "#" - },{ + }, { text: "Pricing", href: "#" }, { text: "Contact us", href: "#" }] -}) }} +}) }} \ No newline at end of file diff --git a/docs/examples/related-navigation.njk b/docs/examples/related-navigation.njk index a7dcc45..62cc17c 100644 --- a/docs/examples/related-navigation.njk +++ b/docs/examples/related-navigation.njk @@ -4,7 +4,6 @@ layout: example.njk title: Related navigation example --- {% from "x-govuk/components/related-navigation/macro.njk" import xGovukRelatedNavigation %} - {{ xGovukRelatedNavigation({ sections: [{ items: [{ @@ -22,4 +21,4 @@ title: Related navigation example }] }] }] -}) }} +}) }} \ No newline at end of file diff --git a/docs/examples/sub-navigation.njk b/docs/examples/sub-navigation.njk index 904a173..a410be1 100644 --- a/docs/examples/sub-navigation.njk +++ b/docs/examples/sub-navigation.njk @@ -4,7 +4,6 @@ layout: example.njk title: Sub navigation example --- {% from "x-govuk/components/sub-navigation/macro.njk" import xGovukSubNavigation %} - {{ xGovukSubNavigation({ visuallyHiddenTitle: "Navigation", items: [{ @@ -23,4 +22,4 @@ title: Sub navigation example href: "/contact/telephone" }] }] -}) }} +}) }} \ No newline at end of file diff --git a/eleventy.config.js b/eleventy.config.js index 0a8a0d7..f367215 100644 --- a/eleventy.config.js +++ b/eleventy.config.js @@ -59,7 +59,7 @@ module.exports = function (eleventyConfig) { const { content } = matter(componentFile) // Remove `{% from "..." import ... %}` line as this is not needed by users - const nunjucksCode = content.replace(/{%\sfrom\s[^\n]+\n\n/, '') + const nunjucksCode = content.replaceAll(/{%\sfrom\s[^\n]+\n/g, '') return nunjucksCode })