main
1import type { RehypePlugin } from "@astrojs/markdown-remark";
2import { visit } from "unist-util-visit";
3
4// Feed readers load neither the site's stylesheets nor its scripts, so
5// attributes that only serve them are dropped.
6export const rehypeCleanProperties: RehypePlugin = () => (tree) => {
7 visit(tree, "element", (node) => {
8 if (node.properties.class) {
9 delete node.properties.class;
10 }
11 for (const key of Object.keys(node.properties)) {
12 if (key.startsWith("data-")) {
13 delete node.properties[key];
14 }
15 }
16 if (node.properties.style) {
17 delete node.properties.style;
18 }
19 });
20};