@astrojs/mdx
Version:
Add support for MDX pages in your Astro site
13 lines (12 loc) • 342 B
JavaScript
import { jsToTreeNode } from "./utils.js";
function rehypeInjectHeadingsExport() {
return function(tree, file) {
const headings = file.data.astro?.headings ?? [];
tree.children.unshift(
jsToTreeNode(`export function getHeadings() { return ${JSON.stringify(headings)} }`)
);
};
}
export {
rehypeInjectHeadingsExport
};