aboutsummaryrefslogtreecommitdiffstats
path: root/eleventy.config.js
diff options
context:
space:
mode:
Diffstat (limited to 'eleventy.config.js')
-rw-r--r--eleventy.config.js74
1 files changed, 63 insertions, 11 deletions
diff --git a/eleventy.config.js b/eleventy.config.js
index f759804..049294f 100644
--- a/eleventy.config.js
+++ b/eleventy.config.js
@@ -6,12 +6,23 @@ import directoryOutputPlugin from "@11ty/eleventy-plugin-directory-output";
import { eleventyImageTransformPlugin } from "@11ty/eleventy-img"
import pluginWebc from "@11ty/eleventy-plugin-webc";
+import { readFile } from 'node:fs/promises';
import { DateTime } from "luxon";
-import { readFileSync } from 'node:fs';
+import htmlmin from "html-minifier-terser";
+
+import mdAbbr from 'markdown-it-abbr';
+import mdContainer from 'markdown-it-container';
+
+import postcss from 'postcss';
+import cssnano from 'cssnano';
+
+
+import metadata from './data/metadata.js';
+
/** @param {import("@11ty/eleventy").UserConfig} eleventyConfig */
-export default async function (eleventyConfig) {
+export default async function(eleventyConfig) {
eleventyConfig.addPlugin(EleventyHtmlBasePlugin);
eleventyConfig.addPlugin(RenderPlugin);
eleventyConfig.addPlugin(InputPathToUrlTransformPlugin);
@@ -23,15 +34,13 @@ export default async function (eleventyConfig) {
collection: {
name: "post"
},
+ stylesheet: "atom.xsl",
metadata: {
- language: "en-GB",
- title: "Sudomsg",
- subtitle: "Messages from Root",
- base: "https://sudomsg.com/",
- author: {
- name: "Marc Pervaz Boocha",
- email: "mboocha@sudomsg.com",
- }
+ language: metadata.language,
+ title: metadata.title,
+ subtitle: metadata.description,
+ base: metadata.url.href,
+ author: metadata.author,
}
});
eleventyConfig.addPlugin(eleventyNavigationPlugin);
@@ -40,6 +49,28 @@ export default async function (eleventyConfig) {
components: [
"npm:@11ty/eleventy-plugin-syntaxhighlight/*.webc",
],
+ bundlePluginOptions: {
+ transforms: [
+ async function(content) {
+ if (this.type == 'css') {
+ const result = await postcss([
+ cssnano({
+ preset: ['default', {
+ discardComments: {
+ removeAll: true,
+ },
+ }]
+ })
+ ]).process(content, {
+ from: this.page.inputPath,
+ to: null,
+ })
+ return result.css
+ }
+ return content;
+ }
+ ],
+ }
});
eleventyConfig.addPassthroughCopy({
@@ -56,6 +87,12 @@ export default async function (eleventyConfig) {
loading: "lazy"
},
});
+
+
+ eleventyConfig.amendLibrary("md", mdLib => {
+ mdLib.use(mdAbbr).use(mdContainer, "aside");
+ });
+
eleventyConfig.setServerPassthroughCopyBehavior("passthrough");
eleventyConfig.addFilter("readableDate", (dateObj, format, zone) => {
@@ -64,11 +101,26 @@ export default async function (eleventyConfig) {
eleventyConfig.addFilter('htmlDateString', dateObj => DateTime.fromJSDate(dateObj, { zone: 'utc' }).toFormat('yyyy-LL-dd'));
eleventyConfig.addShortcode('schema', type => (type instanceof URL ? type : new URL(type, "http://schema.org/")).href);
- eleventyConfig.addFilter('embed', path => readFileSync(path, { encoding: 'utf8' }));
+ eleventyConfig.addAsyncFilter('embed', path => readFile(path, { encoding: 'utf8' }));
eleventyConfig.setQuietMode(true);
eleventyConfig.setDynamicPermalinks(false);
+ eleventyConfig.addTransform("htmlmin", function(content) {
+ if ((this.page.outputPath || "").endsWith(".html")) {
+ let minified = htmlmin.minify(content, {
+ useShortDoctype: true,
+ removeComments: true,
+ collapseWhitespace: true,
+ });
+
+ return minified;
+ }
+
+ // If not an HTML output, return content as-is
+ return content;
+ });
+
return {
markdownTemplateEngine: "njk",
htmlTemplateEngine: "webc",