Skip to content

Commit

Permalink
Merge branch 'main' into gg/loading-indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavoguichard authored Feb 5, 2024
2 parents dad1da4 + 5263bb4 commit ab7399c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/lib/gh-docs/docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ global.docCache ??= new LRUCache<string, Doc>({

async function fetchDoc(key: string): Promise<Doc> {
let [repo, ref, slug] = key.split(":");
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: 1 addition & 1 deletion app/routes/$.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const loader = async ({ request, params }: LoaderFunctionArgs) => {
try {
let ref = "main";
let lang = "en";
let doc = await getRepoDoc(ref, params["*"]!);
let doc = await getRepoDoc(ref, `docs/${params["*"]}`);
if (!doc) throw null;
// FIXME: This results in two fetches, as the loader for the docs page will
// repeat the request cycle. This isn't a problem if the doc is in the LRU
Expand Down
5 changes: 4 additions & 1 deletion app/routes/docs.$lang.$ref.$.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ export async function loader({ params, request }: LoaderFunctionArgs) {
let pageUrl = url.protocol + "//" + url.host + url.pathname;
invariant(params.ref, "expected `ref` params");
try {
let doc = await getRepoDoc(params.ref, params["*"] || "index");
let slug = params["*"]?.endsWith("/changelog")
? "CHANGELOG"
: `docs/${params["*"] || "index"}`;
let doc = await getRepoDoc(params.ref, slug);
if (!doc) throw null;
return json(
{ doc, pageUrl },
Expand Down
5 changes: 5 additions & 0 deletions app/routes/docs.$lang.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { redirect, type LoaderFunctionArgs } from "@remix-run/node";
export async function loader({ params }: LoaderFunctionArgs) {
const { lang, ref } = params;
return !ref ? redirect(`/docs/${lang}/main`) : null;
}
4 changes: 4 additions & 0 deletions app/styles/docsearch.css
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,7 @@

@apply grid h-5 w-3.5 place-items-center rounded bg-white px-1 text-xs text-gray-600 dark:bg-gray-600 dark:text-gray-200;
}

.DocSearch-Container {
cursor: auto;
}

0 comments on commit ab7399c

Please sign in to comment.