-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy patheleventy.config.js
More file actions
196 lines (181 loc) · 5.24 KB
/
eleventy.config.js
File metadata and controls
196 lines (181 loc) · 5.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
import fs from 'node:fs/promises'
import { nhsukEleventyPlugin } from '@x-govuk/nhsuk-eleventy-plugin'
const serviceName = 'Digital prevention services design history'
export default function (eleventyConfig) {
eleventyConfig.addPlugin(nhsukEleventyPlugin, {
stylesheets: ['/styles/application.css'],
templates: {
feed: {
title: serviceName
},
tags: true,
searchIndex: true
},
header: {
service: {
text: serviceName,
href: '/'
}
},
footer: {
meta: {
items: [
{
text: 'Sitemap',
href: '/sitemap'
},
{
text: 'All posts',
href: '/all'
},
{
text: 'Subscribe to feed',
href: '/feed.xml'
},
{
text: 'Tags',
href: '/tags'
}
],
text: 'All data and personal information shown in prototypes are fictional and for demonstration purposes only.'
}
},
url:
process.env.GITHUB_ACTIONS &&
'https://design-history.prevention-services.nhs.uk/'
})
// Images and PDFs
eleventyConfig.addPassthroughCopy('./app/**/*.ai')
eleventyConfig.addPassthroughCopy('./app/**/*.gif')
eleventyConfig.addPassthroughCopy('./app/**/*.jpg')
eleventyConfig.addPassthroughCopy('./app/**/*.jpeg')
eleventyConfig.addPassthroughCopy('./app/**/*.png')
eleventyConfig.addPassthroughCopy('./app/**/*.pdf')
eleventyConfig.addPassthroughCopy('./app/**/*.sketch')
// Nunjucks filters
eleventyConfig.addFilter('push', (array, item) => {
const newArray = [...array]
newArray.push(item)
return newArray
})
// Service area collections
for (const area of [
'screening',
'vaccinations',
'personalised-prevention',
'digital-best-start',
'managing-my-health'
]) {
eleventyConfig.addCollection(`${area}-area`, (collection) => {
return collection
.getAll()
.filter(({ data }) => data?.area === area && !data?.pathway)
.sort((a, b) => {
// Promoted collection in an area should be shown first
if (a.data.promote) return -1
if (b.data.promote) return 1
return a.data.title.localeCompare(b.data.title)
})
})
}
// Pathway collections
// Breast screening pathway - aggregates posts from all breast screening teams
eleventyConfig.addCollection('pathway-breast-screening', (collection) => {
return collection
.getFilteredByGlob([
'app/manage-breast-screening/**/*.md',
'app/breast-screening-pathway/**/*.md',
'app/breast-screening-reporting/**/*.md',
'app/explore-team/**/*.md',
'app/select/**/*.md',
'app/screening-invite/**/*.md'
])
.sort((a, b) => a.date - b.date)
})
// Breast screening teams - the team index pages for this pathway
eleventyConfig.addCollection(
'pathway-breast-screening-teams',
(collection) => {
return collection
.getAll()
.filter(
({ data }) =>
data?.pathway === 'breast-screening' &&
data?.layout === 'collection'
)
.sort((a, b) => a.data.title.localeCompare(b.data.title))
}
)
// Service collections
for (const service of [
'digital-prevention-services',
// Screening service collections
'screening',
'bowel-screening',
'breast-screening-reporting',
'breast-screening-pathway',
'select',
'diabetic-eye-screening',
'explore-team',
'manage-breast-screening',
'manage-your-screening',
'hpv-self-testing',
'screening-invite',
// Vaccination service collections
'vaccinations',
'book-a-vaccination',
'manage-vaccinations-in-schools',
'manage-your-appointments',
'record-a-vaccination',
'select-people-for-invitation',
'vaccinations-in-the-app',
// Personalised prevention service collections
'ai-health-coach',
'personalised-prevention',
'lung-health-check',
'nhs-health-check-online',
'personalised-prevention-platform',
'smoking-cessation',
'talking-therapies',
// Digital best start
'age-related-messaging',
'check-childrens-vaccination-history',
'antenatal-screening',
// Managing my health
'cohorting-as-a-service'
]) {
eleventyConfig.addCollection(service, (collection) => {
return collection.getFilteredByGlob(`app/${service}/**/*.md`)
})
}
// Guide collection
eleventyConfig.addCollection('guide', (collection) => {
return collection.getFilteredByGlob(`app/guide/**/*.md`)
})
// Posts collection (all posts across all services)
eleventyConfig.addCollection('post', (collection) => {
return collection
.getAllSorted()
.filter((item) => item.data?.layout === 'post')
})
// Reset contents of output directory before each build
eleventyConfig.on('eleventy.before', async ({ directories, runMode }) => {
if (runMode === 'build') {
await fs.rm(directories.output, {
force: true,
recursive: true
})
}
})
// Config
return {
dataTemplateEngine: 'njk',
htmlTemplateEngine: 'njk',
markdownTemplateEngine: 'njk',
dir: {
input: 'app',
includes: '_components',
layouts: '_layouts'
}
}
}