Files
CyBySide/eleventy.config.js
2025-07-06 00:59:24 -04:00

71 lines
1.9 KiB
JavaScript

/** @param {import("@11ty/eleventy").UserConfig} eleventyConfig */
export default async function(eleventyConfig) {
eleventyConfig.addPassthroughCopy(
{'./public/': '/'}
);
eleventyConfig.addShortcode("triangleSvg", function(strokeWidth = 10) {
const w = parseFloat(strokeWidth);
if (isNaN(w) || w <= 0) {
throw new Error("strokeWidth must be a positive number");
}
// Scale offsets based on strokeWidth
const topInset = +(w * 1.05).toFixed(2);
const bottomInset = +(w * 0.5).toFixed(2);
const sideInset = +(w * 0.8).toFixed(2);
const topPoint = `50,${topInset}`;
const leftPoint = `${sideInset},${100 - bottomInset}`;
const rightPoint = `${100 - sideInset},${100 - bottomInset}`;
const points = `${topPoint} ${leftPoint} ${rightPoint}`;
return `
<svg viewBox="0 0 100 100" width="100%" height="100%" preserveAspectRatio="xMidYMid meet" aria-hidden="true" focusable="false">
<polygon
points="${points}"
fill="none"
stroke="currentColor"
stroke-width="${w}"
stroke-linejoin="miter"
/>
</svg>`;
});
eleventyConfig.addShortcode("squareSvg", function(strokeWidth = 10, className = "square") {
const w = parseFloat(strokeWidth);
if (isNaN(w) || w <= 0) {
throw new Error("strokeWidth must be a positive number");
}
const inset = +(w / 2).toFixed(2);
const x1 = inset;
const y1 = inset;
const x2 = 100 - inset;
const y2 = 100 - inset;
return `
<svg
class="${className}"
viewBox="0 0 100 100"
width="100%"
height="100%"
preserveAspectRatio="xMidYMid meet"
aria-hidden="true"
focusable="false"
>
<rect
class="${className}__shape"
x="${x1}"
y="${y1}"
width="${(x2 - x1).toFixed(2)}"
height="${(y2 - y1).toFixed(2)}"
stroke="currentColor"
fill="none"
stroke-width="${w}"
stroke-linejoin="miter"
/>
</svg>`;
});
}