-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy path.eleventy.js
31 lines (27 loc) · 1.16 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
const svgContents = require("eleventy-plugin-svg-contents");
const syntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");
const rssPlugin = require("@11ty/eleventy-plugin-rss");
const axios = require("axios");
const md = require('markdown-it')({html: true});
module.exports = function(eleventyConfig) {
eleventyConfig.addPlugin(syntaxHighlight);
eleventyConfig.addPlugin(svgContents);
eleventyConfig.addPlugin(rssPlugin);
eleventyConfig.addNunjucksAsyncShortcode("fetchMD", async function(url) {
const {val} = url;
const res = await axios.get(val)
return md.render(res.data);
})
eleventyConfig.addCollection("plugins", function(collectionApi) {
return collectionApi.getFilteredByTag('plugins').sort((a, b) => {
if (a.data.title.toLowerCase() > b.data.title.toLowerCase()) return -1;
else if (a.data.title.toLowerCase() < b.data.title.toLowerCase()) return 1;
else return 0;
}).reverse()
});
eleventyConfig.addCollection("categories", function(collectionApi) {
return collectionApi.getFilteredByTag('categories');
});
eleventyConfig.addPassthroughCopy('assets');
eleventyConfig.addPassthroughCopy('admin');
}