Skip to content

Add broken-image pre-commit hook + CI check #34

Description

@jmxpearson

Summary

Phases 1, 2, and 4 (PR #32) added pre-commit hooks for image compression, a size cap, and code quality. There is no hook that verifies image references resolve. The dibs-web01 rot (separate issue) is exactly the failure mode this would catch.

Proposal

A small Python script run as a local hook in .pre-commit-config.yaml:

  • For each staged *.html and *.md, scan for <img src="..."> and ![alt](url) references.
  • For relative paths: verify the target exists in the repo.
  • For external URLs: HEAD with a short timeout; fail on 4xx/5xx (with the same conservative accept list as lychee).
  • Skip data URIs and template Liquid expressions like {{ site.url }}/....

Mirror in CI so contributors who skip the local install still get caught.

Acceptance

  • scripts/check_image_refs.py (stdlib + minimal deps)
  • Wired into .pre-commit-config.yaml
  • Added to .github/workflows/pre-commit.yml and/or site-health.yml
  • README documents what it does and how to override (config file analogous to .image-size-overrides)

Pairs with

The dibs-web01 migration issue. This hook is the prevention; that one is the cure.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions