Skip to content

Commit

Permalink
Control whitespace in component examples
Browse files Browse the repository at this point in the history
  • Loading branch information
paulrobertlloyd committed Dec 18, 2023
1 parent f106575 commit 2e27f19
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 14 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.njk]
insert_final_newline = false
3 changes: 1 addition & 2 deletions docs/examples/autocomplete.njk
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ layout: example.njk
title: Autocomplete example
---
{% from "x-govuk/components/autocomplete/macro.njk" import xGovukAutocomplete %}

{{ xGovukAutocomplete({
id: "country",
name: "country",
Expand Down Expand Up @@ -43,4 +42,4 @@ title: Autocomplete example
{ text: "Spain" },
{ text: "Sweden" }
]
}) }}
}) }}
3 changes: 1 addition & 2 deletions docs/examples/masthead.njk
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -25,4 +24,4 @@ title: Masthead example
startButton: {
href: "/get-started/"
}
}) }}
}) }}
9 changes: 4 additions & 5 deletions docs/examples/primary-navigation.njk
Original file line number Diff line number Diff line change
Expand Up @@ -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: "#"
}]
}) }}
}) }}
3 changes: 1 addition & 2 deletions docs/examples/related-navigation.njk
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ layout: example.njk
title: Related navigation example
---
{% from "x-govuk/components/related-navigation/macro.njk" import xGovukRelatedNavigation %}

{{ xGovukRelatedNavigation({
sections: [{
items: [{
Expand All @@ -22,4 +21,4 @@ title: Related navigation example
}]
}]
}]
}) }}
}) }}
3 changes: 1 addition & 2 deletions docs/examples/sub-navigation.njk
Original file line number Diff line number Diff line change
Expand Up @@ -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: [{
Expand All @@ -23,4 +22,4 @@ title: Sub navigation example
href: "/contact/telephone"
}]
}]
}) }}
}) }}
2 changes: 1 addition & 1 deletion eleventy.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
Expand Down

0 comments on commit 2e27f19

Please sign in to comment.