mirror of
https://github.com/geoffsee/open-gsio.git
synced 2025-09-08 22:56:46 +00:00
20 lines
506 B
TypeScript
20 lines
506 B
TypeScript
import { visit } from "unist-util-visit";
|
|
|
|
export default function remarkImageGeneration() {
|
|
return (tree) => {
|
|
visit(tree, "code", (node, index, parent) => {
|
|
if (node.lang === "generation") {
|
|
try {
|
|
const data = JSON.parse(node.value);
|
|
parent.children[index] = {
|
|
type: "generation",
|
|
data: data,
|
|
};
|
|
} catch (error) {
|
|
console.error("Invalid JSON in image-generation block:", error);
|
|
}
|
|
}
|
|
});
|
|
};
|
|
}
|