2026-02-19 12:07:10 -08:00
|
|
|
import { IdAttributePlugin } from "@11ty/eleventy";
|
2026-02-17 21:11:03 -08:00
|
|
|
import { eleventyImageTransformPlugin } from "@11ty/eleventy-img";
|
2026-02-18 10:58:36 -08:00
|
|
|
import eleventyNavigationPlugin from "@11ty/eleventy-navigation";
|
|
|
|
|
import { feedPlugin } from "@11ty/eleventy-plugin-rss";
|
|
|
|
|
import syntaxHighlight from "@11ty/eleventy-plugin-syntaxhighlight";
|
2026-02-18 16:29:21 -08:00
|
|
|
import { attrs } from "@mdit/plugin-attrs";
|
2026-02-18 18:44:17 -08:00
|
|
|
import { chunk } from "lodash-es";
|
2026-02-19 17:54:01 -08:00
|
|
|
import path from "node:path";
|
2026-02-18 18:44:17 -08:00
|
|
|
|
|
|
|
|
import pluginFilters from "./_config/filters.js";
|
2026-02-17 21:11:03 -08:00
|
|
|
|
2026-02-17 20:03:12 -08:00
|
|
|
export default async function(eleventyConfig) {
|
2026-02-18 16:29:21 -08:00
|
|
|
/* Markdown HTML attribute parsing */
|
|
|
|
|
eleventyConfig.amendLibrary("md", (mdLib) => mdLib.use(attrs));
|
|
|
|
|
|
2026-02-19 12:07:10 -08:00
|
|
|
/* Bundles */
|
|
|
|
|
/* CSS */
|
|
|
|
|
eleventyConfig.addBundle("css", {
|
|
|
|
|
toFileDirectory: "dist",
|
|
|
|
|
bundleHtmlContentFromSelector: "style",
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/* Javascript */
|
|
|
|
|
eleventyConfig.addBundle("js", {
|
|
|
|
|
toFileDirectory: "dist",
|
|
|
|
|
bundleHtmlContentFromSelector: "script",
|
|
|
|
|
});
|
|
|
|
|
|
2026-02-18 18:44:17 -08:00
|
|
|
/* Collections */
|
|
|
|
|
/* Tag pagination */
|
|
|
|
|
eleventyConfig.addCollection("tagPagination", function(collection) {
|
|
|
|
|
let tagSet = new Set(collection.getAllSorted().flatMap((post) => post.data.tags || []));
|
2026-02-19 07:44:29 -08:00
|
|
|
tagSet = tagSet.difference(new Set(["posts", "gallery", "reference"]));
|
2026-02-18 18:44:17 -08:00
|
|
|
|
|
|
|
|
let paginationSize = 13;
|
|
|
|
|
let tagMap = [];
|
|
|
|
|
let tagArray = [...tagSet];
|
2026-02-19 07:44:29 -08:00
|
|
|
|
2026-02-18 18:44:17 -08:00
|
|
|
for( let tagName of tagArray) {
|
|
|
|
|
let tagItems = collection.getFilteredByTag(tagName);
|
|
|
|
|
let pagedItems = chunk(tagItems.reverse(), paginationSize); // console.log( tagName, tagItems.length, pagedItems.length );
|
2026-02-19 07:44:29 -08:00
|
|
|
|
2026-02-18 18:44:17 -08:00
|
|
|
for( let pageNumber = 0, max = pagedItems.length; pageNumber < max; pageNumber++) {
|
|
|
|
|
tagMap.push({
|
|
|
|
|
tagName: tagName,
|
|
|
|
|
pageNumber: pageNumber,
|
|
|
|
|
pageSize: pagedItems.length,
|
|
|
|
|
pageData: pagedItems[pageNumber]
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return tagMap;
|
2026-02-18 10:58:36 -08:00
|
|
|
});
|
|
|
|
|
|
2026-02-17 21:11:03 -08:00
|
|
|
/* Plugins */
|
2026-02-18 18:44:17 -08:00
|
|
|
/* All filters from _config/filters.js */
|
|
|
|
|
eleventyConfig.addPlugin(pluginFilters);
|
|
|
|
|
|
2026-02-17 21:11:03 -08:00
|
|
|
/* RSS */
|
|
|
|
|
eleventyConfig.addPlugin(feedPlugin, {
|
|
|
|
|
type: "atom", // or "rss", "json"
|
|
|
|
|
outputPath: "/feed.xml",
|
|
|
|
|
collection: {
|
|
|
|
|
name: "posts", // iterate over `collections.posts`
|
|
|
|
|
limit: 10, // 0 means no limit
|
|
|
|
|
},
|
|
|
|
|
metadata: {
|
|
|
|
|
language: "en",
|
|
|
|
|
title: "hello hello",
|
|
|
|
|
subtitle: "Lee Cattarin... on the internet!",
|
|
|
|
|
base: "https://leecat.art",
|
|
|
|
|
author: {
|
|
|
|
|
name: "Lee Cattarin",
|
|
|
|
|
email: "lee.cattarin@gmail.com",
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/* Images */
|
|
|
|
|
eleventyConfig.addPlugin(eleventyImageTransformPlugin, {
|
|
|
|
|
// output image formats
|
|
|
|
|
formats: ["auto"],
|
|
|
|
|
|
|
|
|
|
// output image widths
|
2026-02-18 18:44:17 -08:00
|
|
|
widths: [1000],
|
2026-02-17 21:11:03 -08:00
|
|
|
|
|
|
|
|
// optional, attributes assigned on <img> nodes override these values
|
|
|
|
|
htmlOptions: {
|
|
|
|
|
imgAttributes: {
|
|
|
|
|
loading: "lazy",
|
|
|
|
|
decoding: "async",
|
|
|
|
|
},
|
|
|
|
|
},
|
2026-02-19 17:54:01 -08:00
|
|
|
filenameFormat: function (id, src, width, format, options) {
|
|
|
|
|
return path.basename(src);
|
|
|
|
|
},
|
2026-02-17 21:11:03 -08:00
|
|
|
});
|
|
|
|
|
|
2026-02-18 10:58:36 -08:00
|
|
|
/* Navigation */
|
|
|
|
|
eleventyConfig.addPlugin(eleventyNavigationPlugin);
|
|
|
|
|
|
2026-02-19 12:07:10 -08:00
|
|
|
/* `id` attributes */
|
|
|
|
|
eleventyConfig.addPlugin(IdAttributePlugin);
|
|
|
|
|
|
2026-02-18 10:58:36 -08:00
|
|
|
/* Syntax highlighting */
|
|
|
|
|
eleventyConfig.addPlugin(syntaxHighlight);
|
|
|
|
|
|
2026-02-19 12:07:10 -08:00
|
|
|
/* Shortcodes */
|
|
|
|
|
eleventyConfig.addShortcode("currentBuildDate", () => {
|
|
|
|
|
return (new Date()).toISOString();
|
|
|
|
|
});
|
|
|
|
|
|
2026-02-17 21:11:03 -08:00
|
|
|
/* Watch when serving */
|
|
|
|
|
eleventyConfig.addWatchTarget("css");
|
2026-02-17 20:03:12 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const config = {
|
|
|
|
|
dir: {
|
2026-02-17 21:11:03 -08:00
|
|
|
input: "src",
|
|
|
|
|
includes: "../_includes",
|
2026-02-18 10:58:36 -08:00
|
|
|
layouts: "../_includes/layouts",
|
2026-02-17 21:11:03 -08:00
|
|
|
data: "../_data"
|
2026-02-17 20:03:12 -08:00
|
|
|
},
|
|
|
|
|
markdownTemplateEngine: "njk",
|
|
|
|
|
htmlTemplateEngine: "njk",
|
|
|
|
|
templateFormats: ["html", "md", "njk"],
|
|
|
|
|
};
|