summaryrefslogtreecommitdiffhomepage
path: root/vhosts/blog/nuldoc-src/djot/parse.ts
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2025-06-27 23:39:31 +0900
committernsfisis <nsfisis@gmail.com>2025-06-27 23:39:31 +0900
commit674fe965550444db87edc7937ff6932e1a918d9d (patch)
treee8a80dd958d3e082485286bf5785a7992b6e6b0e /vhosts/blog/nuldoc-src/djot/parse.ts
parentfe4d1d625b53796c5f20399790e5ff8c7a7e1608 (diff)
downloadnsfisis.dev-674fe965550444db87edc7937ff6932e1a918d9d.tar.gz
nsfisis.dev-674fe965550444db87edc7937ff6932e1a918d9d.tar.zst
nsfisis.dev-674fe965550444db87edc7937ff6932e1a918d9d.zip
feat(meta): rename vhosts/ directory to services/
Diffstat (limited to 'vhosts/blog/nuldoc-src/djot/parse.ts')
-rw-r--r--vhosts/blog/nuldoc-src/djot/parse.ts33
1 files changed, 0 insertions, 33 deletions
diff --git a/vhosts/blog/nuldoc-src/djot/parse.ts b/vhosts/blog/nuldoc-src/djot/parse.ts
deleted file mode 100644
index c79a6708..00000000
--- a/vhosts/blog/nuldoc-src/djot/parse.ts
+++ /dev/null
@@ -1,33 +0,0 @@
-import { parse as parseDjot } from "@djot/djot";
-import { parse as parseToml } from "@std/toml";
-import { Config } from "../config.ts";
-import {
- createNewDocumentFromDjotDocument,
- Document,
- PostMetadata,
- PostMetadataSchema,
-} from "./document.ts";
-import toHtml from "./to_html.ts";
-
-export async function parseDjotFile(
- filePath: string,
- config: Config,
-): Promise<Document> {
- try {
- const fileContent = await Deno.readTextFile(filePath);
- const [, frontmatter, ...rest] = fileContent.split(/^---$/m);
- const meta = parseMetadata(frontmatter);
- const root = parseDjot(rest.join("\n"));
- const doc = createNewDocumentFromDjotDocument(root, meta, filePath, config);
- return await toHtml(doc);
- } catch (e) {
- if (e instanceof Error) {
- e.message = `${e.message} in ${filePath}`;
- }
- throw e;
- }
-}
-
-function parseMetadata(s: string): PostMetadata {
- return PostMetadataSchema.parse(parseToml(s));
-}