Skip to content

Resolve local images everywhere + staticFiles + sitemap.xml#341

Merged
ankitskvmdam merged 6 commits into
masterfrom
feat/image-asset-resolution-sitemap
Jun 25, 2026
Merged

Resolve local images everywhere + staticFiles + sitemap.xml#341
ankitskvmdam merged 6 commits into
masterfrom
feat/image-asset-resolution-sitemap

Conversation

@ankitskvmdam

Copy link
Copy Markdown
Owner

Fixes #333.

Summary

Local image assets now work from every prose source the theme renders, not just opts.docs — plus JSDoc staticFiles support and a generated sitemap.xml. Both the JSDoc and TypeDoc bridges have parity.

Image resolution

  • Images referenced from tutorials, the README, and JSDoc / TypeScript doc comments are copied through the content-hashed _assets/ pipeline and the reference is rewritten — both Markdown ![](…) and raw <img>. Comment images resolve against each symbol's own source file; SVGs are inlined (theme-toggle-aware).
  • templates.default.staticFiles is honored: included files are copied verbatim to the output root (JSDoc parity), and the include directories become fallback search roots, so a bare reference like ![](classes-io.png) resolves and is hashed — no need to rewrite existing comments/tutorials. A file already served from _assets/ isn't duplicated at the root.
  • Image syntax shown inside code spans / fenced blocks / <pre>/<code> is left literal — no spurious copy, rewrite, or "could not read image" warning.

sitemap.xml

  • Set siteUrl and the build emits sitemap.xml at the output root — one <loc> per non-hidden page (hidden source-viewer pages excluded). Only the URL's origin is used; the deploy sub-path comes from basePath, so the two never double-count.

Docs & examples

  • New "Working with Images" guide (en + hi/ja/zh) covering all of the above.
  • siteUrl documented on the configuration page in every locale; enabled on the docs-site itself.
  • examples/basic and examples/typedoc-basic gain fixtures exercising each path.
  • ARCHITECTURE.md updated for the image pipeline, staticFiles, sitemap, and the code-region skip.

Tests

  • utils 116, dwar 138, clean-jsdoc-theme 78, typedoc 50 — all green; typecheck + lint clean.
  • Verified end-to-end against examples/basic, examples/typedoc-basic, the docs-site (all locales build with zero image warnings), and a real consumer project.

Commits

  1. feat(dwar) — emit sitemap.xml from the rendered page set
  2. feat(clean-jsdoc-theme) — resolve images from tutorials / README / comments, staticFiles, code-region skip
  3. feat(typedoc) — image-resolution parity + siteUrl
  4. test(examples) — image, staticFiles, and siteUrl fixtures
  5. docs — Working with Images guide, siteUrl docs, ARCHITECTURE

Add a pure buildSitemapXml(siteUrl, basePath, slugs) and emit sitemap.xml at the
output root when RenderOptions.siteUrl is set — one <loc> per non-hidden page,
so hidden source-viewer pages are excluded. Only siteUrl's origin is used; the
deploy sub-path comes from theme.basePath, so the two never double-count.

Register siteUrl in utils' RenderOptions and THEME_OPT_KEYS.
… and comments

Only opts.docs images were copied into the build before. Route local images
referenced from tutorials, the README, and JSDoc-comment prose through the same
content-hashed _assets/ pipeline (Markdown and raw <img>), resolving comment
images against each doclet's own source file.

Also:
- Honor templates.default.staticFiles: copy the included files verbatim to the
  output root (JSDoc parity), and treat the include dirs as fallback search
  roots so a bare reference such as ![](classes-io.png) resolves and is hashed.
  A file already served from _assets/ is not duplicated at the root.
- Skip image syntax inside code spans / fenced blocks / <pre>/<code>, so example
  syntax shown in prose is left literal (no spurious copy or warning).
- Thread opts.siteUrl through to render() for sitemap.xml.
Mirror the JSDoc bridge in the TypeDoc plugin: resolve README and symbol-comment
images through the shared content-hashed _assets/ pipeline (handling raw <img>
and skipping code regions), and emit sitemap.xml when cleanJsdocTheme.siteUrl is
set.
basic: add an img/ directory, a "Working with Images" tutorial, a JSDoc-comment
image, a README image, templates.default.staticFiles.include, and siteUrl.
typedoc-basic: add a doc-comment image and siteUrl.
Add the "Working with Images" guide (en + hi/ja/zh) covering image resolution
across docs, tutorials, README, and JSDoc/TypeScript comments, plus
templates.default.staticFiles. Document the siteUrl option on the configuration
page in every locale, enable siteUrl on the docs-site itself, and update
ARCHITECTURE for the image pipeline, staticFiles, sitemap, and code-region skip.
@ankitskvmdam
ankitskvmdam merged commit a716b7d into master Jun 25, 2026
3 checks passed
@ankitskvmdam
ankitskvmdam deleted the feat/image-asset-resolution-sitemap branch July 1, 2026 16:32
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.

v4 to v5 migration notes

1 participant