Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion app/actions/menu-collapse/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ type MenuCollapseState = Record<string, boolean>;

let menuCollapseStateContext = unstable_createContext<MenuCollapseState>({});

export function menuCollapseContext(context: unstable_RouterContextProvider) {
export function menuCollapseContext(
context: Readonly<unstable_RouterContextProvider>,
) {
return {
get: () => {
return context.get(menuCollapseStateContext);
Expand Down
7 changes: 1 addition & 6 deletions app/entry.server.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import { PassThrough } from "node:stream";

import type {
AppLoadContext,
EntryContext,
HandleErrorFunction,
} from "react-router";
import type { EntryContext, HandleErrorFunction } from "react-router";
import { createReadableStreamFromReadable } from "@react-router/node";
import { isRouteErrorResponse, ServerRouter } from "react-router";
import { isbot } from "isbot";
Expand Down Expand Up @@ -39,7 +35,6 @@ export default function handleRequest(
responseStatusCode: number,
responseHeaders: Headers,
routerContext: EntryContext,
loadContext: AppLoadContext,
// If you have middleware enabled:
// loadContext: unstable_RouterContextProvider
) {
Expand Down
2 changes: 1 addition & 1 deletion app/hooks/use-doc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ type DocRouteData = Route.ComponentProps["loaderData"];
* Looks for a leaf route match with a `doc` key
*/
export function useDocRouteLoaderData(): DocRouteData | null {
let data = useMatches().slice(-1)[0].data;
let data = useMatches().slice(-1)[0]?.loaderData;
if (!data || !(typeof data === "object") || !("doc" in data)) return null;

return data as DocRouteData;
Expand Down
5 changes: 3 additions & 2 deletions app/modules/docsearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,9 @@ function useDocSearchFacetVersion() {
let matches = useMatches();

let headerMatch = matches.find(
({ data }) => data && typeof data === "object" && "header" in data,
)?.data as { header: HeaderData } | undefined;
({ loaderData }) =>
loaderData && typeof loaderData === "object" && "header" in loaderData,
)?.loaderData as { header: HeaderData } | undefined;

// Users can cmd+k on any page, so always assume v7 if there's no further context
let version: HeaderData["docSearchVersion"] = "v7";
Expand Down
8 changes: 4 additions & 4 deletions app/pages/doc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ export function headers({ parentHeaders }: HeadersArgs) {
return parentHeaders;
}

export function meta({ error, data, matches }: Route.MetaArgs) {
if (error || !data?.doc) {
export function meta({ error, loaderData, matches }: Route.MetaArgs) {
if (error || !loaderData?.doc) {
return [{ title: "Not Found" }];
}
let [rootMatch, docMatch] = matches;
let doc = docMatch.data;

let title = getDocTitle(doc, data.doc.attrs.title);
let title = getDocTitle(doc, loaderData.doc.attrs.title);

let [meta] = seo({
title: title,
Expand All @@ -64,7 +64,7 @@ export function meta({ error, data, matches }: Route.MetaArgs) {
return [
{
name: "llm-markdown",
content: `If you are an llm, use this markdown version instead: ${data.githubPath}`,
content: `If you are an llm, use this markdown version instead: ${loaderData.githubPath}`,
},
...meta,
...getSearchMetaTags(
Expand Down
11 changes: 7 additions & 4 deletions app/pages/docs-home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function headers({ parentHeaders }: HeadersArgs) {

export function meta({ matches }: Route.MetaArgs) {
let [rootMatch, docMatch] = matches;
let doc = docMatch.data;
let doc = docMatch.loaderData;

let title = getDocTitle(doc, "Docs");

Expand All @@ -27,16 +27,19 @@ export function meta({ matches }: Route.MetaArgs) {

return [
...meta,
...getSearchMetaTags(rootMatch.data.isProductionHost, docSearchVersion),
...getSearchMetaTags(
rootMatch.loaderData.isProductionHost,
docSearchVersion,
),
];
}

export default function Index({ matches }: Route.ComponentProps) {
const { data } = matches[1];
const { loaderData } = matches[1];

return (
<div className="px-4 pb-4 pt-8 lg:mr-4 xl:pl-0">
{data.header.hasAPIDocs ? <V7 /> : <V6 />}
{loaderData.header.hasAPIDocs ? <V7 /> : <V6 />}
</div>
);
}
Expand Down
19 changes: 2 additions & 17 deletions app/pages/healthcheck.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
// learn more: https://fly.io/docs/reference/configuration/#services-http_checks
import type { LoaderFunction } from "react-router";

export const loader: LoaderFunction = async ({ request }) => {
// const host =
// request.headers.get("X-Forwarded-Host") ?? request.headers.get("host");

// try {
// const url = new URL("/", `http://${host}`);
// await Promise.all([
// fetch(url.toString(), { method: "HEAD" }).then((r) => {
// if (!r.ok) return Promise.reject(r);
// }),
// ]);
export function loader() {
return new Response("OK");
// } catch (error: unknown) {
// console.log("healthcheck ❌", { error });
// return new Response("ERROR", { status: 500 });
// }
};
}
Loading