-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eleventy.js
172 lines (149 loc) · 5.72 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
//require('dotenv').config({path: __dirname + '/.env.dev'});
// const { DateTime } = require("luxon");
// const CleanCSS = require("clean-css");
// const UglifyJS = require("uglify-es");
// const htmlmin = require("html-minifier");
const slugify = require("slugify");
//const eleventyNavigationPlugin = require("@11ty/eleventy-navigation");
module.exports = function(eleventyConfig) {
// Eleventy Navigation https://www.11ty.dev/docs/plugins/navigation/
//eleventyConfig.addPlugin(eleventyNavigationPlugin);
// Configuration API: use eleventyConfig.addLayoutAlias(from, to) to add
// layout aliases! Say you have a bunch of existing content using
// layout: post. If you don’t want to rewrite all of those values, just map
// post to a new file like this:
// eleventyConfig.addLayoutAlias("post", "layouts/my_new_post_layout.njk");
// Merge data instead of overriding
// https://www.11ty.dev/docs/data-deep-merge/
eleventyConfig.setDataDeepMerge(true);
// Date formatting (human readable)
// eleventyConfig.addFilter("readableDate", dateObj => {
// return DateTime.fromJSDate(dateObj).toFormat("dd LLL yyyy");
// });
// // Date formatting (machine readable)
// eleventyConfig.addFilter("machineDate", dateObj => {
// return DateTime.fromJSDate(dateObj).toFormat("yyyy-MM-dd");
// });
// // Minify CSS
// eleventyConfig.addFilter("cssmin", function(code) {
// return new CleanCSS({}).minify(code).styles;
// });
// // Minify JS
// eleventyConfig.addFilter("jsmin", function(code) {
// let minified = UglifyJS.minify(code);
// if (minified.error) {
// console.log("UglifyJS error: ", minified.error);
// return code;
// }
// return minified.code;
// });
// Minify HTML output
// if (process.env.ELEVENTY_ENV == 'production') {
// eleventyConfig.addTransform("htmlmin", function(content, outputPath) {
// if (outputPath.indexOf(".html") > -1) {
// let minified = htmlmin.minify(content, {
// useShortDoctype: true,
// removeComments: true,
// collapseWhitespace: true
// });
// return minified;
// }
// return content;
// });
// }
// Universal slug filter strips unsafe chars from URLs
eleventyConfig.addFilter("slugify", function(str) {
return slugify(str, {
lower: true,
replacement: "-",
remove: /[*+~.·,()'"`´%!?¿:@]/g
});
});
// Don't process folders with static assets e.g. images
eleventyConfig.addPassthroughCopy("favicon.ico");
eleventyConfig.addPassthroughCopy("static/img");
eleventyConfig.addPassthroughCopy("admin");
eleventyConfig.addPassthroughCopy("_includes/assets/");
/* Markdown Plugins */
// let markdownIt = require("markdown-it");
// let markdownItAttrs = require('markdown-it-attrs');
// let markdownItAnchor = require("markdown-it-anchor");
// let options = {
// html: true,
// breaks: true,
// linkify: true
// };
// let opts = {
// permalink: false
// };
// eleventyConfig.setLibrary("md", markdownIt(options)
// .use(markdownItAnchor, opts)
// .use(require('markdown-it-container'), '', {
// validate: () => true,
// render: (tokens, idx) => {
// if (tokens[idx].nesting === 1) {
// const classList = tokens[idx].info.trim()
// return `<div ${classList && `class="${classList}"`}>`;
// } else {
// return `</div>`;
// }
// }
// })
// .use(markdownItAttrs)
// );
//module.exports = function(eleventyConfig, pluginNamespace) {
//eleventyConfig.namespace(pluginNamespace, () => {
// eleventyConfig.addShortcode('imgresp', parameter => {
// var errors = '';
// if (!parameter.path) {
// errors += 'path parameter missing!';
// } else if (!parameter.sizes) {
// errors += 'sizes parameter missing!';
// }
// if (errors) {
// return '<span style="background:lightsalmon; padding:5px;">' + errors + '</span>';
// } else {
// const hostname = eleventyConfig.hostname ? eleventyConfig.hostname : '';
// const arraySizes = parameter.sizes.replace(/ /g,'').split(',');
// const maxSize = Math.max.apply(Math, arraySizes);
// const baseUrl = `https://res.cloudinary.com/${eleventyConfig.cloudinaryCloudName}/image/fetch/`;
// const imageSrc = `${baseUrl}q_auto,f_auto,w_${maxSize}/${hostname}${parameter.path}`;
// const srcset = arraySizes.map(width => {
// return `${baseUrl}q_auto,f_auto,w_${width}/${hostname}${parameter.path} ${width}w`;
// }).join(',');
// return '<img ' +
// (parameter.width ? ' width="' + parameter.width + '"' : '') +
// (parameter.height ? ' height="' + parameter.height + '"' : '') +
// (parameter.sizes ? ' sizes="(max-width: ' + maxSize + 'px) 100vw, ' + maxSize + 'px"' : '') +
// ' src="' + imageSrc + '"' +
// ' srcset="' + srcset + '"' +
// (parameter.alt ? ' alt="' + parameter.alt.trim() + '"' : '') +
// (parameter.classes ? ' class="' + parameter.classes + '"' : '') +
// '>';
// }
// });
//});
//};
/* Plugin: eleventy-plugin-respimg */
//const pluginRespimg = require('eleventy-plugin-respimg');
// eleventyConfig.cloudinaryCloudName = process.env.CLOUDINARY_CLOUD_NAME;
// eleventyConfig.hostname = 'https://spectrumac.netlify.app';
//eleventyConfig.addPlugin( pluginRespimg );
return {
templateFormats: ["md", "njk", "html", "liquid"],
// If your site lives in a different subdirectory, change this.
// Leading or trailing slashes are all normalized away, so don’t worry about it.
// If you don’t have a subdirectory, use "" or "/" (they do the same thing)
// This is only used for URLs (it does not affect your file structure)
pathPrefix: "/",
markdownTemplateEngine: "njk",
htmlTemplateEngine: "njk",
dataTemplateEngine: "njk",
dir: {
input: ".",
includes: "_includes",
data: "_data",
output: "_site"
}
};
};