Skip to content

Commit 472becb

Browse files
committed
Complete conversion into 11ty
1 parent 02cf699 commit 472becb

File tree

161 files changed

+18327
-2060
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

161 files changed

+18327
-2060
lines changed

.editorconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ root = true
55
charset = utf-8
66
indent_size = 2
77
indent_style = space
8-
insert_final_newline = false
9-
trim_trailing_whitespace = false
8+
insert_final_newline = true
9+
trim_trailing_whitespace = false

.eleventy.js

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
/*
2+
USEFUL LINKS:
3+
4+
https://github.com/11ty/eleventy/issues/812
5+
https://www.npmjs.com/package/@thedigitalman/eleventy-plugin-toc-a11y
6+
https://www.trysmudford.com/blog/encapsulated-11ty-components
7+
https://www.brycewray.com/posts/2022/09/shorter-shortcuts-nunjucks-macros-eleventy
8+
https://davidea.st/articles/11ty-tips-i-wish-i-knew-from-the-start
9+
https://dev.to/murtuzaalisurti/adding-custom-anchors-to-headings-in-markdown-eleventy-275o
10+
*/
11+
12+
const markdownIt = require('markdown-it');
13+
const markdownItAttrs = require('markdown-it-attrs');
14+
const markdownItAnchor = require('markdown-it-anchor');
15+
16+
17+
// Breadcrumb trail
18+
const eleventyNavigationPlugin = require('@11ty/eleventy-navigation');
19+
20+
21+
// Table of contents
22+
const eleventyPluginTOC = require('@thedigitalman/eleventy-plugin-toc-a11y');
23+
24+
25+
const markdownItOptions = {
26+
html: true,
27+
breaks: true,
28+
linkify: false
29+
};
30+
31+
32+
const markdownItAnchorOptions = {
33+
level: 2,
34+
tabIndex: false
35+
};
36+
37+
38+
module.exports = function (eleventyConfig) {
39+
40+
41+
eleventyConfig.setUseGitIgnore(false);
42+
43+
44+
// Copy GOV.UK fonts
45+
eleventyConfig.addPassthroughCopy({'node_modules/govuk-frontend/govuk/assets/fonts': 'assets/fonts'});
46+
47+
48+
// Copy MOD.UK assets
49+
eleventyConfig.addPassthroughCopy({'./src/assets/images': 'assets/images'});
50+
51+
52+
// Table of contents
53+
eleventyConfig.addPlugin(eleventyPluginTOC, {
54+
tags: ['h2'],
55+
wrapper: 'nav',
56+
wrapperClass: 'gem-c-contents-list',
57+
heading: true,
58+
headingClass: 'gem-c-contents-list__title',
59+
headingLevel: 'h2',
60+
headingText: 'Contents',
61+
listType: 'ol',
62+
listClass: 'gem-c-contents-list__list',
63+
listItemClass: 'gem-c-contents-list__list-item gem-c-contents-list__list-item--dashed',
64+
listItemAnchorClass: 'gem-c-contents-list__link govuk-link govuk-link--no-visited-state',
65+
});
66+
67+
68+
// Macros used in markdown files
69+
eleventyConfig.addCollection('everything', (collectionApi) => {
70+
const macroImport = `{%- from 'system/component.njk' import component -%}{%- from 'system/modukcomponent.njk' import modukcomponent -%}`
71+
let collMacros = collectionApi.getFilteredByGlob('src/**/*.md')
72+
collMacros.forEach((item) => {
73+
item.template.frontMatter.content = `${macroImport}\n${item.template.frontMatter.content}`
74+
})
75+
return collMacros
76+
});
77+
78+
79+
// Markdown configurations
80+
eleventyConfig.setLibrary('md', markdownIt(markdownItOptions).use(markdownItAnchor, markdownItAnchorOptions).use(markdownItAttrs));
81+
82+
83+
// Navigation
84+
eleventyConfig.addPlugin(eleventyNavigationPlugin);
85+
86+
87+
// Configurations
88+
return {
89+
dir: {
90+
input: 'src',
91+
output: 'public',
92+
includes: '_includes'
93+
},
94+
templateFormats: [ 'md', 'njk', 'html'],
95+
markdownTemplateEngine: 'njk',
96+
htmlTemplateEngine: 'njk',
97+
dataTemplateEngine: 'njk',
98+
};
99+
100+
101+
};
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Build and Deploy
2+
on: [push]
3+
permissions:
4+
contents: write
5+
jobs:
6+
build-and-deploy:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Checkout 🛎️
10+
uses: actions/checkout@v3
11+
12+
- name: Install and Build
13+
run: |
14+
npm ci
15+
npm run prod
16+
- name: Deploy 🚀
17+
uses: JamesIves/github-pages-deploy-action@v4
18+
with:
19+
branch: gh-pages
20+
folder: public
21+
clean: true

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ logs
1414
# Other
1515
.env
1616
.npm
17-
package-lock.json
1817
npm-debug.log
1918
*.cache
20-
.vscode
19+
.vscode

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1818
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
21+
SOFTWARE.

Procfile

Lines changed: 0 additions & 1 deletion
This file was deleted.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ Watch for changes to `CSS`, `JS`, `Images`, `Nunjucks`. Automatically update the
3131
npm run dev
3232
```
3333

34-
Visit: <a href="http://localhost:3000">http://localhost:3000</a>
34+
Visit: <a href="http://localhost:8080">http://localhost:8080</a>
3535

3636
## Build app for production
3737

3838
Render `CSS`, `JS`, `Images`, `Nunjucks`. Compress files and generates `HTML` pages, ready for production. It also performs a [W3C validation](https://validator.w3.org) on `HTML`, to ensure everything is valid.
3939

4040
```
4141
npm run prod
42-
```
42+
```

app.js

Lines changed: 0 additions & 151 deletions
This file was deleted.

app/config.js

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)