2023-11-05 23:05:38 +08:00
|
|
|
const { DateTime } = require("luxon");
|
|
|
|
const CleanCSS = require("clean-css");
|
|
|
|
const htmlmin = require("html-minifier");
|
|
|
|
const markdownIt = require("markdown-it");
|
|
|
|
const markdownItAttrs = require("markdown-it-attrs");
|
|
|
|
|
|
|
|
module.exports = function(eleventyConfig) {
|
|
|
|
|
|
|
|
eleventyConfig.setUseGitIgnore(false);
|
|
|
|
|
|
|
|
const mdOptions = {
|
|
|
|
html: true,
|
|
|
|
breaks: true,
|
|
|
|
linkify: true,
|
|
|
|
};
|
|
|
|
|
|
|
|
const markdownLib = markdownIt(mdOptions)
|
|
|
|
.use(markdownItAttrs)
|
|
|
|
.use(require('markdown-it-bracketed-spans'))
|
|
|
|
.disable("code");
|
|
|
|
|
|
|
|
eleventyConfig.setLibrary("md", markdownLib);
|
|
|
|
|
|
|
|
eleventyConfig.setTemplateFormats([
|
|
|
|
"md",
|
|
|
|
"webmanifest",
|
|
|
|
"xml",
|
|
|
|
"ico",
|
|
|
|
"svg",
|
|
|
|
"png",
|
|
|
|
"jpg",
|
|
|
|
"txt",
|
|
|
|
"woff",
|
|
|
|
"woff2",
|
|
|
|
"css",
|
|
|
|
"pdf"
|
|
|
|
]);
|
|
|
|
|
|
|
|
eleventyConfig.addFilter("readablePostDate", (dateObj) => {
|
|
|
|
return DateTime.fromJSDate(dateObj, {
|
2023-11-07 07:40:08 +08:00
|
|
|
zone: "Asia/Singapore",
|
2023-11-05 23:05:38 +08:00
|
|
|
}).setLocale('en-GB').toLocaleString({day: 'numeric',month: 'short',year: 'numeric'});
|
|
|
|
});
|
|
|
|
|
|
|
|
eleventyConfig.addFilter("postDate", (dateObj) => {
|
|
|
|
return DateTime.fromJSDate(dateObj, {
|
|
|
|
zone: "Asia/Singapore",
|
|
|
|
}).setLocale('en-GB').toISODate();
|
|
|
|
});
|
|
|
|
|
|
|
|
eleventyConfig.addTransform("htmlmin", function(content, outputPath) {
|
|
|
|
if( outputPath && outputPath.endsWith(".html") ) {
|
|
|
|
let minified = htmlmin.minify(content, {
|
|
|
|
useShortDoctype: true,
|
|
|
|
removeComments: true,
|
|
|
|
collapseWhitespace: true
|
|
|
|
});
|
|
|
|
return minified;
|
|
|
|
}
|
|
|
|
return content;
|
|
|
|
});
|
|
|
|
|
|
|
|
return {
|
|
|
|
dir: {
|
|
|
|
input: "src",
|
|
|
|
includes: "_includes",
|
|
|
|
output: "site"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
eleventyConfig.addPassthroughCopy('/src/css')
|
|
|
|
return {
|
|
|
|
passthroughFileCopy: true
|
|
|
|
}
|
|
|
|
};
|