-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eleventy.js
106 lines (100 loc) · 4.34 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
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
const striptags = require("striptags");
const markdownIt = require("markdown-it");
const mdRender = new markdownIt();
const fetch = require("node-fetch");
const he = require("he");
const pluginRss = require("@11ty/eleventy-plugin-rss");
const WHITESPACE = /\s+/;
module.exports = function (eleventyConfig) {
eleventyConfig.addPlugin(pluginRss);
eleventyConfig.addPassthroughCopy('CNAME');
eleventyConfig.addPassthroughCopy("./authorImg");
eleventyConfig.addPassthroughCopy("./css");
eleventyConfig.addPassthroughCopy("./img");
eleventyConfig.addPassthroughCopy("./links");
eleventyConfig.addPassthroughCopy("./postImg");
eleventyConfig.addPassthroughCopy("./script");
eleventyConfig.addPassthroughCopy("./sitemap.xml");
eleventyConfig.addPassthroughCopy("./robots.txt");
eleventyConfig.addPassthroughCopy("./ads.txt");
eleventyConfig.addFilter("fifty_words", (content) => {
var plainText = striptags(he.decode(mdRender.render(content), { strict: true }), []);
if (plainText.split(WHITESPACE).length > 50) {
plainText = plainText.split(WHITESPACE).slice(0, 50).join(" ") + "...";
}
return plainText;
});
eleventyConfig.addLiquidShortcode("header", function () {
return `
<header>
<noscript>
<div id="error">
<strong>
This site works best with JavaScript enabled! (╯°□°)╯︵ ┻━┻
</strong>
</div>
</noscript>
<img id="topBtn" src="/img/TopIcon.svg" alt="Click to go back to top.">
<div id="vignette"></div>
<a href="/">
<img src="/img/2022-01_ARBEE_Wort-Marke_rgb_weiss_01.svg" id="wordmark" alt="ARBEE's Wordmark">
</a>
</header>`
});
eleventyConfig.addLiquidShortcode("footer", function () {
return `
<footer id="footer">
<img src="/img/2022-01_ARBEE_Wort-Bild-Marke_rgb_weiss_01.svg" alt="ARBEE's Word-Imagemark.">
<br>
<div id="footercontact">
<a href="https://ko-fi.com/arbee" target="_blank">
<img src="/img/ko-fi-icon.svg" alt="Support me on Ko-fi!">
</a>
<a href="https://arbeeco.de/links/discord" target="_blank">
<img src="/img/icon_clyde_circle_white.svg" alt="Contact ARBEE over Discord.">
</a>
<a href="https://twitter.com/ARBEE_codes" target="_blank">
<img src="/img/TwitterLogoWhite.svg" alt="Contact ARBEE over Twitter">
</a>
<a rel="me" href="https://floss.social/@arbee">
<img src="/img/MastodonLogoWhiteCircle.svg" alt="Contact ARBEE over Mastodon">
</a>
<a href="https://github.com/Arbee4ever" target="_blank">
<img src="/img/GitHub-Logo.svg" alt="Contact ARBEE over GitHub.">
</a>
<a href="mailto:%61%72%62%65%65%40%61%72%62%65%65%63%6F%2E%64%65?subject=Contact-Website&body=Hello%20ARBEE%2C">
<img src="/img/MailLogoWhite.svg" alt="Contact ARBEE over eMail.">
</a>
</div>
<p>Hosted on <a href="https://pages.cloudflare.com" target="_blank">Cloudflare</a>, domain from <a href="https://dashserv.io/a/arbee" target="_blank">dashserv</a></p>
<p>Brand design by <a href="https://www.instagram.com/ralfbaenecke/" target="_blank">ralf baenecke</a>.</p>
<p>© 2022 ARBEE</p>
</footer>`
});
eleventyConfig.addLiquidShortcode("modPostPreview", async mod => {
const modrinthAPI = await fetch("https://api.modrinth.com/v2/project/" + mod, {
Accept: "application/json",
method: "GET",
"User-Agent": "https://github.com/Arbee4ever/arbeeco.de (arbeeco.de)"
});
const response = await modrinthAPI.json();
const body = response.body;
return eleventyConfig.getFilter("fifty_words")(body);
});
eleventyConfig.addLiquidShortcode("modPost", async mod => {
const modrinthAPI = await fetch("https://api.modrinth.com/v2/project/" + mod, {
Accept: "application/json",
method: "GET",
"User-Agent": "https://github.com/Arbee4ever/arbeeco.de (arbeeco.de)"
});
const response = await modrinthAPI.json();
return mdRender.render(response.body);
});
return {
dir: {
input: "./",
output: "./_site",
layouts: "./_layouts"
}
};
}