Complete redo of content indexing and querying (#517)

Complete redo of data store
Introduces live queries and live templates
This commit is contained in:
Zef Hemel
2023-10-03 14:16:33 +02:00
committed by GitHub
parent 7af98e7c7b
commit 0313565610
200 changed files with 4675 additions and 4363 deletions
+2 -2
View File
@@ -22,7 +22,7 @@ Deno.test("Markdown render", async () => {
new URL("test/example.md", import.meta.url).pathname,
);
const tree = parse(lang, testFile);
await renderMarkdownToHtml(tree, {
renderMarkdownToHtml(tree, {
failOnUnknown: true,
});
// console.log("HTML", html);
@@ -34,7 +34,7 @@ Deno.test("Smart hard break test", async () => {
*world!*`;
const lang = buildMarkdown([]);
const tree = parse(lang, example);
const html = await renderMarkdownToHtml(tree, {
const html = renderMarkdownToHtml(tree, {
failOnUnknown: true,
smartHardBreak: true,
});
+23 -4
View File
@@ -1,4 +1,5 @@
import {
collectNodesOfType,
findNodeOfType,
ParseTree,
renderToText,
@@ -115,9 +116,13 @@ function render(
case "FencedCode":
case "CodeBlock": {
// Clear out top-level indent blocks
const lang = findNodeOfType(t, "CodeInfo");
t.children = t.children!.filter((c) => c.type);
return {
name: "pre",
attrs: {
"data-lang": lang ? lang.children![0].text : undefined,
},
body: cleanTags(mapRender(t.children!)),
};
}
@@ -235,6 +240,7 @@ function render(
name: "a",
attrs: {
href: `/${ref.replace("@", "#")}`,
"data-ref": ref,
},
body: linkText,
};
@@ -255,12 +261,25 @@ function render(
body: t.children![0].text!,
};
case "Task":
case "Task": {
let externalTaskRef = "";
collectNodesOfType(t, "WikiLinkPage").forEach((wikilink) => {
const ref = wikilink.children![0].text!;
if (!externalTaskRef && ref.includes("@")) {
externalTaskRef = ref;
}
});
return {
name: "span",
attrs: externalTaskRef
? {
"data-external-task-ref": externalTaskRef,
}
: {},
body: cleanTags(mapRender(t.children!)),
};
}
case "TaskState": {
// child[0] = marker, child[1] = state, child[2] = marker
const stateText = t.children![1].text!;
@@ -269,8 +288,8 @@ function render(
name: "input",
attrs: {
type: "checkbox",
checked: t.children![0].text !== "[ ]" ? "checked" : undefined,
"data-onclick": JSON.stringify(["task", t.to]),
checked: stateText !== " " ? "checked" : undefined,
"data-state": stateText,
},
body: "",
};
+1 -1
View File
@@ -12,7 +12,7 @@ export async function markdownWidget(
});
return Promise.resolve({
html: html,
script: `updateHeight();
script: `
document.addEventListener("click", () => {
api({type: "blur"});
});`,