Use images for github callout icons #1
This commit is contained in:
1 parent
cf19330257
commit
268f506a9c
12 files changed
+63
-34
No files matched your search
@@ -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 = ""
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user