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
+9 -7
View File
@@ -1,7 +1,3 @@
import type {
FileData,
FileEncoding,
} from "../../common/spaces/space_primitives.ts";
import { renderToText, replaceNodesMatching } from "$sb/lib/tree.ts";
import type { FileMeta } from "../../common/types.ts";
import { parseMarkdown } from "$sb/silverbullet-syscall/markdown.ts";
@@ -11,8 +7,7 @@ export const cloudPrefix = "💭 ";
export async function readFileCloud(
name: string,
encoding: FileEncoding,
): Promise<{ data: FileData; meta: FileMeta } | undefined> {
): Promise<{ data: string; meta: FileMeta } | undefined> {
const originalUrl = name.substring(
cloudPrefix.length,
name.length - ".md".length,
@@ -43,7 +38,7 @@ export async function readFileCloud(
`${cloudPrefix}${originalUrl.split("/")[0]}/`,
);
return {
data: encoding === "utf8" ? text : base64EncodedDataUrl(
data: base64EncodedDataUrl(
"text/markdown",
new TextEncoder().encode(text),
),
@@ -57,6 +52,13 @@ export async function readFileCloud(
};
}
export function writeFileCloud(
name: string,
): Promise<FileMeta> {
console.log("Writing cloud file", name);
return getFileMetaCloud(name);
}
async function translateLinksWithPrefix(
text: string,
prefix: string,