Skip to content

Favicons: discover square size variants and ship a configurable gen-favicons CLI - #2656

Merged
chalin merged 14 commits into
docsy:mainfrom
chalin:chalin-m24-favicons-2026-0615
Jun 15, 2026
Merged

chalin merged 14 commits into
docsy:mainfrom
chalin:chalin-m24-favicons-2026-0615

Conversation

@chalin

@chalin chalin commented Jun 15, 2026 •

Copy link
Copy Markdown
Collaborator
  • Contributes to Improve favicon support, in particular for light/dark mode #2357
  • Theme partial — discover square size variants
    • Aligns the default favicons.html partial with Hugo template conventions (whitespace trims, structure)
    • Discovers and links any square favicon-NxN.png variant in static/ (was a hard-coded 16/32px pair), in ascending pixel-size order via os.ReadDir
    • Generalizes the same discovery to apple-touch-icon-NxN.png, via a reusable inline sized-variants helper parameterized by file prefix and link attributes
    • Coerces the helper's return to []interface{} (no-op append slice) so the caller's chained append always flattens it, avoiding an empty-then-nonempty nesting trap
    • Drops the hard-coded sizes="16x16 32x32 48x48" on the favicon.ico link: a .ico is self-describing, so the declared list adds nothing and silently drifts when the file's frames differ (rationale captured in a user-guide footnote)
  • gen-favicons — npm-installable CLI
    • Rewrites scripts/gen-favicons.sh as a Node CLI folder scripts/gen-favicons/ (index/cli/tests/README) exposed via an npm bin (npx gen-favicons)
    • Adds configurable --ico/--png/--apple sizes (comma-separated, or none) with a sensible default set
  • Docs & tests
    • Updates the "Add your favicons" user guide and the changelog for the discovered-variant families and the new CLI
    • Adds theme tests asserting square favicon-NxN.png and apple-touch-icon-NxN.png variants are linked in ascending pixel-size order, a gen-favicons test suite, an npm-pack contract test, and a --help smoke test

chalin added 6 commits June 15, 2026 04:39
- Contributes to docsy#2357
- Shortens the block comment and points to the user guide for details
- Defaults to right-trim whitespace control and indents nested `range`/`if` blocks
- Emits explicit newlines between discovered icon links via `{{- "\n" -}}`
- Contributes to docsy#2357
- Generalizes the default partial to discover any square `favicon-NxN.png` in `static/` via `os.ReadDir`, linking the variants in ascending pixel-size order, rather than only the hard-coded 16/32px pair
- Collapses the user-guide discovery table to a single `favicon-NxN.png` row and notes that any number of square variants are supported
- Adds a theme test asserting arbitrary sizes are linked and numerically sorted
- Adds `submatch` to the cspell dictionary for `findRESubmatch`
…rable sizes

- Contributes to docsy#2357
- Replaces the `scripts/gen-favicons.sh` wrapper with a Node `scripts/gen-favicons/` folder (index/cli/tests/readme) that runs without bash and shells out to ImageMagick as before.
- Adds a `gen-favicons` npm `bin` and ships the tool via `files`, so npm-based Docsy sites run `npx gen-favicons` while module/submodule installs run `cli.mjs` directly.
- Supports configurable `--ico`, `--png`, and `--apple` sizes (comma-separated, or `none` to skip), defaulting to the set the favicons partial discovers.
- Smoke-tests `npx gen-favicons --help` in NPM mode and pins the new tarball contents in the npm-pack contract test.
- Updates the favicons guide, changelog, and spell-check dictionary.
- Contributes to docsy#2357
- Generalizes the default partial to also discover any square `apple-touch-icon-NxN.png` in `static/`, via a reusable inline `sized-variants` helper parameterized by file prefix and link attributes
- Coerces the helper's return to `[]interface{}` so the caller's chained `append` always flattens it, avoiding the empty-then-nonempty nesting trap
- Adds the `apple-touch-icon-NxN.png` discovery row to the user guide and DRYs the `gen-favicons` guidance to point at `--help`
- Adds a theme test asserting square apple-touch-icon variants are linked in ascending pixel-size order
…eholder

