2022-02-14 20:32:58 +00:00
|
|
|
import fs from 'fs';
|
2022-04-23 23:03:43 +00:00
|
|
|
import { getAllPosts } from './slug';
|
2022-02-14 20:32:58 +00:00
|
|
|
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;
|
|
|
|
}
|