-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheleventy.config.js
More file actions
123 lines (105 loc) · 3.39 KB
/
Copy patheleventy.config.js
File metadata and controls
123 lines (105 loc) · 3.39 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
113
114
115
116
117
118
119
120
121
122
123
import { IdAttributePlugin } from "@11ty/eleventy";
import { feedPlugin } from "@11ty/eleventy-plugin-rss";
import syntaxHighlight from "@11ty/eleventy-plugin-syntaxhighlight";
import browserslist from "browserslist";
import * as lightningcss from "lightningcss";
import { browserslistToTargets } from "lightningcss";
import markdownItFootnote from "markdown-it-footnote";
import path from "path";
import * as sass from "sass";
import "xxgen/dist/import-tsx.js";
const targets = browserslistToTargets(browserslist('< 101%')) // literally everything
export default function (eleventyConfig) {
eleventyConfig.setInputDirectory("./site");
eleventyConfig.setLayoutsDirectory("_includes/layouts");
eleventyConfig.addPassthroughCopy("./site/assets");
eleventyConfig.addPassthroughCopy({'./site/assets/favicon.ico': 'favicon.ico'})
eleventyConfig.addPassthroughCopy({'./site/well-known': '.well-known'});
eleventyConfig.addPlugin(IdAttributePlugin);
eleventyConfig.addPlugin(syntaxHighlight, {
codeAttributes: {
class: ({ language }) => `language-${language} codeblock`,
}
});
eleventyConfig.amendLibrary("md", (mdLib) => {
// obsidian generates links that are absolute paths, but without the leading slash wich causes issues.
// normalise to be actually abolute paths
var oldNormalizeLink = mdLib.normalizeLink;
mdLib.normalizeLink = (url) => {
try {
const FAKE_ORIGIN = "https://fake.invalid";
let parsed = new URL(url, FAKE_ORIGIN);
if (parsed.origin == FAKE_ORIGIN)
url = parsed.pathname + parsed.search + parsed.hash;
} catch(e) {}
return oldNormalizeLink(url);
}
mdLib.use(markdownItFootnote)
});
const feedConfig = {
collection: {
name: 'notes',
limit: 0,
},
metadata: {
language: "en",
title: "Taylor's Notes",
subtitle: "The various scribblings & notes of a fox on the internet",
base: "https://eth0fox.net/notes",
author: {
name: "Taylor",
email: "fox@boxfox.es",
}
}
}
eleventyConfig.addPlugin(feedPlugin, {
type: 'rss',
outputPath: '/notes/rss.xml',
...feedConfig
});
eleventyConfig.addPlugin(feedPlugin, {
type: 'atom',
outputPath: '/notes/atom.xml',
...feedConfig
});
eleventyConfig.addPlugin(feedPlugin, {
type: 'json',
outputPath: '/notes/feed.json',
...feedConfig
});
eleventyConfig.addExtension(["11ty.jsx", "11ty.ts", "11ty.tsx"], {
key: "11ty.js",
compile: () => async function (data) {
let content = await this.defaultRenderer(data)
if (!Buffer.isBuffer(content) && typeof content !== "string")
content = String(content)
return content;
}
});
eleventyConfig.addExtension("scss", {
outputFileExtension: "css",
useLayouts: false,
compile: async function (inputContent, inputPath) {
let parsed = path.parse(inputPath);
if(parsed.name.startsWith("_")) {
return;
}
let compiled = sass.compileString(inputContent, {
loadPaths: [
parsed.dir || ".",
this.config.dir.includes,
]
});
this.addDependencies(inputPath, compiled.loadedUrls);
let { code } = lightningcss.transform({
filename: parsed.name,
code: Buffer.from(compiled.css),
minify: true,
sourceMap: false,
targets
})
return () => code;
},
});
eleventyConfig.addTemplateFormats(["11ty.jsx", "11ty.ts", "11ty.tsx", 'scss']);
}