mirror of
https://git.tacowolf.net/TacoWolf/mestizo.monster.git
synced 2026-06-12 08:50:04 -04:00
47 lines
1.5 KiB
JavaScript
47 lines
1.5 KiB
JavaScript
import markdownIt from "markdown-it";
|
|
import footnote_plugin from "markdown-it-footnote";
|
|
import readingTime from "eleventy-plugin-reading-time";
|
|
|
|
/** @param {import("@11ty/eleventy").UserConfig} eleventyConfig */
|
|
export default async function (eleventyConfig) {
|
|
eleventyConfig.addPassthroughCopy({ assets: "/" });
|
|
eleventyConfig.addPassthroughCopy(".well-known");
|
|
eleventyConfig.addPassthroughCopy("**/*.jpg");
|
|
eleventyConfig.addPassthroughCopy("**/*.png");
|
|
|
|
eleventyConfig.addCollection("redirects", function (collectionApi) {
|
|
let redirects = [];
|
|
// get each post in our posts folder
|
|
const nodes = collectionApi.getFilteredByGlob("**/*.md");
|
|
// iterate over all the nodes
|
|
nodes.forEach((node) =>
|
|
// for each alias
|
|
(node.data.aliases || []).forEach((alias) =>
|
|
// push target url and the old url
|
|
redirects.push([
|
|
node.data.page.url,
|
|
node.data.page.url.replace(/\/[^\/]*?(\..+)?$/, `/${alias}$1`),
|
|
]),
|
|
),
|
|
);
|
|
return redirects;
|
|
});
|
|
|
|
function sortByDate(values) {
|
|
// inspired by
|
|
let vals = [...values];
|
|
return vals.sort((a, b) => {
|
|
return a.data.date < b.data.date ? 1 : -1;
|
|
});
|
|
}
|
|
eleventyConfig.addFilter("sortByDate", sortByDate);
|
|
|
|
let markdownItOptions = {
|
|
html: true,
|
|
breaks: true,
|
|
linkify: true,
|
|
};
|
|
eleventyConfig.setLibrary("md", markdownIt(markdownItOptions));
|
|
eleventyConfig.amendLibrary("md", (mdLib) => mdLib.use(footnote_plugin));
|
|
eleventyConfig.addPlugin(readingTime);
|
|
}
|