Rebuilt frontmatter templates as template widgets
This commit is contained in:
@@ -36,8 +36,13 @@ export async function expandCodeWidgets(
|
||||
renderToText(codeTextNode!),
|
||||
pageName,
|
||||
);
|
||||
if (!result) {
|
||||
return {
|
||||
text: "",
|
||||
};
|
||||
}
|
||||
// Only do this for "markdown" widgets, that is: that can render to markdown
|
||||
if (result.markdown) {
|
||||
if (result.markdown !== undefined) {
|
||||
const parsedBody = await parseMarkdown(result.markdown);
|
||||
// Recursively process
|
||||
return expandCodeWidgets(
|
||||
|
||||
@@ -29,7 +29,3 @@ functions:
|
||||
path: "./preview.ts:previewClickHandler"
|
||||
events:
|
||||
- preview:click
|
||||
|
||||
markdownWidget:
|
||||
path: ./widget.ts:markdownWidget
|
||||
codeWidget: markdown
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
import { markdown } from "$sb/syscalls.ts";
|
||||
import type { WidgetContent } from "$sb/app_event.ts";
|
||||
import { renderMarkdownToHtml } from "./markdown_render.ts";
|
||||
|
||||
export async function markdownWidget(
|
||||
bodyText: string,
|
||||
): Promise<WidgetContent> {
|
||||
const mdTree = await markdown.parseMarkdown(bodyText);
|
||||
|
||||
const html = renderMarkdownToHtml(mdTree, {
|
||||
smartHardBreak: true,
|
||||
});
|
||||
return Promise.resolve({
|
||||
html: html,
|
||||
script: `
|
||||
document.addEventListener("click", () => {
|
||||
api({type: "blur"});
|
||||
});`,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user