import { readFileSync } from "fs";
import matter from "gray-matter";

type Frontmatter<I extends string | Buffer> = {
    data: Partial<{
        title: string
        date: number[]
        hidden: boolean
        draft: boolean
    }>
    content: string
    excerpt?: string
    orig: Buffer | I
    language: string
    matter: string
    stringify(lang: string): string
}

export default function (path: string): Frontmatter<string> {
    return matter(readFileSync(path, 'utf8'))

}