Skip to content

Commit 5263bb4

Browse files
authored
feat: query and render the changelog (#172)
* feat: query and render the changelog probably a better alternative approach to this, but it works... closes #165 Signed-off-by: Logan McAnsh <[email protected]> * chore: pr review suggestions Signed-off-by: Logan McAnsh <[email protected]> --------- Signed-off-by: Logan McAnsh <[email protected]>
1 parent a7dadf0 commit 5263bb4

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

app/lib/gh-docs/docs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ global.docCache ??= new LRUCache<string, Doc>({
9292

9393
async function fetchDoc(key: string): Promise<Doc> {
9494
let [repo, ref, slug] = key.split(":");
95-
let filename = `docs/${slug}.md`;
95+
let filename = `${slug}.md`;
9696
let md = await getRepoContent(repo, ref, filename);
9797
if (md === null) {
9898
throw Error(`Could not find ${filename} in ${repo}@${ref}`);

app/routes/$.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export const loader = async ({ request, params }: LoaderFunctionArgs) => {
5555
try {
5656
let ref = "main";
5757
let lang = "en";
58-
let doc = await getRepoDoc(ref, params["*"]!);
58+
let doc = await getRepoDoc(ref, `docs/${params["*"]}`);
5959
if (!doc) throw null;
6060
// FIXME: This results in two fetches, as the loader for the docs page will
6161
// repeat the request cycle. This isn't a problem if the doc is in the LRU

app/routes/docs.$lang.$ref.$.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ export async function loader({ params, request }: LoaderFunctionArgs) {
3030
let pageUrl = url.protocol + "//" + url.host + url.pathname;
3131
invariant(params.ref, "expected `ref` params");
3232
try {
33-
let doc = await getRepoDoc(params.ref, params["*"] || "index");
33+
let slug = params["*"]?.endsWith("/changelog")
34+
? "CHANGELOG"
35+
: `docs/${params["*"] || "index"}`;
36+
let doc = await getRepoDoc(params.ref, slug);
3437
if (!doc) throw null;
3538
return json(
3639
{ doc, pageUrl },

0 commit comments

Comments
 (0)