HTTP Caching

This commit is contained in:
Zef Hemel
2022-10-21 16:56:46 +02:00
parent 09b20cadd8
commit dc32ca81a9
4 changed files with 40 additions and 12 deletions
+10 -4
View File
@@ -5,12 +5,13 @@ import type {
import { renderToText, replaceNodesMatching } from "$sb/lib/tree.ts";
import type { FileMeta } from "../../common/types.ts";
import { parseMarkdown } from "$sb/silverbullet-syscall/markdown.ts";
import { base64EncodedDataUrl } from "../../plugos/asset_bundle/base64.ts";
const pagePrefix = "💭 ";
export async function readFileCloud(
name: string,
_encoding: FileEncoding,
encoding: FileEncoding,
): Promise<{ data: FileData; meta: FileMeta } | undefined> {
const originalUrl = name.substring(
pagePrefix.length,
@@ -36,10 +37,15 @@ export async function readFileCloud(
console.error("ERROR", e.message);
text = e.message;
}
text = await translateLinksWithPrefix(
text,
`${pagePrefix}${originalUrl.split("/")[0]}/`,
);
console.log("Got this", text);
return {
data: await translateLinksWithPrefix(
text,
`${pagePrefix}${originalUrl.split("/")[0]}/`,
data: encoding === "string" ? text : base64EncodedDataUrl(
"text/markdown",
new TextEncoder().encode(text),
),
meta: {
name,