feat: define closed portfolio input contract

This commit is contained in:
2026-09-02 00:31:43 +03:00
parent 51af112e21
commit 4a704d89f7
20 changed files with 819 additions and 0 deletions

12
src/content/asset-url.ts Normal file
View File

@@ -0,0 +1,12 @@
import type { PublicAssetManifest } from './types.ts';
export const assetUrl = (manifest: PublicAssetManifest, assetId: string, base = '/assets/'): string => {
if (!base.startsWith('/') || base.startsWith('//') || /[?#]/u.test(base)) {
throw new Error('Asset URL base must be an absolute path without a query or fragment.');
}
const asset = manifest.assets.find((candidate) => candidate.id === assetId);
if (asset === undefined) {
throw new Error(`Unknown asset ID: ${assetId}`);
}
return `${base.endsWith('/') ? base : `${base}/`}${encodeURIComponent(asset.fileName)}`;
};