feat: Added head filter

This commit is contained in:
2025-08-03 03:20:42 -04:00
parent eca0aad00e
commit 07af321fda
2 changed files with 13 additions and 0 deletions

View File

@ -1,4 +1,5 @@
import { feedPlugin } from "@11ty/eleventy-plugin-rss";
import filtersPlugin from "./src/_config/filters.js";
/** @param {import("@11ty/eleventy").UserConfig} eleventyConfig */
export default async function(eleventyConfig) {
@ -24,6 +25,8 @@ export default async function(eleventyConfig) {
}
});
eleventyConfig.addPlugin(filtersPlugin);
eleventyConfig.addShortcode("triangleSvg", function(strokeWidth = 10) {
const w = parseFloat(strokeWidth);
if (isNaN(w) || w <= 0) {

10
src/_config/filters.js Normal file
View File

@ -0,0 +1,10 @@
export default function(eleventyConfig) {
// Get the first element of a collection.
eleventyConfig.addFilter("head", (array) => {
if(!Array.isArray(array) || array.length === 0) {
return null;
}
return array[0];
});
};