From 6c999dbabf82c32dd7b9e5a18c73ed42b68e4e28 Mon Sep 17 00:00:00 2001 From: Paul Date: Wed, 27 Apr 2022 06:28:15 -0400 Subject: [PATCH] Change gen dir for deploy purposes --- components/fuzzy-bar.tsx | 2 +- util/slug.js | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/components/fuzzy-bar.tsx b/components/fuzzy-bar.tsx index 8a0bca2..7752408 100644 --- a/components/fuzzy-bar.tsx +++ b/components/fuzzy-bar.tsx @@ -3,7 +3,7 @@ import Fuzzy from './_fuzzy'; import pages from '../public/pages.json'; import style from '../styles/fuzzy.module.css'; // @ts-ignore -import posts from '../public/posts.json' // I do not like this +import posts from '../posts/meta.json' // I do not like this function FuzzyBar(): JSX.Element { const searchField = useRef(null); diff --git a/util/slug.js b/util/slug.js index bdd48bb..297c5ec 100644 --- a/util/slug.js +++ b/util/slug.js @@ -3,8 +3,6 @@ const matter = require('gray-matter'); const { join } = require('path'); const postsDir = join(process.cwd(), 'posts'); -const cacheDir = join(process.cwd(), '.next', 'cache'); -const publicDir = join(process.cwd(), 'public'); function getPost(rawslug, filter = []) { const slug = rawslug.replace(/\.md$/, ''); @@ -40,7 +38,7 @@ function getAllPosts(filter = []) { const files = fs.readdirSync(postsDir); return files - .filter(c => !c.match(/^\./)) + .filter(c => (!c.match(/^\.]/) && c.match(/\.md$/))) .map(file => { return getPost(file, filter) }); @@ -49,7 +47,7 @@ function getAllPosts(filter = []) { function cachePostsMeta() { // public access cache const posts = getAllPosts(['title', 'slug', 'created_at', 'last_updated']); - fs.writeFile(join(publicDir, 'posts.json'), JSON.stringify(posts), (e) => { + fs.writeFile(join(postsDir, 'meta.json'), JSON.stringify(posts), (e) => { if (e) console.error(e); }); @@ -57,7 +55,7 @@ function cachePostsMeta() { // public access cache } function getPostsMeta() { - const file = fs.readFileSync(join(publicDir, 'posts.json'), 'utf-8'); + const file = fs.readFileSync(join(postsDir, 'meta.json'), 'utf-8'); if (!file) { return cachePostsMeta();