[AI Slop🤖] Implement lazy loading and fixed image size for documentation and about page#47
Conversation
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
ani-website | 95fc2ad | Commit Preview URL Branch Preview URL |
May 11 2026, 01:51 PM |
Agent-Logs-Url: https://github.com/open-ani/ani-website/sessions/fcdf4390-451a-4af0-839d-09acdab43f61 Co-authored-by: nick-cjyx9 <119087246+nick-cjyx9@users.noreply.github.com>
|
Agent-Logs-Url: https://github.com/open-ani/ani-website/sessions/733c5fd9-448f-4ee4-ab3f-34aaf0d95d2d Co-authored-by: nick-cjyx9 <119087246+nick-cjyx9@users.noreply.github.com>
已在 3bfa430 中更新:
|
|
@copilot /about 中对于人为指定了长宽之一的 |
…arly-return Agent-Logs-Url: https://github.com/open-ani/ani-website/sessions/bed598a5-be3b-4ec7-96d0-bf4864f51988 Co-authored-by: nick-cjyx9 <119087246+nick-cjyx9@users.noreply.github.com>
已在 da4e664 中修复: SVG 宽高注入:将 inline |
Prevents CLS (Cumulative Layout Shift) by injecting image dimensions and lazy-loading attributes at build time via a rehype plugin, and adds a skeleton placeholder with a smooth fade-in transition when images finish loading.
Changes Made
src/plugins/rehypeMarkdownImages.ts— build-time rehype plugin that injectsloading="lazy",decoding="async", inferredwidth/height(from a static dimension map with aspect-ratio inference), andlazy-image is-loadingCSS classes on all markdown<img>elements, including inline HTML images in/about. Dimension injection (including aspect-ratio inference when only one of width/height is provided) now runs for all image types before the SVG early-return, so SVGs also receive correctwidth/heightattributes./images/animeko.svg(1280×640) is included in the dimension map.src/scripts/enhanceMarkdownImages.ts— lightweight client script (used by bothDoc.astroandPost.astro) that transitionsis-loading→is-loaded/is-erroronload/errorevents; uses aWeakSetfor idempotent registration without polluting the DOMsrc/styles/markdown.css— skeleton pulse animation (markdown-image-pulse) during load, and amarkdown-image-fade-inkeyframe (opacity 0 → 1, 0.35s ease,fill-mode: forwards) applied to.is-loadedfor a natural fade-in after the skeleton clears;is-errordims the image withopacity: 0.6astro.config.mjs— registersrehypeMarkdownImagesas the first rehype pluginsrc/content/wiki/macos-intel-install.md— updates inline<img>to use explicitwidth/heightwithstyle="width:20%"for responsive sizingCoverage
The rehype plugin runs after Astro's internal
rehype-rawpass, so it processes both standard markdown images and raw inline HTML<img>tags (including those in the/aboutpage tables). Inline<img>elements with only one dimension manually set (e.g.width="200") have the missing dimension automatically inferred from the known aspect ratio. BothDoc.astro(wiki pages) andPost.astro(about/posts) callenhanceMarkdownImages().Testing
astro check) passes