feat: Added head filter
This commit is contained in:
@ -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
10
src/_config/filters.js
Normal 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];
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user