app/routes/procedure.sheet.tsx
46 lines and 4 functions in DrDustinEdwards/dustinedwards-info, at commit 1590ba4 on 2026-10-24. This file on GitHub.
Functions
| Function | Lines | Complexity | Covered | CRAP | Mutation |
|---|---|---|---|---|---|
| headers | 21 to 23 | 1 | No data: no coverage report in this map | No data: no coverage report in this map | No data: no mutants in this code |
| loader | 25 to 34 | 4 | No data: no coverage report in this map | No data: no coverage report in this map | No data: no mutants in this code |
| meta | 36 to 44 | 2 | No data: no coverage report in this map | No data: no coverage report in this map | No data: no mutants in this code |
| ProcedureSheetRoute | 46 to 53 | 1 | No data: no coverage report in this map | No data: no coverage report in this map | No data: no mutants in this code |
Imports
It imports app/components/procedure.tsx, app/db/procedures.ts, app/kb/procedures/cite.mjs, app/kb/procedures/route.ts, app/lib/access.server.ts, app/lib/context.ts, app/lib/seo.ts. No module of this repo imports it.
Source
import { data } from "react-router";
import { ProcedureSheet } from "~/components/procedure";
import { getProcedureByPath } from "~/db/procedures";
import { isAdminViewer } from "~/lib/access.server";
import { getEnv } from "~/lib/context";
import { sheetAddress } from "~/kb/procedures/cite.mjs";
import { PROCEDURES_CACHE_TAG, readScale } from "~/kb/procedures/route";
import { SITE_ORIGIN, publicHtmlHeaders } from "~/lib/seo";
import type { Route } from "./+types/procedure.sheet";
import "~/styles/prose.css";
import "~/styles/procedure.css";
/**
* A procedure's printable sheet at `<page>/sheet`: the materials (scaled by the same `?n=` or
* `?servings=` as the page), the steps with their flags and the troubleshooting table, without the site's
* header and footer or the reasoning notes. Not indexed: the page is the canonical copy.
*/
export function headers() {
return new Headers(publicHtmlHeaders(PROCEDURES_CACHE_TAG));
}
export async function loader({ request, context }: Route.LoaderArgs) {
const env = getEnv(context);
const url = new URL(request.url);
const path = url.pathname.replace(/\/sheet\/?$/, "");
const row = await getProcedureByPath(env, path);
if (!row) throw data(null, { status: 404 });
if (row.status === "draft" && !(await isAdminViewer(env, request))) throw data(null, { status: 404 });
const { count, factor } = readScale(row.record, url);
return { record: row.record, count, factor };
}
export function meta({ loaderData }: Route.MetaArgs) {
if (!loaderData) return [];
const { record } = loaderData;
return [
{ title: `${record.title}: printable sheet` },
{ name: "robots", content: "noindex" },
{ tagName: "link", rel: "canonical", href: `${SITE_ORIGIN}${record.path}` },
];
}
export default function ProcedureSheetRoute({ loaderData }: Route.ComponentProps) {
const { record, count, factor } = loaderData;
return (
<main className="procedure-sheet-page" id="main">
<ProcedureSheet record={record} count={count} factor={factor} address={sheetAddress(record, SITE_ORIGIN)} />
</main>
);
}