Mirror of static site repo git.pfy.ch/pfych/static
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031import { resolve } from 'node:path';import { writeFile } from 'node:fs/promises';import { output, postsDirectory } from '../../config';import { createPostsObject, Post } from './create-post-object';import { ensureDirectoryExists } from '../../utils/ensure-directory-exists';import { globDirectory } from '../../utils/glob-directory';import { buildRSS } from '../indexes/rss';import { buildAll } from '../indexes/all';import { buildJSON } from '../indexes/json';
export const buildPost = async (post: Post) => { const outputDir = resolve(output, post.file.relativeFolder); await ensureDirectoryExists(outputDir); return writeFile( resolve(outputDir, `${post.file.fileName.replace('.md', '')}.html`), post.templatedContent, );};
export const buildPosts = async () => { const paths = await globDirectory('**/*.md', postsDirectory); const posts = await createPostsObject(paths, postsDirectory);
await Promise.all([ ...posts.map(buildPost), buildRSS(posts), buildAll(posts), buildJSON(posts), ]);};