- Contributes to docsy#2357
- Adds a theme test asserting a non-square `favicon-WxH.png` is ignored while its square sibling is linked, locking the square-only discovery rule
- Adds a theme test asserting a sized `apple-touch-icon-NxN.png` is linked on its own when the unsized `apple-touch-icon.png` is absent
- Glosses the `PATH_TO_DOCSY` placeholder on first use in the user guide
- Contributes to docsy#2357
- Splits favicon generation into its own "Generate favicons" section, linked from the discovery intro, documenting the npm-package, Git-submodule, and Hugo-module invocations (the latter via `go list -m -f '{{.Dir}}' github.com/google/docsy`)
- Uses `static/favicon.svg` as the `gen-favicons` source so the SVG is both linked by the theme and rasterized in place, removing the previous manual "copy your SVG" step
- Aligns the `gen-favicons` README and CLI `--help` examples with the same source-in-static usage
@chalin
chalin force-pushed the chalin-m24-favicons-2026-0615 branch from 2b7bb50 to e89ed65 Compare June 15, 2026 14:41
chalin added 3 commits June 15, 2026 10:45
…icons"

- Contributes to docsy#2357
- Makes generation a level-3 subsection so it reads as part of adding favicons rather than a sibling top-level topic; the `#generate-favicons` anchor is unchanged
… pointer

- Contributes to docsy#2357
- Adds a theme test asserting unrelated `static/` files (e.g. `robots.txt`, `logo.svg`, `favicon.svg`) are passed over while square `favicon-NxN.png` and `apple-touch-icon-NxN.png` variants are still discovered, pinning the empty-`findRESubmatch` path in the `sized-variants` helper
- Rewords the `gen-favicons --help` pointer to the per-install command forms, since `gen-favicons` is only on `PATH` for npm-package installs
@chalin
chalin force-pushed the chalin-m24-favicons-2026-0615 branch from 0f8fe3d to 5d1512d Compare June 15, 2026 15:50
chalin added 5 commits June 15, 2026 12:22
- Drops `sizes="16x16 32x32 48x48"` from the `favicon.ico` `<link>`: a `.ico` is self-describing (browsers read the frame sizes it bundles), so a declared list adds nothing and silently drifts when the file's frames differ
- Documents the rationale (and that SVG-capable browsers prefer `favicon.svg`, with `.ico` as fallback) in a user-guide footnote rather than the template
- Updates the theme tests and the favicon golden to expect the size-less `.ico` link
- Fixes the broken `hooks/head-end.html` reference in the favicons user guide: the blob URL was missing the `theme/` path prefix and 404'd
- Renames the favicon footnote id `svg-pref` to `ico-link` so it reflects its full content (no `sizes` on `.ico`, plus the SVG preference), not just the SVG aspect
- Aligns the `gen-favicons` README to the `DOCSY_DIR` placeholder used in the user guide, and glosses it on first use
- Adds the missing `theme/` path prefix to the partial blob links (`baseof.html`, `head.html`, `scripts.html`, `hooks/head-end.html`, `hooks/body-end.html`), which all 404'd
- Points the `scripts.html` link at `scripts.html` instead of `head.html`
@chalin
chalin merged commit f312828 into docsy:main Jun 15, 2026
15 checks passed
@chalin
chalin deleted the chalin-m24-favicons-2026-0615 branch June 15, 2026 16:57
chalin added a commit to chalin/docsy that referenced this pull request Jun 26, 2026
…report

Release-prep audit reconciliation for 0.16.0:

- Reference docsy#2656 (square favicon variant discovery and the configurable
  gen-favicons CLI) from the favicon entries in the release report and the
  changelog; it was implemented but previously unreferenced.
- Fix a broken "Upgrade to Docsy 0.12.0" link in the rollback NOTE that was
  split across a stray nested blockquote, and reword so the file is
  prettier-stable.
@chalin chalin added this to the 0.16.0 milestone Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant