Use images for github callout icons #1

This commit is contained in:
Vojta committed 2025-06-09 21:02:08 +02:00
1 parent cf19330257
commit 268f506a9c
12 files changed
+63 -34

No files matched your search

-25
View File
@@ -1,25 +0,0 @@
import { visit } from 'unist-util-visit';
export default function rehypeCustomFootnotes() {
return (tree: any) => {
visit(tree, 'element', (node) => {
if (
node.tagName === 'h2' &&
node.properties?.id === 'footnote-label'
) {
node.children[0].value = 'Zdroje'; // Change heading text
}
if (
node.tagName === 'span' &&
node.properties?.className?.includes('sr-only') &&
node.children?.[0]?.value?.startsWith('Section titled')
) {
node.children[0].remove;
}
});
};
}
+34
View File
@@ -0,0 +1,34 @@
import { visit } from 'unist-util-visit';
export default function rehypeCustomization() {
return (tree: any) => {
visit(tree, 'element', (node) => {
// Change the footnotes heading text (hard-wired to "Footnotes")
// by Astro or remark (not sure)
if (
node.tagName === 'h2' &&
node.properties?.id === 'footnote-label'
) {
node.children[0].value = 'Zdroje';
}
// Embed SVG icons instead of using inline style supplying data url
if (
node.tagName === 'span' &&
node.properties?.class?.includes("octicon")
) {
let octicon_kind = node.properties.class.split(" ")[1]
node.tagName = "img"
node.properties.src = `/icons/${octicon_kind}.svg`
node.properties.alt = octicon_kind
node.properties.class = `custom-octicon`
node.properties.style = ""
}
});
};
}
+11
View File
@@ -41,3 +41,14 @@ img[alt="width=700"] {
width: 700px;
margin: auto;
}
/* Github callout icons */
.custom-octicon {
margin-right: .5rem;
overflow: visible !important;
display: inline-block;
vertical-align: text-bottom;
width: 1em;
height: 1em;
}