import fs from "fs";
import matter from "gray-matter";
import { remark } from "remark";
import remarkGfm from "remark-gfm";
import remarkRehype from "remark-rehype";
import rehypeShiki from "@shikijs/rehype";
import rehypeStringify from "rehype-stringify";
import {
  extractOrderFromFilename,
  cleanFilename,
  slugToTitle
} from "./utils";
async function parseMarkdownFile(filePath) {
  const fileContent = fs.readFileSync(filePath, "utf-8");
  const { data, content } = matter(fileContent);
  const processedContent = await remark().use(remarkGfm).use(remarkRehype, { allowDangerousHtml: true }).use(rehypeShiki, { theme: "github-dark" }).use(rehypeStringify, { allowDangerousHtml: true }).process(content);
  return {
    metadata: data,
    content,
    html: processedContent.toString()
  };
}
export {
  cleanFilename,
  extractOrderFromFilename,
  parseMarkdownFile,
  slugToTitle
};
