main
1import type { RehypePlugin } from "@astrojs/markdown-remark";
2import { visit } from "unist-util-visit";
3
4// Clean auto generated endnote, because we generate sidenotes instead.
5export const rehypeCleanEndnotes: RehypePlugin = () => (tree) => {
6 visit(tree, "element", (node, index, parent) => {
7 if (
8 node.tagName === "section" &&
9 node.properties.role === "doc-endnotes" &&
10 parent &&
11 typeof index === "number"
12 ) {
13 parent.children.splice(index, 1);
14 }
15 });
16};