Skip to the content

Capsid menu

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

The functions of procedure.sheet.tsx
FunctionLinesComplexityCoveredCRAPMutation
headers21 to 231No data: no coverage report in this mapNo data: no coverage report in this mapNo data: no mutants in this code
loader25 to 344No data: no coverage report in this mapNo data: no coverage report in this mapNo data: no mutants in this code
meta36 to 442No data: no coverage report in this mapNo data: no coverage report in this mapNo data: no mutants in this code
ProcedureSheetRoute46 to 531No data: no coverage report in this mapNo data: no coverage report in this mapNo 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>
  );
}