blob: ef1fefdcd9c100aaf58e7f3e5d1fbe02a2b302d9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
import { fileAttributeSchema, imageAttributeSchema } from "$/deps/strapi.ts";
const publicUrl = Deno.env.get("STRAPI_PUBLIC_URL") ?? Deno.env.get("STRAPI_URL");
export const resolvedFileAttributeSchema = fileAttributeSchema.pipe(
({ url, previewUrl, ...o }) => ({
...o,
url: new URL(url, publicUrl).href,
...(previewUrl ? { previewUrl: new URL(previewUrl, publicUrl).href } : {}),
}),
);
export const resolvedImageAttributeSchema = imageAttributeSchema.pipe((o) => ({
...o,
previewUrl: o.previewUrl ? new URL(o.previewUrl, publicUrl).href : undefined,
url: new URL(o.url, publicUrl).href,
}));
|