| 123456789101112131415161718192021 |
- import fs from "fs/promises"
- import matter from "gray-matter"
- import { getHref, slugifyString } from "../../util/index.js"
- import { createMarkdownRenderer } from "../_shared/markdown.js"
- export async function renderMarkdownToHtml({ config: actionConfig, meta }) {
- const filePath = actionConfig.filePath
- const fileOutputPath = actionConfig.fileOutputPath
- const content = await fs.readFile(filePath, "utf8")
- const { data, content: markdown } = matter(content)
- const href = getHref(fileOutputPath, meta)
- const renderer = createMarkdownRenderer(meta)
- const html = renderer(markdown)
- const detail = { ...data, href, content: html, fileOutputPath }
- return {
- detail,
- ref: slugifyString(filePath),
- }
- }
|