-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.eleventy.js
66 lines (54 loc) · 2.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
const CleanCSS = require("clean-css");
const { EleventyRenderPlugin } = require("@11ty/eleventy");
const markdownIt = require('markdown-it');
const markdownItAnchor = require('markdown-it-anchor');
const markdownItAttrs = require('markdown-it-attrs');
const markdownItFootnote = require('markdown-it-footnote');
module.exports = function (eleventyConfig) {
eleventyConfig.addPassthroughCopy("**/*.jpg");
eleventyConfig.addPassthroughCopy("**/*.png");
eleventyConfig.addPassthroughCopy("**/*.gif");
eleventyConfig.addPassthroughCopy("**/*.svg");
eleventyConfig.addPassthroughCopy("**/*.webp");
eleventyConfig.addFilter("cssmin", function (code) {
return new CleanCSS({}).minify(code).styles;
});
// Filters
eleventyConfig.addFilter("readableDate", (dateObj) => {
dateObj ??= new Date(); // if null or undefined, then create new obj with current time
const dateOptions = {
year: "numeric",
month: "long",
day: "numeric",
};
// TODO: USE PRETTIER DATE FORMAT
return dateObj.toLocaleDateString("en-us", {
timeZone: "utc",
...dateOptions,
}); // Use utc tz so that no tz conversion occurs
});
eleventyConfig.addFilter("htmlDateString", (dateObj) => {
dateObj ??= new Date(); // if null or undefined, then create new obj with current time
// Use utc tz so that no tz conversion occurs
// Convert to YYYY/MM/DD, then replace forward slashes with dashes to return YYYY-MM-DD
return dateObj
.toLocaleDateString("en-ZA", { timezone: "utc" })
.replace(/\//g, "-");
});
eleventyConfig.addPlugin(EleventyRenderPlugin);
const markdownItOptions = {
html: true // you can include HTML tags
}
const markdownItAnchorOptions = {
level: 2 // anchors will only be applied to h2 level headers and below but not h1
}
eleventyConfig.setLibrary("md", markdownIt(markdownItOptions).use(markdownItAnchor, markdownItAnchorOptions).use(markdownItAttrs).use(markdownItFootnote))
return {
dir: {
input: "content", // default: "."
includes: "../_includes", // default: "_includes"
data: "../_data", // default: "_data"
output: "_site",
},
};
};