mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-20 11:24:05 -06:00
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.
This commit is contained in:
parent
09b4f072be
commit
e23c03ca25
@ -17,20 +17,20 @@ export const LocalizedFootnotes: QuartzTransformerPlugin = () => {
|
||||
// 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
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user