generated from visual-framework/vf-eleventy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
eleventy.js
executable file
·105 lines (88 loc) · 3.06 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
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
const { DateTime } = require('luxon');
const _ = require('lodash');
const Path = require('path');
module.exports = function(config) {
// 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(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("makeLowercase", function(value) {
// value = value || '';
// return value.toLowerCase();
// });
// config.addFilter("spaceToDashes", function(value) {
// value = value || '';
// return value.replace(/\s+/g, '-').toLowerCase();
// });
// Shortcodes
// https://www.11ty.io/docs/shortcodes/
// -----
// nunjucks
// {% sampleShortcode "firstName", "lastName" %}
// handlebars
// {{ sampleShortcode "firstName" "lastName" }}
// config.addShortcode("sampleShortcode", function(firstName, lastName) {
// return 'hi ' + firstName + lastName;
// });
// If you want to minify html output
// config.addTransform("htmlmin", require("./node_modules/\@visual-framework/vf-eleventy--extensions/utils/minify-html.js"));
// Add any custom tags
// config.addNunjucksTag("uppercase", function(nunjucksEngine) {
// return new function() {
// this.tags = ["uppercase"];
//
// this.parse = function(parser, nodes, lexer) {
// var tok = parser.nextToken();
//
// var args = parser.parseSignature(null, true);
// parser.advanceAfterBlockEnd(tok.value);
//
// return new nodes.CallExtensionAsync(this, "run", args);
// };
//
// this.run = function(context, myStringArg, callback) {
// let ret = new nunjucksEngine.runtime.SafeString(
// myStringArg.toUpperCase()
// );
// callback(null, ret);
// };
// }();
// });
// copy js files
// this is neccesary now that 11ty tries to compile JS files as templates
// @todo: backport to vf-eleventy
config.addPassthroughCopy("./src/site/**/*.js");
// pass some assets right through
config.addPassthroughCopy("./src/site/images");
return {
dir: {
input: "src/site",
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: "/ebi-eleventy-boilerplate/" // if your site is deployed to a sub-url, otherwise comment out
};
};