Seed from NAS prod snapshot 20260130-190531
All checks were successful
CI / build-and-anchors (push) Successful in 1m25s
SMOKE / smoke (push) Successful in 11s
CI / build-and-anchors (pull_request) Successful in 1m20s

This commit is contained in:
archicratia
2026-01-31 10:51:38 +00:00
commit 60d88939b0
142 changed files with 33443 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
import { visit } from "unist-util-visit";
import crypto from "node:crypto";
function toText(node) {
if (!node) return "";
if (node.type === "text") return node.value || "";
const children = node.children || [];
return children.map(toText).join("");
}
export default function rehypeParagraphIds() {
return (tree) => {
let i = 0;
visit(tree, "element", (node) => {
if (node.tagName !== "p") return;
const text = toText(node).trim();
if (!text) return;
const norm = text.replace(/\s+/g, " ").toLowerCase();
const hash = crypto.createHash("sha1").update(norm).digest("hex").slice(0, 8);
node.properties = node.properties || {};
if (!node.properties.id) node.properties.id = `p-${i}-${hash}`;
i += 1;
});
};
}