www/util/post-cache.ts
Paul bfacb23f8a Add posts and old grade-calc
Fix small bugs
>bad commit
2022-02-14 15:32:58 -05:00

14 lines
404 B
TypeScript

import fs from 'fs';
import { getAllPosts } from '../lib/slug';
import { join } from 'path';
const publicDir = join(process.cwd(), 'public');
export default function cachePostLinkData() {
const posts = getAllPosts(['title', 'slug', 'last_updated']);
fs.writeFile(`${publicDir}/posts.json`, JSON.stringify(posts), (e) => {
if (e)
console.error(e);
});
return posts;
}