1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-09-16 19:45:33 -04:00

only reveal a db record via /api/hits if it matches a real page

This commit is contained in:
2022-07-06 11:49:41 -04:00
parent 8d47958473
commit 155c6cacd9
9 changed files with 82 additions and 76 deletions

View File

@@ -14,7 +14,7 @@ import type { NoteFrontMatter } from "../../types";
export const getNoteSlugs = async (): Promise<string[]> => {
// list all .mdx files in NOTES_DIR
const mdxFiles = await glob("*.mdx", {
cwd: NOTES_DIR,
cwd: path.join(process.cwd(), NOTES_DIR),
dot: false,
});
@@ -31,7 +31,7 @@ export const getNoteData = async (
frontMatter: NoteFrontMatter;
content: string;
}> => {
const fullPath = path.join(NOTES_DIR, `${slug}.mdx`);
const fullPath = path.join(process.cwd(), NOTES_DIR, `${slug}.mdx`);
const rawContent = await fs.readFile(fullPath, "utf8");
const { data, content } = matter(rawContent);
@@ -47,7 +47,7 @@ export const getNoteData = async (
smartypants: true,
}),
slug,
permalink: `${baseUrl}/notes/${slug}/`,
permalink: `${baseUrl}/${NOTES_DIR}/${slug}/`,
date: formatDate(data.date), // validate/normalize the date string provided from front matter
},
content,