-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
958 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { NextResponse, NextRequest } from "next/server"; | ||
import fs from "fs"; | ||
import path from "path"; | ||
|
||
export async function GET(req: NextRequest): Promise<NextResponse> { | ||
const fileName = req.nextUrl.searchParams.get("file"); | ||
|
||
if (!fileName) { | ||
return new NextResponse("Bad Request: Missing file name", { status: 400 }); | ||
} | ||
|
||
const filePath = path.join(process.cwd(), fileName); | ||
if (!fs.existsSync(filePath)) { | ||
return new NextResponse("Not Found: File does not exist", { status: 404 }); | ||
} | ||
|
||
try { | ||
const data = await fs.promises.readFile(filePath, "utf-8"); | ||
return new NextResponse(data, { | ||
status: 200, | ||
headers: { | ||
"Content-Type": "text/plain", | ||
}, | ||
}); | ||
} catch (err) { | ||
console.error(err); | ||
return new NextResponse("Internal Server Error", { status: 500 }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,42 @@ | ||
"use client"; | ||
|
||
import Markdown from "react-markdown"; | ||
import remarkGfm from "remark-gfm"; | ||
import { useEffect, useState } from "react"; | ||
|
||
export default function CreditsView() { | ||
const [readMe, setReadMe] = useState<string | null>(null); | ||
|
||
useEffect(() => { | ||
const fetchData = async () => { | ||
const response = await fetch("/api/fetch_file?file=README.md", { | ||
cache: "force-cache", | ||
}); | ||
if (!response.ok) { | ||
console.log("Failed to fetch:", response.status); | ||
return; | ||
} | ||
const data = await response.text(); | ||
setReadMe(data); | ||
}; | ||
|
||
if (!readMe) { | ||
fetchData(); | ||
} | ||
}); | ||
|
||
return ( | ||
<div className="h-full w-full"> | ||
<h1 className="text-emerald-600"> hello World</h1> | ||
<div className="relative bg-white h-full w-full overflow-y-auto max-h-[calc(100vh)]"> | ||
<div className="sticky top-0 mx-2 border-b border-gray-300 pt-4 pb-3 bg-white flex justify-between items-center"> | ||
<div className="text-3xl">Read Me</div> | ||
</div> | ||
<article className="mx-auto py-5 prose"> | ||
{readMe ? ( | ||
<Markdown remarkPlugins={[remarkGfm]}>{readMe}</Markdown> | ||
) : ( | ||
<p>Loading README content...</p> | ||
)} | ||
</article> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.