resolver rework
This commit is contained in:
@@ -8,7 +8,15 @@ export function Resolver({ resolver }: { resolver: string }) {
|
||||
const [res] = useState(new TTCQueryResolver(parser));
|
||||
const [content, setContent] = useState<ReactNode>("");
|
||||
useEffect(() => {
|
||||
setContent(res.resolve(resolver));
|
||||
let resolved = res.resolve(resolver);
|
||||
|
||||
setContent(
|
||||
typeof resolved?.display === "function" ? (
|
||||
<resolved.display />
|
||||
) : (
|
||||
resolved?.display
|
||||
)
|
||||
);
|
||||
}, [resolver, res]);
|
||||
return <span>{content}</span>;
|
||||
}
|
||||
@@ -31,8 +39,9 @@ export function OnDemandResolver({
|
||||
for (const idx of stackIdxs) {
|
||||
let thing = res.current.getFromStack(idx);
|
||||
if (Array.isArray(thing)) thing = thing.at(0);
|
||||
if (typeof thing === "function") thing = thing();
|
||||
content = content.replaceAll(idx, thing as string);
|
||||
if (typeof thing.display === "function")
|
||||
content = content.replaceAll(idx, thing.display() as string);
|
||||
else content = content.replaceAll(idx, thing.display as string);
|
||||
}
|
||||
setContent(content);
|
||||
}, [res, template]);
|
||||
|
Reference in New Issue
Block a user