Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions site/scripts/lib/search/build-index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,18 @@ async function fetchIndexEntries(): Promise<IndexEntry[] | null> {
const apiUrl = (process.env.PUBLIC_HUB_API_URL || '').replace(/\/$/, '');
if (!apiUrl) return null;
try {
const res = await fetch(`${apiUrl}/api/hub/workflows/index`);
// Match hub-api.ts listWorkflowIndex(): preview builds request all statuses
// so the search index includes pending/rejected/deprecated workflows too.
// Production builds (PUBLIC_APPROVED_ONLY=true) request only approved.
const approvedOnly = process.env.PUBLIC_APPROVED_ONLY === 'true';
const statuses = approvedOnly
? 'approved'
: 'pending,approved,rejected,deprecated';
const res = await fetch(`${apiUrl}/api/hub/workflows/index?status=${statuses}`);
if (!res.ok) return null;
return (await res.json()) as IndexEntry[];
const entries = (await res.json()) as IndexEntry[];
// Return null on empty array so the caller falls back to content collection
return entries.length > 0 ? entries : null;
} catch {
return null;
}
Expand Down
Loading