-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.eleventy.js
65 lines (56 loc) · 2.38 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
const { JSDOM } = require('jsdom');
const path = require('path');
const pluginNavigation = require("@11ty/eleventy-navigation");
const eleventySass = require("eleventy-sass");
const updatePermalinks = require('./lib/update-permalinks');
const updateMarkup = require('./lib/update-markup');
const { execSync } = require('child_process');
const markdownit = require('markdown-it');
const md = markdownit({ html: true, linkify: true });
module.exports = function(eleventyConfig) {
// Custom collections
// Returns an array collection from the reusableDesign tag, sorted alphabetically
eleventyConfig.addCollection("reusableDesignAtoZ", function (collectionApi) {
return collectionApi.getFilteredByTag("reusableDesign").sort((a, b) => {
return a.data.title.localeCompare(b.data.title, undefined, { sensitivity: "base" });
});
});
// All plugins used
eleventyConfig.addPlugin(pluginNavigation);
eleventyConfig.addPlugin(eleventySass, {
compileOptions: {
permalink: function(contents, inputPath) {
return (data) => data.page.filePathStem.replace(/^\/scss\//, "/css/") + ".css";
}
},
sass: {
style: "compressed",
sourceMap: false
},
});
eleventyConfig.addPlugin(updatePermalinks);
eleventyConfig.addPlugin(updateMarkup);
// Paired shortcode for the callout component- variant types are info, print, alert, block
eleventyConfig.addPairedShortcode("callout", function(content, variant) {
return `<article class="umich-lib-callout ${variant}"><p><span class="visually-hidden">${variant} callout</span>${md.renderInline(content)}</p></article>`;
});
eleventyConfig.addShortcode("year", () => `${new Date().getFullYear()}`);
// The addWatchTarget config method allows you to manually add a file for Eleventy to watch.
eleventyConfig.addWatchTarget("./src/scss");
eleventyConfig.addWatchTarget("./src/js");
// The Pass Through feature tells Eleventy to copy things to our output folder
// Eleventy passes through our compiled CSS to the public directory.
eleventyConfig.addPassthroughCopy("./src/img");
eleventyConfig.addPassthroughCopy("./src/js");
eleventyConfig.on('eleventy.after', () => {
execSync(`npx pagefind --site public --glob \"**/*.html\"`, { encoding: 'utf-8' })
})
return {
passthroughFileCopy: true,
dir: {
input: "src",
output: "public",
layouts: "_includes/layouts",
},
};
};