-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheleventy.config.mjs
40 lines (39 loc) · 1.69 KB
/
eleventy.config.mjs
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
import fs from "fs";
import path from "path";
export default function (eleventyConfig) {
eleventyConfig.ignores.add("README.md");
eleventyConfig.setWatchThrottleWaitTime(100);
eleventyConfig.addPassthroughCopy("assets/css/*.css");
eleventyConfig.addPassthroughCopy("assets/favicons/*");
eleventyConfig.addPassthroughCopy("assets/img/*");
eleventyConfig.addPassthroughCopy("assets/fonts/*");
eleventyConfig.addPassthroughCopy("assets/js/**/*.js");
eleventyConfig.addShortcode("year", () => `${new Date().getFullYear()}`);
eleventyConfig.addFilter("fileExists", (filePath) => {
const fullPath = path.join("_includes", filePath);
return fs.existsSync(fullPath);
});
eleventyConfig.addFilter("assetExists", function(filePath) {
const fullJSPath = path.join("assets", filePath);
return fs.existsSync(fullJSPath);
});
eleventyConfig.addFilter("listFiles", function(folderPath) {
const fullPath = path.join("_includes", folderPath);
return fs.readdirSync(fullPath).map(file => path.join(folderPath, file));
});
eleventyConfig.addFilter("listFilesWithInfo", function(folderPath) {
const fullPath = path.join("_includes", folderPath);
return fs.readdirSync(fullPath).map(file => {
const fileNoExtension = path.parse(file).name;
return {
filePath: path.join(folderPath, file),
fileName: fileNoExtension
};
});
});
eleventyConfig.addFilter("upperFirst", (filename) => `${filename.charAt(0).toUpperCase() + filename.slice(1)}`);
eleventyConfig.setLiquidOptions({
dynamicPartials: true,
strict_filters: true,
});
}