Skip to content

feat: initial static assets support#230

Draft
QuadnucYard wants to merge 2 commits intoMyriad-Dreamin:mainfrom
QuadnucYard:static-assets
Draft

feat: initial static assets support#230
QuadnucYard wants to merge 2 commits intoMyriad-Dreamin:mainfrom
QuadnucYard:static-assets

Conversation

@QuadnucYard
Copy link
Contributor

@QuadnucYard QuadnucYard commented Dec 15, 2025

This PR introduces initial support for static assets. This can significantly reduce the size of the output HTML by avoiding inlining large assets.

The source can emit static assets with a static-asset function, which injects metadata for link generation in <head> and server-side asset handling. It can take path, text, or bytes as source input.

We also provide a utility function: stylesheet(body, key, priority). Contents with the same key are merged by priority into one file, identified by key.

The mdbook theme has not changed yet.

For comparison, the dist size of shiroa docs reduces from 3.67 MiB to 2.87 MiB. With zebraw assets extraction, the size can be further reduced to 2.11 MiB.

TODO

  • Properly handle asset content conflicts. This can result from regular content update or inconsistent data provided from different pages.
  • Watch asset dependency change. Ensure that updated assets (referenced by path) can be updated to the dist.
  • Hot reload. Currently, when an asset file in the dist is modified, it is still cached in the browser. We need to manually trigger an update.
  • Image support. This will not be included in this PR, but we should consider its API design.

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