Hello. While working with MDX, I discovered that Astro's built-in remark/rehype plugins do not pass code block metastrings (e.g. title="file.js") as properties down to final html components. I've tried to create remark/rehype plugins, but once rehype plugin is executed, metastring data is lost. Is there a proper/convenient way to preserve such data to pass it as properties?
The only way I can think of to do it is very hacky:
let metaIdx = 0;
let metastrings: string[] = [];
export default defineConfig({
markdown: {
remarkPlugins: [() => (root) => {
metaIdx = 0;
metastrings = [];
visit(root, 'code', (node) => {
metastrings.push(node.meta);
});
}],
rehypePlugins: [() => (root) => visit(root, 'pre', (node) => {
const idx = metaIdx++;
node.properties.metastring = metastrings[idx];
})],
},
});