-
Notifications
You must be signed in to change notification settings - Fork 1
/
.eleventy.js
117 lines (96 loc) · 3.78 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
106
107
108
109
110
111
112
113
114
115
116
117
// require('dotenv').config(); // Reference env vars
const eleventyNavigationPlugin = require('@11ty/eleventy-navigation'); // Navigation
const pluginRss = require('@11ty/eleventy-plugin-rss'); // RSS
const { DateTime } = require('luxon'); // Date formatting
module.exports = function (eleventyConfig) {
// UNIVERSAL
// Don't try to build asset files, just transparently copy them through
eleventyConfig.addPassthroughCopy('src/assets');
eleventyConfig.addPassthroughCopy('src/manifest.webmanifest');
eleventyConfig.addPassthroughCopy('src/robots.txt');
// Prettify slug names
/*
eleventyConfig.addFilter('prettySlugName', function(value) {
let slugString = value.replace('-', ' ').split(' ');
let prettyString = [];
for (let word of slugString) {
prettyString.push(word.charAt(0).toUpperCase()+ word.slice(1));
}
return prettyString.join(' ');
});
*/
// UTILITIES
// LIMIT ARRAY
/*
eleventyConfig.addFilter('limit', function (arr, limit) {
return arr.slice(0, limit);
});
*/
// OFFSET ARRAY
/*
eleventyConfig.addFilter('offset', function (arr, limit) {
return arr.slice(limit + 1);
});
*/
// NAVIGATION
eleventyConfig.addPlugin(eleventyNavigationPlugin);
// BLOG
// RSS FEED
eleventyConfig.addPlugin(pluginRss);
// DATE FILTERS
// Machine-readable dates
eleventyConfig.addFilter("machineDate", function(value) {
return DateTime.fromJSDate(value, {zone: 'utc'}).toISO();
});
// Prettify dates
eleventyConfig.addFilter("prettyDate", function(value) {
return DateTime.fromJSDate(value, {zone: 'utc'}).toFormat('MMM dd, yyyy');
});
// Prettify ISO dates
eleventyConfig.addFilter("prettyISODate", function(value) {
return DateTime.fromISO(value, {zone: 'utc'}).toFormat('MMM dd, yyyy');
});
// Reduce date to year
eleventyConfig.addFilter("yearOnlyDate", function(value) {
return DateTime.fromJSDate(value, {zone: 'utc'}).toFormat('yyyy');
});
/* EXTRA MD OPTIONS
* Classes etc: https://www.npmjs.com/package/markdown-it-attrs
* Header anchors: https://www.npmjs.com/package/markdown-it-anchor
*/
/*
const markdownIt = require('markdown-it');
const markdownItAnchor = require('markdown-it-anchor');
const markdownItAttrs = require("markdown-it-attrs");
let markdownLibrary = markdownIt({
html: true,
breaks: true,
linkify: true
}).use(markdownItAttrs).use(markdownItAnchor, {permalink: false});
eleventyConfig.setLibrary('md', markdownLibrary);
*/
// SHORTCODE - RESPONSIVE IMAGES
/*
eleventyConfig.addShortcode("responsiveImage", function(baseSrc, ext, max, alt, classes, link) {
let fullBaseSrc = '/assets/images/content/' + baseSrc;
var sources = '<source media="(min-width: 501px)" srcset="' + fullBaseSrc + '-m.' + ext + '">';
if (max !== 'm') {
sources = '<source media="(min-width: 801px)" srcset="' + fullBaseSrc + '-l.' + ext + '">' + sources;
}
if (max === 'xl') {
sources = '<source media="(min-width: 1201px)" srcset="' + fullBaseSrc + '-xl.' + ext + '">' + sources;
}
if (link) {
return `<div class="c-media ${classes}"><a href="${link}"><picture>${sources}<img src="${fullBaseSrc}-s.${ext}" alt="${alt}"></picture></a></div>`;
} else {
return `<div class="c-media ${classes}"><picture>${sources}<img src="${fullBaseSrc}-s.${ext}" alt="${alt}"></picture></div>`;
}
});
*/
// CUSTOMIZE INPUT DIRECTORY
return {
dir: {
input: 'src'
}
}
};