-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheleventy.js
More file actions
97 lines (80 loc) · 3.17 KB
/
eleventy.js
File metadata and controls
97 lines (80 loc) · 3.17 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
const { DateTime } = require('luxon');
const _ = require('lodash');
const Path = require('path');
const yaml = require("js-yaml");
const helper = require("@11ty/eleventy-upgrade-help");
const moment = require("moment");
const slugify = require("slugify");
const eleventyNavigationPlugin = require("@11ty/eleventy-navigation");
module.exports = function (config) {
config.addPlugin(eleventyNavigationPlugin);
// Add in tags, filters useful for Visual Framework installs
// (fractal's render tag, codeblock, markdown, etc)
// and common configuration
const vfEleventyExtension = require("@visual-framework/vf-extensions\/11ty");
config.addPlugin(helper);
config.addPlugin(vfEleventyExtension);
// BroswerSync options
config.setBrowserSyncConfig({ open: true });
// Filters
// https://www.11ty.io/docs/filters/
// -----
// {{ "myContent" | sampleFilter }}
// config.addFilter("sampleFilter", function(value) {
// return 'ddd' + value;
// });
// Add any utiliuty filters
config.addFilter("dateDisplay", (dateObj, format = "LLL d, y") => {
return DateTime.fromJSDate(dateObj, {
zone: "utc"
}).toFormat(format);
});
config.addFilter("shortMonth", (yearMonthString) => {
const [year, month] = yearMonthString.split("/");
const monthsArray = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
return monthsArray[month - 1] + " " + year;
});
// receive format of `2015-10-08T15:30:00` and make it pretty with Moment.js
config.addFilter("dateMoment", (time, format = "D MMMM YYYY, HH:mm") => {
time = time.replace('T', ' '); // no need for T in timestamp
time = time || new Date();
if (format == 'unix') {
return moment(time).format('X'); // time in seconds
} else {
return moment(time).format(format);
}
});
config.addFilter("dateMoment", (time, format = "D MMMM YYYY, HH:mm") => {
time = time.replace('T', ' '); // no need for T in timestamp
time = time || new Date();
if (format == 'unix') {
return moment(time).format('X'); // time in seconds
} else {
return moment(time).format(format);
}
});
// Add utility for flatten and create array required for vf-navigation from eleventy nav plugin data
config.addFilter("eleventyNavigationCollectionToVFNavigationData", (eleventyNavigationCollection) => {
return eleventyNavigationCollection.flat();
});
config.addPassthroughCopy("./src/site/**/*.js");
// pass some assets right through
config.addPassthroughCopy("./src/site/images");
// use the .yml file associated with the .njk if available
config.addDataExtension("yml", contents => yaml.safeLoad(contents));
return {
dir: {
input: "src/pages",
output: "build",
data: "_data"
},
templateFormats: [
"njk", "md", // note that .md files will also be parsed with njk processor
"css" // passthrough file copying for static assets
],
htmlTemplateEngine: ["njk", "md"],
markdownTemplateEngine: "njk",
passthroughFileCopy: true,
pathPrefix: "/web-optimisation-framework" // if your site is deployed to a sub-url, otherwise comment out
};
};