SilverBullet pivot to become an offline-first PWA (#403)

This commit is contained in:
Zef Hemel
2023-05-23 20:53:53 +02:00
committed by GitHub
parent b256269897
commit 5f484bed57
389 changed files with 4484 additions and 291129 deletions
+2 -30
View File
@@ -4,14 +4,12 @@ import {
renderToText,
traverseTree,
} from "$sb/lib/tree.ts";
import * as YAML from "yaml";
import { Fragment, renderHtml, Tag } from "./html_render.ts";
type MarkdownRenderOptions = {
failOnUnknown?: true;
smartHardBreak?: true;
annotationPositions?: true;
renderFrontMatter?: true;
attachmentUrlPrefix?: string;
// When defined, use to inline images as data: urls
inlineAttachments?: (url: string) => Promise<string>;
@@ -78,33 +76,7 @@ function render(
body: cleanTags(mapRender(t.children!)),
};
case "FrontMatter":
if (options.renderFrontMatter) {
const yamlCode = renderToText(t.children![1]);
const parsedYaml = YAML.parse(yamlCode) as Record<string, any>;
const rows: Tag[] = [];
for (const [k, v] of Object.entries(parsedYaml)) {
rows.push({
name: "tr",
body: [
{ name: "td", attrs: { class: "key" }, body: k },
{
name: "td",
attrs: { class: "value" },
body: YAML.stringify(v),
},
],
});
}
return {
name: "table",
attrs: {
class: "front-matter",
},
body: rows,
};
} else {
return null;
}
return null;
case "CommentBlock":
// Remove, for now
return null;
@@ -261,7 +233,7 @@ function render(
return {
name: "a",
attrs: {
href: `/${ref.replaceAll(" ", "_").replace("@", "#")}`,
href: `/${ref.replace("@", "#")}`,
},
body: linkText,
};