mirror of
https://github.com/nexu-io/open-design.git
synced 2026-06-01 03:14:35 +07:00
fix(landing): keep template preview lookup stable in CI (#2412)
Resolve generated preview thumbnails from both workspace-root and package-root build layouts so Astro production builds can see the images created by the landing preview step. A later merge restored the source-relative lookup, which made /templates render 111 cards with placeholder thumbs despite the PNG files being deployed. Co-authored-by: ashley li <ashleyli@ashleydeMacBook-Air-2.local> Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
41a33aed9e
commit
e4d6d4e805
1 changed files with 15 additions and 4 deletions
|
|
@ -21,9 +21,18 @@ import path from 'node:path';
|
|||
// a `previewUrl` (or `null` when the underlying skill has no `example.html`).
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
const PREVIEWS_ROOT = path.resolve(
|
||||
fileURLToPath(new URL('../../public/previews', import.meta.url)),
|
||||
);
|
||||
const PREVIEWS_ROOT_CANDIDATES = [
|
||||
// `pnpm --filter @open-design/landing-page build` may keep cwd at the
|
||||
// workspace root, while direct package scripts run from the app root.
|
||||
path.resolve(process.cwd(), 'apps/landing-page/public/previews'),
|
||||
path.resolve(process.cwd(), 'public/previews'),
|
||||
// Keep the source-relative path as a final fallback for local dev.
|
||||
path.resolve(fileURLToPath(new URL('../../public/previews', import.meta.url))),
|
||||
] as const;
|
||||
|
||||
function previewRoot(): string | null {
|
||||
return PREVIEWS_ROOT_CANDIDATES.find((dir) => existsSync(dir)) ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Map of `slug → filename`, e.g. `'kami-deck' → 'kami-deck.webp'`.
|
||||
|
|
@ -36,7 +45,9 @@ const PREVIEWS_ROOT = path.resolve(
|
|||
* template asset).
|
||||
*/
|
||||
function listPreviews(bucket: 'skills' | 'systems' | 'templates'): Map<string, string> {
|
||||
const dir = path.join(PREVIEWS_ROOT, bucket);
|
||||
const root = previewRoot();
|
||||
if (!root) return new Map();
|
||||
const dir = path.join(root, bucket);
|
||||
if (!existsSync(dir)) return new Map();
|
||||
const map = new Map<string, string>();
|
||||
for (const file of readdirSync(dir)) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue