UNPKG

fumadocs-core

Version:

The React.js library for building a documentation website

25 lines (24 loc) • 782 B
import { d as walk } from "../utils-C7sTEOQI.js"; import { t as groupSteps } from "../steps-CGouhZm4.js"; import { replaceSource } from "./stringifier.js"; // src/mdx-plugins/remark-steps.ts /** * Convert headings in the format of `1. Hello World` into steps. */ function remarkSteps({ steps = "fd-steps", step = "fd-step" } = {}) { return (tree, file) => { walk(tree, (parent) => { if (!("children" in parent) || parent.type === "heading") return "skip"; const children = groupSteps(parent.children, { steps, step, set(node, key, value) { node[key] = value; }, searchSource: (node, text) => replaceSource(file, node, (s) => text(s.stringify(node)), "search") }); if (children) parent.children = children; }); }; } export { remarkSteps };