]> Witch of Git - web/blog/blob - .eleventy.js
Fix CNAME
[web/blog] / .eleventy.js
1 const pluginRss = require("@11ty/eleventy-plugin-rss");
2 const pluginSyntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");
3 const Nunjucks = require("nunjucks");
4 const nunjucksDate = require("nunjucks-date");
5 const md = require("markdown-it")();
6
7 module.exports = (eleventyConfig) => {
8 eleventyConfig.addNunjucksFilter('date', nunjucksDate);
9 eleventyConfig.addPlugin(pluginRss);
10 eleventyConfig.addPlugin(pluginSyntaxHighlight);
11
12 eleventyConfig.addPassthroughCopy("img");
13 eleventyConfig.addPassthroughCopy("static");
14
15 eleventyConfig.addNunjucksShortcode("youtube", youtubeShortcode);
16 eleventyConfig.addPairedNunjucksShortcode("tweet", tweetShortcode);
17 eleventyConfig.addFilter("markdown", value => md.renderInline(value));
18
19 return {
20 markdownTemplateEngine: "njk",
21 };
22 };
23
24 function youtubeShortcode(items, inWidth, inHeight) {
25 const width = items.width || inWidth || 560;
26 const height = items.height || inHeight || 315;
27 const allow = items.allow || "accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"
28 const border = items.border || "0";
29 const video = items.video || items;
30 if (!video) {
31 throw "Required argument 'video'.";
32 }
33 const src = "https://www.youtube.com/embed/" + video;
34 return `<div class="row flex-center">
35 <iframe width="${width}" height="${height}" src="${src}"
36 frameborder="${border}" allow="${allow}" allowfullscreen></iframe>
37 </div>`;
38 }
39
40 function tweetShortcode(content, items) {
41 // @TODO: Handle parsing date
42 return `<div class="row flex-center">
43 <blockquote class="twitter-tweet">
44 <p lang="en" dir="ltr">${content}</p> &mdash; ${items.name} (@${items.at})
45 <a href="${items.link}">${items.date}</a>
46 </blockquote>
47 <script async src="https://platform.twitter.com/widgets.js" charset="utf-8">
48 </script>
49 </div>`;
50 }