www/lib/read-markdown.ts
Paul W. 35d56f5cde
Bump script ver and refactor md metadata gen
Signed-off-by: Paul W. <lambdapaul@protonmail.com>
2023-10-30 00:18:38 -04:00

10 lines
409 B
TypeScript

import { readFile } from 'fs/promises';
import path from 'path';
export default async function readMarkdown(directory: string, slug: string, withoutTitle: boolean = false): Promise<string> {
const content = await readFile(path.join(process.cwd(), directory, `${slug}.md`), 'utf-8');
if (withoutTitle)
return content.substring(content.indexOf('\n') + 1, content.length);
return content;
}