Skip to content

404 report

The paths a site was asked for and lacks, most hits first, with referring hosts and last request.

<div data-mount="report"></div>

Installation

// package.json: "capsomer": "github:DrDustinEdwards/capsomer#v0.152.2"
import "capsomer/tokens.css";
import "capsomer/base.css";
import "capsomer/not-found-report.css";
import { referrerLine, windowOf, probesLine } from "capsomer/behavior/not-found-report";

Usage

import { NotFoundReport } from "capsomer/react/not-found-report";

<NotFoundReport
  rows={rows}
  days={days}
  windows={[7, 30]}
  onWindow={(d) => setSearchParams(d === 30 ? {} : { days: String(d) })}
  reason={reason}
  actions={(row) => <Link className="cap-btn" data-size="sm" to={`/redirects/new?from=${encodeURIComponent(row.path)}`}>Add a redirect<span className="cap-sr-only"> for {row.path}</span></Link>}
/>

Examples

One window, no actions, scanner probes counted and not listed

<div data-mount="plain"></div>

Nothing missing

<div data-mount="empty"></div>

The report cannot be read, and reading it

<div data-mount="reason"></div>
<div data-mount="loading"></div>

API reference

NotFoundReport

PropTypeRequiredDoes
rowsreadonly NotFoundRow[]Yes
daysnumberYesThe window the rows count over, in days.
windowsreadonly number[]The windows offered, with the change to make: a segmented control in the panel's head.
onWindow(days: number) => void
titleReactNode
srcReactNodeThe source line; "Last 30 days" by default. The probes not listed always follow it.
probesnumber | nullScanner probes the site counted and does not list.
reasonReactNodeThe report cannot be read: why, in a sentence. A state with a reason, never an empty list.
loadingboolean
actions(row: NotFoundRow) => ReactNodeA row's own actions: "Add a redirect".
nownumberA fixed "now" for the last-seen times.

Functions

FunctionSignatureDoes
referrerLine(referrers: readonly { host: string; hits: number; }[]): string"example.com 2, no referrer 1".
windowOf(asked: unknown, windows: readonly number[], fallback?: number | undefined): numberThe window asked for, if it is one the report offers; else the default (the last one offered).
probesLine(probes: number | null | undefined): string | nullWhat the source line says about scanner probes, counted and not listed.
hitsWord(n: number): string

Parts and data attributes

ClassIs
.cap-nf-metaits own class
.cap-nf-paththe root
.cap-nf-reasonits own class

Accessibility

KeyDoes
TabThe window's choice, then each row and its actions
Arrow keys on the windowChange it; the rows follow
Enter on a row actionFollows or runs it
  • The panel is named by its title; the rows are a list named "Missing paths, most hits first".
  • A row's action names its path ("Add a redirect for /blog/spring-update/").
  • The hits and the last-seen time are text beside the path.