summaryrefslogtreecommitdiffhomepage
path: root/vhosts/blog/nuldoc-src/slide/parse.ts
blob: b880ef0ad8194046b83e1e6b1a9a896358ac4cb9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { parse as parseToml } from "std/encoding/toml.ts";
import { Config } from "../config.ts";
import { createNewSlideFromTomlRootObject, Slide } from "./slide.ts";

export async function parseSlideFile(
  filePath: string,
  config: Config,
): Promise<Slide> {
  try {
    // TODO runtime assertion
    const root = parseToml(await Deno.readTextFile(filePath)) as {
      slide: {
        uuid: string;
        title: string;
        event: string;
        talkType: string;
        link: string;
        tags: string[];
        revisions: {
          date: string;
          remark: string;
          isInternal?: boolean;
        }[];
      };
    };
    return createNewSlideFromTomlRootObject(root, filePath, config);
  } catch (e) {
    e.message = `${e.message} in ${filePath}`;
    throw e;
  }
}