forked from tweetback/tweetback
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheleventy.config.js
40 lines (32 loc) · 1.29 KB
/
eleventy.config.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
const numeral = require("numeral");
const { EleventyHtmlBasePlugin } = require("@11ty/eleventy");
const { execSync } = require('child_process')
module.exports = function(eleventyConfig) {
eleventyConfig.ignores.add("README.md");
// eleventyConfig.setServerPassthroughCopyBehavior("copy");
eleventyConfig.addPassthroughCopy("assets/");
eleventyConfig.addPassthroughCopy("img/");
eleventyConfig.addPassthroughCopy("video/");
eleventyConfig.addPassthroughCopy({
"node_modules/@11ty/is-land/is-land.js": "assets/is-land.js",
});
eleventyConfig.addJavaScriptFunction("avatarUrl", function avatarUrl(url) {
if(url.startsWith("https://twitter.com/")) {
url = "https://x.com/" + url.slice("https://twitter.com/".length);
}
return `https://v1.indieweb-avatar.11ty.dev/${encodeURIComponent(url)}/`;
});
eleventyConfig.addJavaScriptFunction("renderNumber", function renderNumber(num) {
if(typeof num === "string") {
num = parseInt(num, 10);
}
return numeral(num).format("0,0");
});
eleventyConfig.addPlugin(EleventyHtmlBasePlugin);
// pagefind search plugin
eleventyConfig.on('eleventy.after', () => {
console.log('[pagefind] Creating search index.');
execSync(`npx pagefind --source _site --glob \"[0-9]*/**/*.html\"`, { encoding: 'utf-8' });
});
return {pathPrefix: "/_site/"}
};