Repository navigation
feat: fall back to a bundled preview image for theme listings - #21
Merged
Merged
Conversation
A theme with an empty `screenshots_json` previously fell straight through to
the CSS mock box, so a shipped theme could look unfinished even when a real
preview existed. Add a middle step: when the row has no screenshots, use a
preview bundled with the site at `public/images/previews/<id>.png` if one
exists, and only then show the mock box.
Preference order is now: row screenshots -> bundled preview -> mock box.
Existence cannot be probed at request time because a Cloudflare Worker has no
filesystem, so the page resolves which ids ship a preview at build time with an
eager `import.meta.glob(..., { query: '?url' })`. The selection itself is pure
logic and lives in `src/lib/theme.ts` as `themeGallery()` with unit tests.
Also adds the first bundled preview, extracted from the anime-tsundere
`.orskin` bundle.
Co-authored-by: openhands <openhands@all-hands.dev>
Deploying openrom-store with
|
| Latest commit: |
89f8011
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://fec2111f.openrom-store.pages.dev |
| Branch Preview URL: | https://feat-theme-preview-fallback.openrom-store.pages.dev |
|
Caution Review failedThe pull request is closed. Walkthrough
Merge Risk:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
A theme with an empty
screenshots_jsonpreviously fell straight through to the CSS mock box, so a shipped theme could look unfinished even when a real preview existed. This adds a middle step: when a row has no screenshots, use a preview bundled with the site atpublic/images/previews/<id>.pngif one exists — and only then show the mock box.Preference order is now: row screenshots → bundled preview → mock box.
flowchart TD A[Theme listing] --> B{screenshots_json<br/>non-empty?} B -->|yes| C[Gallery: DB screenshots] B -->|no| D{bundled preview<br/>public/images/previews/<id>.png?} D -->|yes| E[Gallery: bundled preview] D -->|no| F[CSS mock box]Why the glob
Existence cannot be probed at request time: a Cloudflare Worker has no filesystem. The page therefore resolves which ids ship a preview at build time with an eager
import.meta.glob('../../../public/images/previews/*.png', { query: '?url' }), which bakes the id list into the worker. The selection itself is pure logic, so it lives insrc/lib/theme.tsasthemeGallery()and is unit-tested.Note: the glob path is relative to the
.astrofile's directory, sosrc/pages/plugin/needs three../.Files
src/lib/theme.tsthemeGallery(id, screenshots, hasBundledPreview)helpersrc/pages/plugin/[id].astroshowGallery/showMockupwiringtests/theme.test.tsthemeGallerypublic/images/previews/anime-tsundere.png.orskinVerification
npm test→ 95/95 pass (was 91; +4 new)npm run build→ clean;npx tsc --noEmit→ zero errors insrc/(only the pre-existingastro.config.mjsvite-duplication error)wrangler pages dev dist+ local D1 rows — all three branches confirmed on real rendered HTML:screenshots_jsoncyberpunk-neon["/images/romeo-banner.png"]anime-tsundere[]/images/previews/anime-tsundere.pngmockonly-test[]The served preview image was byte-identical (SHA-256
8501d08f…eff85d). Temporary test rows and scratch pages were removed.This pull request was created by an AI agent (OpenHands) on behalf of the repository maintainer.
Summary by CodeRabbit