Skip to content

Commit

Permalink
feat: Add changelog rendering (#96)
Browse files Browse the repository at this point in the history
* Render the changelog

* Add more spacing to brand page and remove unstable_shouldReload
  • Loading branch information
brookslybrand authored Mar 26, 2024
1 parent c655fbf commit 7d534e4
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
25 changes: 15 additions & 10 deletions app/components/doc-route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type {
LoaderFunctionArgs,
SerializeFrom,
MetaFunction,
HeadersFunction,
} from "@remix-run/node";
import * as React from "react";
import { json } from "@remix-run/node";
Expand All @@ -27,20 +28,24 @@ export let loader = async ({ params, request }: LoaderFunctionArgs) => {

invariant(params.ref, "expected `ref` params");

let doc = await getRepoDoc(params.ref, params["*"] || "index");
if (!doc) {
try {
let slug = params["*"]?.endsWith("/changelog")
? "CHANGELOG"
: `docs/${params["*"] || "index"}`;
let doc = await getRepoDoc(params.ref, slug);
if (!doc) throw null;
return json({ doc }, { headers: { "Cache-Control": CACHE_CONTROL.doc } });
} catch (_) {
throw new Response("", { status: 404 });
}

return json({ doc }, { headers: { "Cache-Control": CACHE_CONTROL.doc } });
};

export function headers() {
return {
"Cache-Control": CACHE_CONTROL.doc,
Vary: "Cookie",
};
}
export const headers: HeadersFunction = ({ loaderHeaders }) => {
// Inherit the caching headers from the loader so we don't cache 404s
let headers = new Headers(loaderHeaders);
headers.set("Vary", "Cookie");
return headers;
};

export const meta: MetaFunction<
typeof loader,
Expand Down
3 changes: 1 addition & 2 deletions app/modules/gh-docs/docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ global.docCache ??= new LRUCache<string, Doc | undefined>({

async function fetchDoc(key: string): Promise<Doc> {
let [repo, ref, slug] = key.split(":");
// remove docs/ when we do https://github.com/remix-run/react-router-website/issues/94
let filename = `docs/${slug}.md`;
let filename = `${slug}.md`;
let md = await getRepoContent(repo, ref, filename);
if (md === null) {
throw Error(`Could not find ${filename} in ${repo}@${ref}`);
Expand Down
2 changes: 0 additions & 2 deletions app/routes/$lang.$ref.$.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,3 @@ export {
meta,
ErrorBoundary,
} from "~/components/doc-route";

export let unstable_shouldReload = () => false;
2 changes: 1 addition & 1 deletion app/routes/brand.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const meta: MetaFunction = () => {

export default function Brand() {
return (
<div className="prose container my-8 flex max-w-full flex-col gap-8 text-base sm:text-lg lg:max-w-4xl">
<div className="prose container my-8 flex max-w-full flex-col gap-8 text-base sm:text-lg lg:my-24 lg:max-w-4xl">
<h1 className="text-2xl font-extrabold dark:text-gray-200 md:text-5xl">
React Router Brand
</h1>
Expand Down

0 comments on commit 7d534e4

Please sign in to comment.