-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.eleventy.js
More file actions
112 lines (100 loc) · 2.86 KB
/
.eleventy.js
File metadata and controls
112 lines (100 loc) · 2.86 KB
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
module.exports = function (eleventyConfig) {
const path = require("path");
const fs = require("fs");
const sass = require("sass");
const { feedPlugin } = require("@11ty/eleventy-plugin-rss");
const { eleventyImageTransformPlugin } = require("@11ty/eleventy-img");
eleventyConfig.addWatchTarget("./src/**/*");
eleventyConfig.addPlugin(feedPlugin, {
type: "atom",
outputPath: "/feed.xml",
stylesheet: "/assets/pretty-atom-feed.xsl",
templateData: {
eleventyNavigation: {
key: "Feed",
order: 4,
},
},
collection: {
name: "post",
limit: 20,
},
metadata: {
language: "en",
title: "Button Kin Games",
subtitle:
"Publishing original games and new content for table top roleplaying, aka TTRPGs",
base: "https://buttonkin.com/",
author: {
name: "Yvris",
},
},
});
eleventyConfig.addPlugin(eleventyImageTransformPlugin, {
formats: ["webp", "jpeg"],
widths: [200, 400, 800, 1600],
htmlOptions: {
imgAttributes: {
loading: "lazy",
decoding: "async",
},
pictureAttributes: {},
},
});
eleventyConfig.addTemplateFormats("scss");
eleventyConfig.addExtension("scss", {
outputFileExtension: "css",
compile: function (inputContent, inputPath) {
let parsed = path.parse(inputPath);
// Don’t compile file names that start with an underscore
if (parsed.name.startsWith("_")) {
return;
}
// Get the directory of the input file for relative imports
const dir = path.dirname(inputPath);
return function (data) {
return sass.compileString(inputContent, {
loadPaths: [dir],
}).css;
};
},
});
eleventyConfig
.addPassthroughCopy("src/assets")
.addPassthroughCopy("src/images")
.addPassthroughCopy("src/assets/pretty-atom-feed.xsl")
.addPassthroughCopy({ "src/assets/favicon.ico": "/favicon.ico" });
eleventyConfig.addFilter("dateToRfc822", function (date) {
return new Date(date).toUTCString();
});
const EXCLUDED_TAGS = ["post", "adventure", "game"];
eleventyConfig.addFilter("tags", (tags) => {
let result = [];
tags.forEach((tag) => {
if (!EXCLUDED_TAGS.includes(tag))
result.push({
tag: tag,
name: tag.replace(/-/, " "),
});
});
return result;
});
eleventyConfig.addFilter("file_exists", function (filepath) {
return fs.existsSync(filepath.replace(/^\//, "./src/"));
});
eleventyConfig.addFilter("append", function (str, append) {
return str + append;
});
return {
dir: {
input: "src",
output: "_site",
includes: "_includes",
layouts: "_layouts",
data: "_data",
},
templateFormats: ["liquid", "md", "njk", "html"],
htmlTemplateEngine: "liquid",
markdownTemplateEngine: "liquid",
};
};