Skip to the content

Capsid menu

app/lib/editor/head.server.ts

17 lines and 1 functions in DrDustinEdwards/dustinedwards-info, at commit 1590ba4 on 2026-10-24. This file on GitHub.

Functions

The functions of head.server.ts
FunctionLinesComplexityCoveredCRAPMutation
readHead10 to 192No data: no coverage report in this mapNo data: no coverage report in this mapNo data: no mutants in this code

Imports

It imports app/lib/editor/publish.server.ts, app/lib/error-message.mjs. Imported by app/routes/admin.posts.$slug.edit.tsx, app/routes/admin.posts.new.tsx.

Source

import { currentHead } from "~/lib/editor/publish.server";
import { errorMessage } from "~/lib/error-message.mjs";

type HeadEnv = Parameters<typeof currentHead>[0];

/**
 * For a loader that must render with no head. The error travels with the empty sha, so the editor
 * names what failed rather than guessing a missing token.
 */
export async function readHead(
  env: HeadEnv,
): Promise<{ headSha: string; headError: string | null }> {
  try {
    return { headSha: await currentHead(env), headError: null };
  } catch (error) {
    console.error(JSON.stringify({ alert: "editor-head-read-failed", detail: errorMessage(error) }));
    return { headSha: "", headError: errorMessage(error) };
  }
}