mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2026-07-21 22:15:57 -04:00
directly (and still dynamically) assign a few of the mdx components
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
// do not convert to ESM -- this needs to be imported in CJS files like next.config.js too
|
||||
module.exports = {
|
||||
// Site info
|
||||
siteName: "Jake Jarvis",
|
||||
|
||||
+3
-2
@@ -3,6 +3,7 @@ import path from "path";
|
||||
import matter from "gray-matter";
|
||||
import { NOTES_DIR, baseUrl } from "./config";
|
||||
|
||||
// returns front matter and/or *raw* markdown contents of a given slug
|
||||
export const getNoteData = (slug: string) => {
|
||||
const fullPath = path.join(process.cwd(), NOTES_DIR, `${slug}.mdx`);
|
||||
const rawContent = fs.readFileSync(fullPath, "utf8");
|
||||
@@ -19,15 +20,15 @@ export const getNoteData = (slug: string) => {
|
||||
};
|
||||
};
|
||||
|
||||
// all .mdx files in NOTES_DIR
|
||||
// returns all .mdx files in NOTES_DIR (without .mdx extension)
|
||||
export const getNoteSlugs = () =>
|
||||
fs
|
||||
.readdirSync(path.join(process.cwd(), NOTES_DIR))
|
||||
.filter((file) => /\.mdx$/.test(file))
|
||||
.map((noteFile) => noteFile.replace(/\.mdx$/, ""));
|
||||
|
||||
// returns the front matter of ALL notes, sorted reverse chronologically
|
||||
export const getAllNotes = () =>
|
||||
getNoteSlugs()
|
||||
.map((slug) => getNoteData(slug).frontMatter)
|
||||
// sort notes by date in descending order
|
||||
.sort((note1: any, note2: any) => (note1.date > note2.date ? -1 : 1));
|
||||
|
||||
Reference in New Issue
Block a user