import type { Depth } from "./content-schema"; export const depthLabels = [ "Surface", "Evidence", "Mechanism", "Experiment", ] as const; export type PublicQuery = Record; export type Sample = "original" | "edited"; export function readDepth( value: PublicQuery[string], supported: readonly Depth[], ): Depth { if (typeof value !== "string" || !/^[0-3]$/.test(value)) return 0; const requested = Number(value) as Depth; return supported.includes(requested) ? requested : 0; } export function depthHref( slug: string, depth: Depth, sample: Sample = "original", ) { const base = "/work/" + slug; if (depth === 0) return base; return ( base + "?d=" + depth + (depth === 3 && sample === "edited" ? "&sample=edited" : "") ); }