2025-06-11 09:36:54 +03:00
|
|
|
import markdownIt from "markdown-it";
|
|
|
|
|
import markdownItAnchor from "markdown-it-anchor";
|
2026-04-07 11:43:33 +03:00
|
|
|
import slugify from "slugify";
|
2025-06-11 09:36:54 +03:00
|
|
|
import { format } from "date-fns";
|
|
|
|
|
|
|
|
|
|
export default async function (eleventyConfig) {
|
2026-04-07 11:43:33 +03:00
|
|
|
/*
|
|
|
|
|
|
|
|
|
|
const linkAfterHeader = markdownItAnchor.permalink.linkAfterHeader({
|
|
|
|
|
class: "anchor",
|
|
|
|
|
symbol: "<span hidden>#</span>",
|
|
|
|
|
style: "aria-labelledby",
|
|
|
|
|
});
|
|
|
|
|
const markdownItAnchorOptions = {
|
|
|
|
|
level: [1, 2, 3],
|
|
|
|
|
slugify: (str) =>
|
|
|
|
|
slugify(str, {
|
|
|
|
|
lower: true,
|
|
|
|
|
strict: true,
|
|
|
|
|
remove: /["]/g,
|
|
|
|
|
}),
|
|
|
|
|
tabIndex: false,
|
|
|
|
|
permalink(slug, opts, state, idx) {
|
|
|
|
|
state.tokens.splice(
|
|
|
|
|
idx,
|
|
|
|
|
0,
|
|
|
|
|
Object.assign(new state.Token("div_open", "div", 1), {
|
|
|
|
|
// Add class "header-wrapper [h1 or h2 or h3]"
|
|
|
|
|
attrs: [["class", `heading-wrapper ${state.tokens[idx].tag}`]],
|
|
|
|
|
block: true,
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
state.tokens.splice(
|
|
|
|
|
idx + 4,
|
|
|
|
|
0,
|
|
|
|
|
Object.assign(new state.Token("div_close", "div", -1), {
|
|
|
|
|
block: true,
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
linkAfterHeader(slug, opts, state, idx + 1);
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
let markdownLibrary = markdownIt({
|
|
|
|
|
html: true,
|
|
|
|
|
}).use(markdownItAnchor, markdownItAnchorOptions);
|
|
|
|
|
eleventyConfig.setLibrary("md", markdownLibrary);
|
|
|
|
|
|
|
|
|
|
*/
|
2025-06-11 09:36:54 +03:00
|
|
|
const assets = "./_src/assets/";
|
|
|
|
|
eleventyConfig.addPassthroughCopy(assets);
|
|
|
|
|
eleventyConfig.addWatchTarget(assets);
|
|
|
|
|
eleventyConfig.addFilter("sortByFirstDate", items => items.sort((a, b) => new Date(b.data.images[0].date) - new Date(a.data.images[0].date)));
|
2025-10-19 15:55:35 +03:00
|
|
|
eleventyConfig.addFilter("link", function(text, url) {
|
2026-04-07 20:14:23 +03:00
|
|
|
return `<a href="${url}"><img src="https://www.google.com/s2/favicons?domain=${url}" alt=""/>${text}</a>`;
|
2025-10-19 15:55:35 +03:00
|
|
|
});
|
2025-06-11 09:36:54 +03:00
|
|
|
eleventyConfig.addFilter("ISO", (dateObj) => {
|
|
|
|
|
return format(dateObj, ("yyyy-LL-dd"));
|
|
|
|
|
});
|
|
|
|
|
eleventyConfig.addFilter("readable", (dateObj) => {
|
2025-09-09 18:12:57 +03:00
|
|
|
return format(dateObj, ("LLLL do, yyyy"));
|
2025-06-11 09:36:54 +03:00
|
|
|
});
|
|
|
|
|
eleventyConfig.setBrowserSyncConfig({
|
|
|
|
|
open: true,
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const config = {
|
|
|
|
|
dir: {
|
|
|
|
|
input: "_src",
|
|
|
|
|
output: "_site"
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|