summaryrefslogtreecommitdiffstats
path: root/src/schemas/common.ts
diff options
context:
space:
mode:
authorVolpeon <git@volpeon.ink>2026-07-26 11:57:13 +0200
committerVolpeon <git@volpeon.ink>2026-07-26 11:57:13 +0200
commit5c899b4a5c2c07398151960b2b86d238b49d5bf4 (patch)
treeccc743f27ba234a25396cb24b6124c139d13b027 /src/schemas/common.ts
parentUse Corvos 0.1.4 (diff)
downloadcorvos-website-5c899b4a5c2c07398151960b2b86d238b49d5bf4.tar.gz
corvos-website-5c899b4a5c2c07398151960b2b86d238b49d5bf4.tar.bz2
corvos-website-5c899b4a5c2c07398151960b2b86d238b49d5bf4.zip
Better Strapi integrationHEADmaster
Diffstat (limited to 'src/schemas/common.ts')
-rw-r--r--src/schemas/common.ts17
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 @@
1import { fileAttributeSchema, imageAttributeSchema } from "$/deps/strapi.ts";
2
3const publicUrl = Deno.env.get("STRAPI_PUBLIC_URL") ?? Deno.env.get("STRAPI_URL");
4
5export 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
13export 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}));