summaryrefslogtreecommitdiffhomepage
path: root/services/blog/nuldoc-src/slide/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 /services/blog/nuldoc-src/slide/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 'services/blog/nuldoc-src/slide/parse.ts')
-rw-r--r--services/blog/nuldoc-src/slide/parse.ts20
1 files changed, 20 insertions, 0 deletions
diff --git a/services/blog/nuldoc-src/slide/parse.ts b/services/blog/nuldoc-src/slide/parse.ts
new file mode 100644
index 00000000..c5a89675
--- /dev/null
+++ b/services/blog/nuldoc-src/slide/parse.ts
@@ -0,0 +1,20 @@
+import { parse as parseToml } from "@std/toml";
+import {
+ createNewSlideFromMetadata,
+ Slide,
+ SlideMetadataSchema,
+} from "./slide.ts";
+
+export async function parseSlideFile(filePath: string): Promise<Slide> {
+ try {
+ const root = SlideMetadataSchema.parse(
+ parseToml(await Deno.readTextFile(filePath)),
+ );
+ return createNewSlideFromMetadata(root, filePath);
+ } catch (e) {
+ if (e instanceof Error) {
+ e.message = `${e.message} in ${filePath}`;
+ }
+ throw e;
+ }
+}