refactor: remove some duplicated code
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { unified } from "npm:unified";
|
||||
import remarkParse from "npm:remark-parse";
|
||||
import { unified } from "https://esm.sh/unified";
|
||||
import remarkParse from "https://esm.sh/remark-parse";
|
||||
import remarkStringify from "https://esm.sh/remark-stringify@10.0.3";
|
||||
import remarkFrontmatter, {
|
||||
Root,
|
||||
@@ -7,10 +7,8 @@ import remarkFrontmatter, {
|
||||
import remarkRehype from "https://esm.sh/remark-rehype@10.1.0";
|
||||
import rehypeSanitize from "https://esm.sh/rehype-sanitize@5.0.1";
|
||||
import rehypeStringify from "https://esm.sh/rehype-stringify@9.0.3";
|
||||
import { parse } from "https://deno.land/std@0.194.0/yaml/mod.ts";
|
||||
import * as cache from "@lib/cache/documents.ts";
|
||||
|
||||
const SILVERBULLET_SERVER = Deno.env.get("SILVERBULLET_SERVER");
|
||||
import { SILVERBULLET_SERVER } from "@lib/env.ts";
|
||||
|
||||
export type Document = {
|
||||
name: string;
|
||||
@@ -20,10 +18,6 @@ export type Document = {
|
||||
perm: string;
|
||||
};
|
||||
|
||||
export function parseFrontmatter(yaml: string) {
|
||||
return parse(yaml);
|
||||
}
|
||||
|
||||
export async function getDocuments(): Promise<Document[]> {
|
||||
const cachedDocuments = await cache.getDocuments();
|
||||
if (cachedDocuments) return cachedDocuments;
|
||||
@@ -31,7 +25,7 @@ export async function getDocuments(): Promise<Document[]> {
|
||||
const headers = new Headers();
|
||||
headers.append("Accept", "application/json");
|
||||
|
||||
const response = await fetch(SILVERBULLET_SERVER + "/index.json", {
|
||||
const response = await fetch(`${SILVERBULLET_SERVER}/index.json`, {
|
||||
headers: headers,
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user