diff options
| author | Volpeon <git@volpeon.ink> | 2026-07-26 11:57:13 +0200 |
|---|---|---|
| committer | Volpeon <git@volpeon.ink> | 2026-07-26 11:57:13 +0200 |
| commit | 5c899b4a5c2c07398151960b2b86d238b49d5bf4 (patch) | |
| tree | ccc743f27ba234a25396cb24b6124c139d13b027 /src/schemas/common.ts | |
| parent | Use Corvos 0.1.4 (diff) | |
| download | corvos-website-master.tar.gz corvos-website-master.tar.bz2 corvos-website-master.zip | |
Diffstat (limited to 'src/schemas/common.ts')
| -rw-r--r-- | src/schemas/common.ts | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/schemas/common.ts b/src/schemas/common.ts new file mode 100644 index 0000000..ef1fefd --- /dev/null +++ b/src/schemas/common.ts | |||
| @@ -0,0 +1,17 @@ | |||
| 1 | import { fileAttributeSchema, imageAttributeSchema } from "$/deps/strapi.ts"; | ||
| 2 | |||
| 3 | const publicUrl = Deno.env.get("STRAPI_PUBLIC_URL") ?? Deno.env.get("STRAPI_URL"); | ||
| 4 | |||
| 5 | export const resolvedFileAttributeSchema = fileAttributeSchema.pipe( | ||
| 6 | ({ url, previewUrl, ...o }) => ({ | ||
| 7 | ...o, | ||
| 8 | url: new URL(url, publicUrl).href, | ||
| 9 | ...(previewUrl ? { previewUrl: new URL(previewUrl, publicUrl).href } : {}), | ||
| 10 | }), | ||
| 11 | ); | ||
| 12 | |||
| 13 | export const resolvedImageAttributeSchema = imageAttributeSchema.pipe((o) => ({ | ||
| 14 | ...o, | ||
| 15 | previewUrl: o.previewUrl ? new URL(o.previewUrl, publicUrl).href : undefined, | ||
| 16 | url: new URL(o.url, publicUrl).href, | ||
| 17 | })); | ||
