Files
open-gsio/src/components/chat/remarkImageGeneration.ts
geoffsee 33679583af init
2025-05-22 23:14:01 -04:00

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);
}
}
});
};
}