-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eleventy.js
42 lines (33 loc) · 1.3 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
const webcPlugin = require("@11ty/eleventy-plugin-webc")
const CleanCSS = require("clean-css")
const syntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight")
const { EleventyRenderPlugin } = require("@11ty/eleventy")
const pluginRss = require("@11ty/eleventy-plugin-rss");
function imgShortcode(src, alt) {
return `<img src="${imgPath(src)}" alt="${alt}" />`
}
function imgPath(filename) {
return `/img/${filename}`
}
function minifyCss(code) {
return new CleanCSS({}).minify(code).styles
}
function readableDate(dateString) {
let d = new Date(dateString)
// d.toString() = Fri Apr 01 2022 23:30:00 GMT+0530 (India Standard Time)
// 👇 gives Fri, Apr 01 2022
return d.toString().replace(/(^[A-z,a-z]{3})(.*20\d\d).*$/, '$1,$2')
}
module.exports = function(eleventyConfig) {
eleventyConfig.addPassthroughCopy("img")
eleventyConfig.addPassthroughCopy("CNAME")
eleventyConfig.addShortcode("img", imgShortcode)
eleventyConfig.addFilter("imgPath", imgPath)
eleventyConfig.addFilter("cssmin", minifyCss)
eleventyConfig.addFilter("readableDate", readableDate)
eleventyConfig.addPlugin(EleventyRenderPlugin)
eleventyConfig.addPlugin(webcPlugin)
eleventyConfig.addPlugin(syntaxHighlight)
eleventyConfig.addPlugin(pluginRss);
eleventyConfig.addLiquidFilter("dateToRfc3339", pluginRss.dateToRfc3339);
}