From e23c03ca252788dc3d7a5b3470b23e6ae560625d Mon Sep 17 00:00:00 2001 From: Amir Pourmand Date: Sun, 24 Aug 2025 17:12:04 +0330 Subject: [PATCH] Refactor footnotes transformer for improved localization handling - Cleaned up code formatting for better readability. - Ensured proper localization of footnote titles by replacing text nodes with localized values. - Removed unnecessary class names from headings to enhance accessibility. --- quartz/plugins/transformers/footnotes.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/quartz/plugins/transformers/footnotes.ts b/quartz/plugins/transformers/footnotes.ts index ca1d4fb2b..d697ef7c4 100644 --- a/quartz/plugins/transformers/footnotes.ts +++ b/quartz/plugins/transformers/footnotes.ts @@ -12,25 +12,25 @@ export const LocalizedFootnotes: QuartzTransformerPlugin = () => { return (tree: Root) => { const cfg = ctx.cfg.configuration const locale = i18n(cfg.locale) - + visit(tree, "element", (node: Element) => { // Find footnotes section if (node.tagName === "section" && node.properties?.["dataFootnotes"] !== undefined) { // Find the h2 heading inside - const heading = node.children.find(child => - child.type === "element" && child.tagName === "h2" + const heading = node.children.find( + (child) => child.type === "element" && child.tagName === "h2", ) as Element - + if (heading) { // Remove sr-only class if present if (Array.isArray(heading.properties?.className)) { heading.properties.className = heading.properties.className.filter( - cls => cls !== "sr-only" + (cls) => cls !== "sr-only", ) } - + // Replace the first text node with localized text - const textNode = heading.children.find(child => child.type === "text") + const textNode = heading.children.find((child) => child.type === "text") if (textNode) { textNode.value = locale.components.footnotes.title }