1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2026-06-05 19:15:30 -04:00

try memoizing front matter parsing

This commit is contained in:
2022-07-18 17:39:55 -04:00
parent a788f673e9
commit a9f3bf2974
5 changed files with 416 additions and 404 deletions
View File
+3
View File
@@ -8,6 +8,9 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*
# typescript
*.tsbuildinfo
# here be secrets
*.env*
!.env.example
+3 -2
View File
@@ -5,6 +5,7 @@ import matter from "gray-matter";
import { marked } from "marked";
import removeMarkdown from "remove-markdown";
import pMap from "p-map";
import pMemoize from "p-memoize";
import { formatDate } from "./format-date";
import { baseUrl } from "../config";
import { NOTES_DIR } from "../config/constants";
@@ -55,7 +56,7 @@ export const getNoteData = async (
};
// returns the parsed front matter of ALL notes, sorted reverse chronologically
export const getAllNotes = async (): Promise<NoteFrontMatter[]> => {
export const getAllNotes = pMemoize(async (): Promise<NoteFrontMatter[]> => {
const slugs = await getNoteSlugs();
// for each slug, query its front matter
@@ -65,4 +66,4 @@ export const getAllNotes = async (): Promise<NoteFrontMatter[]> => {
data.sort((note1, note2) => (note1.date > note2.date ? -1 : 1));
return data;
};
});
+7 -6
View File
@@ -14,7 +14,7 @@
"dev": "cross-env NODE_OPTIONS='--inspect' next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
"lint": "eslint . --ext js,jsx,ts,tsx"
},
"dependencies": {
"@fontsource/comic-neue": "4.5.8",
@@ -42,10 +42,11 @@
"gray-matter": "^4.0.3",
"hex-to-rgba": "^2.0.1",
"marked": "^4.0.18",
"next": "12.2.3-canary.10",
"next": "12.2.3-canary.13",
"next-mdx-remote": "^4.0.3",
"next-seo": "^5.4.0",
"p-map": "^5.5.0",
"p-memoize": "^7.1.0",
"prop-types": "^15.8.1",
"query-string": "^7.1.1",
"react": "18.2.0",
@@ -83,11 +84,11 @@
"@types/react-is": "^17.0.3",
"@types/remove-markdown": "^0.3.1",
"@types/uglify-js": "^3.16.0",
"@typescript-eslint/eslint-plugin": "^5.30.6",
"@typescript-eslint/parser": "^5.30.6",
"@typescript-eslint/eslint-plugin": "^5.30.7",
"@typescript-eslint/parser": "^5.30.7",
"cross-env": "^7.0.3",
"eslint": "~8.19.0",
"eslint-config-next": "12.2.3-canary.10",
"eslint": "~8.20.0",
"eslint-config-next": "12.2.3-canary.13",
"eslint-config-prettier": "~8.5.0",
"eslint-plugin-prettier": "~4.2.1",
"lint-staged": "^13.0.3",
+403 -396
View File
File diff suppressed because it is too large Load Diff