diff --git a/app/on/[title]/page.tsx b/app/on/[title]/page.tsx
index 1abb575..a5f1f67 100644
--- a/app/on/[title]/page.tsx
+++ b/app/on/[title]/page.tsx
@@ -2,7 +2,7 @@ import { ReactMarkdown } from "react-markdown/lib/react-markdown";
import { fetchMdFile, getEssayTitles, parseMdFile } from "../getWritings";
export async function generateStaticParams() {
- const titles = await getEssayTitles("essays");
+ const titles = await getEssayTitles("essays/", "essays");
console.log("generate?", titles);
return titles.map((title: string) => ({
@@ -16,10 +16,9 @@ export default async function Essay({
params: { title: string; content: string; magic: string };
}) {
const path = `essays/${params.title.replaceAll(" ", "-")}.md`;
- const content = await fetchMdFile(path);
+ const content = await fetchMdFile(path, "essays");
console.log("Esasy:", path, params.magic);
const file = await parseMdFile(content);
- console.log("wow", file);
return (
diff --git a/app/on/getWritings.ts b/app/on/getWritings.ts
index 8917fb2..aeba83a 100644
--- a/app/on/getWritings.ts
+++ b/app/on/getWritings.ts
@@ -1,28 +1,15 @@
-const cache: Record = {};
+const BASE_URL = "https://api.github.com";
-export async function getEssayTitles(path: string) {
- const essays = await fetchMdFiles(path);
+export async function getEssayTitles(path: string, tag: string) {
+ const essays = await fetchMdFiles(path, tag);
const fileNames = extractFileNames(essays);
const titles = extractTitles(fileNames);
return titles;
}
-export async function getWritings(path: string) {
- if (cache?.titles) return cache;
- console.log("no cache");
- const mdFiles = await fetchMdFiles(path);
- const titles = extractFileNames(mdFiles);
- const contents: string[] = []; /// await fetchFileContents(mdFiles);
- cache.titles = titles;
- cache.contents = contents;
- return { titles, contents };
-}
-
-const BASE_URL = "https://api.github.com";
-
-async function fetchMdFiles(path: string): Promise {
+async function fetchMdFiles(path: string, tag: string): Promise {
try {
- const response = await fetchRepo(path);
+ const response = await fetchRepo(path, tag);
if (!response.ok) {
throw new Error(`GitHub API responded with ${response.status}`);
}
@@ -51,19 +38,29 @@ function extractTitles(fileNames: string[]): string[] {
return fileNames.map((name) => name.replaceAll("-", " ").replace(".md", ""));
}
-async function fetchFileContents(files: any[]): Promise