Refactoring about how proxy fetching happens

This commit is contained in:
Zef Hemel
2023-08-23 19:08:21 +02:00
parent 38a95d2382
commit 5a88254cde
18 changed files with 320 additions and 93 deletions
+5 -5
View File
@@ -33,11 +33,11 @@ export async function indexLinks({ name, tree }: IndexTreeEvent) {
pageMeta[k] = v;
}
// Don't index meta data starting with $
// for (const key in pageMeta) {
// if (key.startsWith("$")) {
// delete pageMeta[key];
// }
// }
for (const key in pageMeta) {
if (key.startsWith("$")) {
delete pageMeta[key];
}
}
// console.log("Extracted page meta data", pageMeta);
await index.set(name, "meta:", pageMeta);
}
+9
View File
@@ -357,6 +357,15 @@ function render(
};
}
return null;
case "Escape": {
return {
name: "span",
attrs: {
class: "escape",
},
body: t.children![0].text!.slice(1),
};
}
// Text
case undefined:
return t.text!;
+3 -11
View File
@@ -8,20 +8,15 @@ export async function publishCommand() {
const text = await editor.getText();
const pageName = await editor.getCurrentPage();
const tree = await markdown.parseMarkdown(text);
const { $share } = await extractFrontmatter(tree);
let { $share } = await extractFrontmatter(tree);
if (!$share) {
await editor.flashNotification("Saved.");
// Nothing to do here
return;
}
if (!Array.isArray($share)) {
await editor.flashNotification(
"$share front matter must be an array.",
"error",
);
return;
$share = [$share];
}
await editor.flashNotification("Sharing...");
// Delegate actual publishing to the server
try {
await publish(pageName, $share);
await editor.flashNotification("Done!");
@@ -31,9 +26,6 @@ export async function publishCommand() {
}
async function publish(pageName: string, uris: string[]) {
if (!Array.isArray(uris)) {
uris = [uris];
}
for (const uri of uris) {
const publisher = uri.split(":")[0];
const results = await events.dispatchEvent(