-
Notifications
You must be signed in to change notification settings - Fork 1
/
.eleventy.js
60 lines (54 loc) · 1.99 KB
/
.eleventy.js
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
const govukEleventyPlugin = require("@x-govuk/govuk-eleventy-plugin");
const tagFilter = require("./plugins/tagFilter");
const hashFilter = require("./plugins/hashFilter");
const getContentsAfterTags = require("./plugins/getContentsAfterTags");
const fs = require("fs");
const util = require("util");
function gitRev() {
const rev = fs.readFileSync(".git/HEAD").toString().trim();
if (rev.indexOf(":") === -1) return rev;
else
return fs
.readFileSync(".git/" + rev.substring(5))
.toString()
.trim();
}
function gitSHA() {
return gitRev().slice(0, 8);
}
module.exports = function (eleventyConfig) {
eleventyConfig.addPlugin(govukEleventyPlugin, {
header: {
productName: `Cloud Maturity Model <strong class="govuk-tag govuk-phase-banner__content__tag">Alpha</strong>`,
},
footer: {
meta: {
text: `Page built from <a href="https://github.com/co-cddo/cloudmaturity/commit/${gitRev()}">${gitSHA()}</a> at ${new Date().toISOString()}`,
},
},
});
eleventyConfig.addFilter("tagfilter", tagFilter);
eleventyConfig.addFilter("hash", hashFilter);
eleventyConfig.addFilter("getContentsAfterTags", getContentsAfterTags);
eleventyConfig.addFilter("console", function (value) {
const str = util.inspect(value);
return `<code style="white-space: pre-wrap;">${unescape(str)}</code>;`;
});
eleventyConfig.addPassthroughCopy("./src/assets");
eleventyConfig.addPassthroughCopy("./src/robots.txt");
eleventyConfig.addPassthroughCopy({
"./node_modules/govuk-frontend/dist/govuk/assets/images": "./assets/images",
"./node_modules/govuk-frontend/dist/govuk/assets/fonts": "./assets/fonts",
"./node_modules/chaarts/dist/chaarts.min.css": "./assets/chaarts.min.css",
});
return {
pathPrefix: process.env.PATH_PREFIX || "/",
dataTemplateEngine: "njk",
htmlTemplateEngine: "njk",
markdownTemplateEngine: "njk",
dir: {
input: "./src",
layouts: "../node_modules/@x-govuk/govuk-eleventy-plugin/layouts",
},
};
};