@prismicio/api-renderer
Advanced tools
Comparing version 3.2.4-alpha.12 to 3.2.4-alpha.13
import type { LinkConfig } from "@prismicio/types-internal/lib/customtypes"; | ||
import * as t from "io-ts"; | ||
declare const codec: t.IntersectionC<[t.PartialC<{ | ||
declare const codec: t.PartialC<{ | ||
select: t.UnionC<[t.LiteralC<"any">, t.NullC, t.UndefinedC]>; | ||
}>, t.PartialC<{ | ||
allowText: t.BooleanC; | ||
}>]>; | ||
}>; | ||
export type AnyLinkDef = { | ||
@@ -9,0 +8,0 @@ select: null; |
@@ -8,10 +8,6 @@ "use strict"; | ||
const t = tslib_1.__importStar(require("io-ts")); | ||
const codec = t.intersection([ | ||
t.partial({ | ||
select: t.union([t.literal("any"), t.null, t.undefined]), | ||
}), | ||
t.partial({ | ||
allowText: t.boolean, | ||
}), | ||
]); | ||
const codec = t.partial({ | ||
select: t.union([t.literal("any"), t.null, t.undefined]), | ||
allowText: t.boolean, | ||
}); | ||
exports.AnyLinkDef = new t.Type("AnyLinkDef", (u) => u.select === "any", (u) => { | ||
@@ -18,0 +14,0 @@ return (0, function_1.pipe)(codec.decode(u), fp_ts_1.either.map((decoded) => { |
@@ -5,18 +5,10 @@ "use strict"; | ||
renderV1(link) { | ||
let render = { | ||
...(link.text && { text: link.text }), | ||
}; | ||
if ("url" in link) { | ||
const target = typeof link.target === "string" ? { target: link.target } : {}; | ||
render = { | ||
...render, | ||
url: link.url, | ||
...target, | ||
...(link.text && { text: link.text }), | ||
}; | ||
} | ||
return { | ||
type: "Link.web", | ||
value: { | ||
...render, | ||
...("url" in link && { | ||
url: link.url, | ||
...(typeof link.target === "string" && { target: link.target }), | ||
}), | ||
...(link.text && { text: link.text }), | ||
}, | ||
@@ -26,17 +18,9 @@ }; | ||
renderV2(def, link) { | ||
let render = { | ||
...(def.allowText && link.text && { text: link.text }), | ||
}; | ||
if ("url" in link) { | ||
const target = typeof link.target === "string" ? { target: link.target } : {}; | ||
render = { | ||
...render, | ||
url: link.url, | ||
...target, | ||
...(def.allowText && link.text && { text: link.text }), | ||
}; | ||
} | ||
return { | ||
link_type: "Web", | ||
...render, | ||
...("url" in link && { | ||
url: link.url, | ||
...(typeof link.target === "string" && { target: link.target }), | ||
}), | ||
...(def.allowText && link.text && { text: link.text }), | ||
}; | ||
@@ -43,0 +27,0 @@ }, |
@@ -5,18 +5,14 @@ "use strict"; | ||
renderV1(link) { | ||
let render = { | ||
kind: link.kind, | ||
...(link.text && { text: link.text }), | ||
}; | ||
if ("url" in link) { | ||
render = { | ||
...render, | ||
name: link.name, | ||
url: ctx.urlRewriter.rewriteFileUrl(link.url), | ||
size: link.size, | ||
}; | ||
} | ||
return { | ||
type: "Link.file", | ||
value: { | ||
file: render, | ||
file: { | ||
kind: link.kind, | ||
...("url" in link && { | ||
url: ctx.urlRewriter.rewriteFileUrl(link.url), | ||
name: link.name, | ||
size: link.size, | ||
}), | ||
...(link.text && { text: link.text }), | ||
}, | ||
}, | ||
@@ -26,17 +22,13 @@ }; | ||
renderV2(def, link) { | ||
let render = { | ||
return { | ||
link_type: "Media", | ||
kind: link.kind, | ||
...(def.allowText && link.text && { text: link.text }), | ||
}; | ||
if ("url" in link) { | ||
render = { | ||
...render, | ||
...("url" in link && { | ||
id: link.id, | ||
url: ctx.urlRewriter.rewriteFileUrl(link.url), | ||
name: link.name, | ||
url: ctx.urlRewriter.rewriteFileUrl(link.url), | ||
size: link.size, | ||
}; | ||
} | ||
return render; | ||
}), | ||
...(def.allowText && link.text && { text: link.text }), | ||
}; | ||
}, | ||
@@ -43,0 +35,0 @@ renderMocks(def, link) { |
@@ -5,21 +5,17 @@ "use strict"; | ||
renderV1(link) { | ||
let render = { | ||
kind: link.kind, | ||
...(link.text && { text: link.text }), | ||
}; | ||
if ("url" in link) { | ||
render = { | ||
...render, | ||
id: link.id, | ||
name: link.name, | ||
url: ctx.urlRewriter.optimizeImageUrl(link.url), | ||
size: link.size, | ||
height: link.height, | ||
width: link.width, | ||
}; | ||
} | ||
return { | ||
type: "Link.image", | ||
value: { | ||
image: render, | ||
image: { | ||
kind: link.kind, | ||
...("url" in link && { | ||
id: link.id, | ||
url: ctx.urlRewriter.optimizeImageUrl(link.url), | ||
name: link.name, | ||
size: link.size, | ||
width: link.width, | ||
height: link.height, | ||
}), | ||
...(link.text && { text: link.text }), | ||
}, | ||
}, | ||
@@ -29,19 +25,15 @@ }; | ||
renderV2(def, link) { | ||
let render = { | ||
return { | ||
link_type: "Media", | ||
kind: link.kind, | ||
...(def.allowText && link.text && { text: link.text }), | ||
}; | ||
if ("url" in link) { | ||
render = { | ||
...render, | ||
...("url" in link && { | ||
id: link.id, | ||
url: ctx.urlRewriter.optimizeImageUrl(link.url), | ||
name: link.name, | ||
url: ctx.urlRewriter.optimizeImageUrl(link.url), | ||
size: link.size, | ||
width: link.width, | ||
height: link.height, | ||
width: link.width, | ||
}; | ||
} | ||
return render; | ||
}), | ||
...(def.allowText && link.text && { text: link.text }), | ||
}; | ||
}, | ||
@@ -48,0 +40,0 @@ renderMocks(def, link) { |
@@ -85,3 +85,3 @@ "use strict"; | ||
renderMocks(def, content) { | ||
if (content.value.__TYPE__ === "ImageLink" && ((0, models_1.isMediaLinkDef)(def) || (0, models_1.isAnyLinkDef)(def))) { | ||
if (((0, models_1.isMediaLinkDef)(def) || (0, models_1.isAnyLinkDef)(def)) && content.value.__TYPE__ === "ImageLink") { | ||
return (0, ImageLinkRenderer_1.default)(ctx).renderMocks(def.config, content.value); | ||
@@ -88,0 +88,0 @@ } |
import type { MediaLinkContent } from "@prismicio/types-internal/lib/content"; | ||
import type { MediaLinkDef, LinkRenderer } from "../../../models"; | ||
import type { LinkRenderer, MediaLinkDef } from "../../../models"; | ||
declare const MediaLinkRenderer: LinkRenderer<MediaLinkDef, MediaLinkContent>; | ||
export default MediaLinkRenderer; |
@@ -286,2 +286,3 @@ import type { RenderContext } from "../models"; | ||
date?: string | null | undefined; | ||
} & { | ||
text?: string | undefined; | ||
@@ -301,2 +302,3 @@ }) | { | ||
date?: string | null | undefined; | ||
} & { | ||
text?: string | undefined; | ||
@@ -325,2 +327,3 @@ }) | { | ||
} | null | undefined; | ||
} & { | ||
text?: string | undefined; | ||
@@ -369,3 +372,3 @@ }) | { | ||
__TYPE__: "ImageLink"; | ||
} & (({ | ||
} & { | ||
kind: "image"; | ||
@@ -380,9 +383,5 @@ id: string; | ||
date?: string | null | undefined; | ||
text?: string | undefined; | ||
}) | { | ||
kind: "image"; | ||
text: string; | ||
})) | ({ | ||
}) | ({ | ||
__TYPE__: "FileLink"; | ||
} & (({ | ||
} & { | ||
kind: "file"; | ||
@@ -395,23 +394,9 @@ id: string; | ||
date?: string | null | undefined; | ||
text?: string | undefined; | ||
}) | { | ||
kind: "file"; | ||
text: string; | ||
})) | ({ | ||
__TYPE__: "MediaLink"; | ||
} & { | ||
kind: "media"; | ||
text: string; | ||
}) | ({ | ||
__TYPE__: "DocumentLink"; | ||
} & (({ | ||
} & { | ||
id: string; | ||
}) | ({ | ||
__TYPE__: "ExternalLink"; | ||
} & { | ||
text?: string | undefined; | ||
}) | { | ||
kind: "document"; | ||
text: string; | ||
})) | ({ | ||
__TYPE__: "ExternalLink"; | ||
} & (({ | ||
url: string; | ||
@@ -424,10 +409,2 @@ } & { | ||
} | null | undefined; | ||
text?: string | undefined; | ||
}) | { | ||
kind: "web"; | ||
text: string; | ||
})) | ({ | ||
__TYPE__: "AnyLink"; | ||
} & { | ||
text: string; | ||
}) | null | undefined; | ||
@@ -470,3 +447,3 @@ }; | ||
__TYPE__: "ImageLink"; | ||
} & (({ | ||
} & { | ||
kind: "image"; | ||
@@ -481,9 +458,5 @@ id: string; | ||
date?: string | null | undefined; | ||
text?: string | undefined; | ||
}) | { | ||
kind: "image"; | ||
text: string; | ||
})) | ({ | ||
}) | ({ | ||
__TYPE__: "FileLink"; | ||
} & (({ | ||
} & { | ||
kind: "file"; | ||
@@ -496,23 +469,9 @@ id: string; | ||
date?: string | null | undefined; | ||
text?: string | undefined; | ||
}) | { | ||
kind: "file"; | ||
text: string; | ||
})) | ({ | ||
__TYPE__: "MediaLink"; | ||
} & { | ||
kind: "media"; | ||
text: string; | ||
}) | ({ | ||
__TYPE__: "DocumentLink"; | ||
} & (({ | ||
} & { | ||
id: string; | ||
}) | ({ | ||
__TYPE__: "ExternalLink"; | ||
} & { | ||
text?: string | undefined; | ||
}) | { | ||
kind: "document"; | ||
text: string; | ||
})) | ({ | ||
__TYPE__: "ExternalLink"; | ||
} & (({ | ||
url: string; | ||
@@ -525,10 +484,2 @@ } & { | ||
} | null | undefined; | ||
text?: string | undefined; | ||
}) | { | ||
kind: "web"; | ||
text: string; | ||
})) | ({ | ||
__TYPE__: "AnyLink"; | ||
} & { | ||
text: string; | ||
}); | ||
@@ -838,2 +789,3 @@ start: number; | ||
date?: string | null | undefined; | ||
} & { | ||
text?: string | undefined; | ||
@@ -853,2 +805,3 @@ }) | { | ||
date?: string | null | undefined; | ||
} & { | ||
text?: string | undefined; | ||
@@ -877,2 +830,3 @@ }) | { | ||
} | null | undefined; | ||
} & { | ||
text?: string | undefined; | ||
@@ -921,3 +875,3 @@ }) | { | ||
__TYPE__: "ImageLink"; | ||
} & (({ | ||
} & { | ||
kind: "image"; | ||
@@ -932,9 +886,5 @@ id: string; | ||
date?: string | null | undefined; | ||
text?: string | undefined; | ||
}) | { | ||
kind: "image"; | ||
text: string; | ||
})) | ({ | ||
}) | ({ | ||
__TYPE__: "FileLink"; | ||
} & (({ | ||
} & { | ||
kind: "file"; | ||
@@ -947,23 +897,9 @@ id: string; | ||
date?: string | null | undefined; | ||
text?: string | undefined; | ||
}) | { | ||
kind: "file"; | ||
text: string; | ||
})) | ({ | ||
__TYPE__: "MediaLink"; | ||
} & { | ||
kind: "media"; | ||
text: string; | ||
}) | ({ | ||
__TYPE__: "DocumentLink"; | ||
} & (({ | ||
} & { | ||
id: string; | ||
}) | ({ | ||
__TYPE__: "ExternalLink"; | ||
} & { | ||
text?: string | undefined; | ||
}) | { | ||
kind: "document"; | ||
text: string; | ||
})) | ({ | ||
__TYPE__: "ExternalLink"; | ||
} & (({ | ||
url: string; | ||
@@ -976,10 +912,2 @@ } & { | ||
} | null | undefined; | ||
text?: string | undefined; | ||
}) | { | ||
kind: "web"; | ||
text: string; | ||
})) | ({ | ||
__TYPE__: "AnyLink"; | ||
} & { | ||
text: string; | ||
}) | null | undefined; | ||
@@ -1022,3 +950,3 @@ }; | ||
__TYPE__: "ImageLink"; | ||
} & (({ | ||
} & { | ||
kind: "image"; | ||
@@ -1033,9 +961,5 @@ id: string; | ||
date?: string | null | undefined; | ||
text?: string | undefined; | ||
}) | { | ||
kind: "image"; | ||
text: string; | ||
})) | ({ | ||
}) | ({ | ||
__TYPE__: "FileLink"; | ||
} & (({ | ||
} & { | ||
kind: "file"; | ||
@@ -1048,23 +972,9 @@ id: string; | ||
date?: string | null | undefined; | ||
text?: string | undefined; | ||
}) | { | ||
kind: "file"; | ||
text: string; | ||
})) | ({ | ||
__TYPE__: "MediaLink"; | ||
} & { | ||
kind: "media"; | ||
text: string; | ||
}) | ({ | ||
__TYPE__: "DocumentLink"; | ||
} & (({ | ||
} & { | ||
id: string; | ||
}) | ({ | ||
__TYPE__: "ExternalLink"; | ||
} & { | ||
text?: string | undefined; | ||
}) | { | ||
kind: "document"; | ||
text: string; | ||
})) | ({ | ||
__TYPE__: "ExternalLink"; | ||
} & (({ | ||
url: string; | ||
@@ -1077,10 +987,2 @@ } & { | ||
} | null | undefined; | ||
text?: string | undefined; | ||
}) | { | ||
kind: "web"; | ||
text: string; | ||
})) | ({ | ||
__TYPE__: "AnyLink"; | ||
} & { | ||
text: string; | ||
}); | ||
@@ -1087,0 +989,0 @@ start: number; |
@@ -627,2 +627,3 @@ import { GroupContent } from "@prismicio/types-internal/lib/content"; | ||
date?: string | null | undefined; | ||
} & { | ||
text?: string | undefined; | ||
@@ -642,2 +643,3 @@ }) | { | ||
date?: string | null | undefined; | ||
} & { | ||
text?: string | undefined; | ||
@@ -666,2 +668,3 @@ }) | { | ||
} | null | undefined; | ||
} & { | ||
text?: string | undefined; | ||
@@ -710,3 +713,3 @@ }) | { | ||
__TYPE__: "ImageLink"; | ||
} & (({ | ||
} & { | ||
kind: "image"; | ||
@@ -721,9 +724,5 @@ id: string; | ||
date?: string | null | undefined; | ||
text?: string | undefined; | ||
}) | { | ||
kind: "image"; | ||
text: string; | ||
})) | ({ | ||
}) | ({ | ||
__TYPE__: "FileLink"; | ||
} & (({ | ||
} & { | ||
kind: "file"; | ||
@@ -736,23 +735,9 @@ id: string; | ||
date?: string | null | undefined; | ||
text?: string | undefined; | ||
}) | { | ||
kind: "file"; | ||
text: string; | ||
})) | ({ | ||
__TYPE__: "MediaLink"; | ||
} & { | ||
kind: "media"; | ||
text: string; | ||
}) | ({ | ||
__TYPE__: "DocumentLink"; | ||
} & (({ | ||
} & { | ||
id: string; | ||
}) | ({ | ||
__TYPE__: "ExternalLink"; | ||
} & { | ||
text?: string | undefined; | ||
}) | { | ||
kind: "document"; | ||
text: string; | ||
})) | ({ | ||
__TYPE__: "ExternalLink"; | ||
} & (({ | ||
url: string; | ||
@@ -765,10 +750,2 @@ } & { | ||
} | null | undefined; | ||
text?: string | undefined; | ||
}) | { | ||
kind: "web"; | ||
text: string; | ||
})) | ({ | ||
__TYPE__: "AnyLink"; | ||
} & { | ||
text: string; | ||
}) | null | undefined; | ||
@@ -811,3 +788,3 @@ }; | ||
__TYPE__: "ImageLink"; | ||
} & (({ | ||
} & { | ||
kind: "image"; | ||
@@ -822,9 +799,5 @@ id: string; | ||
date?: string | null | undefined; | ||
text?: string | undefined; | ||
}) | { | ||
kind: "image"; | ||
text: string; | ||
})) | ({ | ||
}) | ({ | ||
__TYPE__: "FileLink"; | ||
} & (({ | ||
} & { | ||
kind: "file"; | ||
@@ -837,23 +810,9 @@ id: string; | ||
date?: string | null | undefined; | ||
text?: string | undefined; | ||
}) | { | ||
kind: "file"; | ||
text: string; | ||
})) | ({ | ||
__TYPE__: "MediaLink"; | ||
} & { | ||
kind: "media"; | ||
text: string; | ||
}) | ({ | ||
__TYPE__: "DocumentLink"; | ||
} & (({ | ||
} & { | ||
id: string; | ||
}) | ({ | ||
__TYPE__: "ExternalLink"; | ||
} & { | ||
text?: string | undefined; | ||
}) | { | ||
kind: "document"; | ||
text: string; | ||
})) | ({ | ||
__TYPE__: "ExternalLink"; | ||
} & (({ | ||
url: string; | ||
@@ -866,10 +825,2 @@ } & { | ||
} | null | undefined; | ||
text?: string | undefined; | ||
}) | { | ||
kind: "web"; | ||
text: string; | ||
})) | ({ | ||
__TYPE__: "AnyLink"; | ||
} & { | ||
text: string; | ||
}); | ||
@@ -1519,2 +1470,3 @@ start: number; | ||
date?: string | null | undefined; | ||
} & { | ||
text?: string | undefined; | ||
@@ -1534,2 +1486,3 @@ }) | { | ||
date?: string | null | undefined; | ||
} & { | ||
text?: string | undefined; | ||
@@ -1558,2 +1511,3 @@ }) | { | ||
} | null | undefined; | ||
} & { | ||
text?: string | undefined; | ||
@@ -1602,3 +1556,3 @@ }) | { | ||
__TYPE__: "ImageLink"; | ||
} & (({ | ||
} & { | ||
kind: "image"; | ||
@@ -1613,9 +1567,5 @@ id: string; | ||
date?: string | null | undefined; | ||
text?: string | undefined; | ||
}) | { | ||
kind: "image"; | ||
text: string; | ||
})) | ({ | ||
}) | ({ | ||
__TYPE__: "FileLink"; | ||
} & (({ | ||
} & { | ||
kind: "file"; | ||
@@ -1628,23 +1578,9 @@ id: string; | ||
date?: string | null | undefined; | ||
text?: string | undefined; | ||
}) | { | ||
kind: "file"; | ||
text: string; | ||
})) | ({ | ||
__TYPE__: "MediaLink"; | ||
} & { | ||
kind: "media"; | ||
text: string; | ||
}) | ({ | ||
__TYPE__: "DocumentLink"; | ||
} & (({ | ||
} & { | ||
id: string; | ||
}) | ({ | ||
__TYPE__: "ExternalLink"; | ||
} & { | ||
text?: string | undefined; | ||
}) | { | ||
kind: "document"; | ||
text: string; | ||
})) | ({ | ||
__TYPE__: "ExternalLink"; | ||
} & (({ | ||
url: string; | ||
@@ -1657,10 +1593,2 @@ } & { | ||
} | null | undefined; | ||
text?: string | undefined; | ||
}) | { | ||
kind: "web"; | ||
text: string; | ||
})) | ({ | ||
__TYPE__: "AnyLink"; | ||
} & { | ||
text: string; | ||
}) | null | undefined; | ||
@@ -1703,3 +1631,3 @@ }; | ||
__TYPE__: "ImageLink"; | ||
} & (({ | ||
} & { | ||
kind: "image"; | ||
@@ -1714,9 +1642,5 @@ id: string; | ||
date?: string | null | undefined; | ||
text?: string | undefined; | ||
}) | { | ||
kind: "image"; | ||
text: string; | ||
})) | ({ | ||
}) | ({ | ||
__TYPE__: "FileLink"; | ||
} & (({ | ||
} & { | ||
kind: "file"; | ||
@@ -1729,23 +1653,9 @@ id: string; | ||
date?: string | null | undefined; | ||
text?: string | undefined; | ||
}) | { | ||
kind: "file"; | ||
text: string; | ||
})) | ({ | ||
__TYPE__: "MediaLink"; | ||
} & { | ||
kind: "media"; | ||
text: string; | ||
}) | ({ | ||
__TYPE__: "DocumentLink"; | ||
} & (({ | ||
} & { | ||
id: string; | ||
}) | ({ | ||
__TYPE__: "ExternalLink"; | ||
} & { | ||
text?: string | undefined; | ||
}) | { | ||
kind: "document"; | ||
text: string; | ||
})) | ({ | ||
__TYPE__: "ExternalLink"; | ||
} & (({ | ||
url: string; | ||
@@ -1758,10 +1668,2 @@ } & { | ||
} | null | undefined; | ||
text?: string | undefined; | ||
}) | { | ||
kind: "web"; | ||
text: string; | ||
})) | ({ | ||
__TYPE__: "AnyLink"; | ||
} & { | ||
text: string; | ||
}); | ||
@@ -1768,0 +1670,0 @@ start: number; |
{ | ||
"name": "@prismicio/api-renderer", | ||
"version": "3.2.4-alpha.12", | ||
"version": "3.2.4-alpha.13", | ||
"description": "Prismic renderers for the content API", | ||
@@ -38,3 +38,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@prismicio/types-internal": "2.7.0-alpha.8", | ||
"@prismicio/types-internal": "2.7.0", | ||
"tslib": "^2.5.0", | ||
@@ -41,0 +41,0 @@ "uuid": "^9.0.0" |
@@ -6,10 +6,6 @@ import type { LinkConfig } from "@prismicio/types-internal/lib/customtypes" | ||
const codec = t.intersection([ | ||
t.partial({ | ||
select: t.union([t.literal("any"), t.null, t.undefined]), | ||
}), | ||
t.partial({ | ||
allowText: t.boolean, | ||
}), | ||
]) | ||
const codec = t.partial({ | ||
select: t.union([t.literal("any"), t.null, t.undefined]), | ||
allowText: t.boolean, | ||
}) | ||
@@ -16,0 +12,0 @@ export type AnyLinkDef = { |
@@ -7,21 +7,10 @@ import type { ExternalLinkContent } from "@prismicio/types-internal/lib/content" | ||
renderV1(link: ExternalLinkContent): unknown { | ||
let render: Record<string, unknown> = { | ||
...(link.text && { text: link.text }), | ||
} | ||
if ("url" in link) { | ||
const target = typeof link.target === "string" ? { target: link.target } : {} | ||
render = { | ||
...render, | ||
url: link.url, | ||
...target, | ||
...(link.text && { text: link.text }), | ||
} | ||
} | ||
return { | ||
type: "Link.web", | ||
value: { | ||
...render, | ||
...("url" in link && { | ||
url: link.url, | ||
...(typeof link.target === "string" && { target: link.target }), | ||
}), | ||
...(link.text && { text: link.text }), | ||
}, | ||
@@ -32,20 +21,9 @@ } | ||
renderV2(def: WebLinkDef | AnyLinkDef, link: ExternalLinkContent): unknown { | ||
let render: Record<string, unknown> = { | ||
...(def.allowText && link.text && { text: link.text }), | ||
} | ||
if ("url" in link) { | ||
const target = typeof link.target === "string" ? { target: link.target } : {} | ||
render = { | ||
...render, | ||
url: link.url, | ||
...target, | ||
...(def.allowText && link.text && { text: link.text }), | ||
} | ||
} | ||
return { | ||
link_type: "Web", | ||
...render, | ||
...("url" in link && { | ||
url: link.url, | ||
...(typeof link.target === "string" && { target: link.target }), | ||
}), | ||
...(def.allowText && link.text && { text: link.text }), | ||
} | ||
@@ -52,0 +30,0 @@ }, |
@@ -8,20 +8,14 @@ import type { FileLinkContent } from "@prismicio/types-internal/lib/content" | ||
renderV1(link: FileLinkContent): unknown { | ||
let render: Record<string, unknown> = { | ||
kind: link.kind, | ||
...(link.text && { text: link.text }), | ||
} | ||
if ("url" in link) { | ||
render = { | ||
...render, | ||
name: link.name, | ||
url: ctx.urlRewriter.rewriteFileUrl(link.url), | ||
size: link.size, | ||
} | ||
} | ||
return { | ||
type: "Link.file", | ||
value: { | ||
file: render, | ||
file: { | ||
kind: link.kind, | ||
...("url" in link && { | ||
url: ctx.urlRewriter.rewriteFileUrl(link.url), | ||
name: link.name, | ||
size: link.size, | ||
}), | ||
...(link.text && { text: link.text }), | ||
}, | ||
}, | ||
@@ -32,19 +26,13 @@ } | ||
renderV2(def: MediaLinkDef | AnyLinkDef, link: FileLinkContent): unknown { | ||
let render: Record<string, unknown> = { | ||
return { | ||
link_type: "Media", | ||
kind: link.kind, | ||
...(def.allowText && link.text && { text: link.text }), | ||
} | ||
if ("url" in link) { | ||
render = { | ||
...render, | ||
...("url" in link && { | ||
id: link.id, | ||
url: ctx.urlRewriter.rewriteFileUrl(link.url), | ||
name: link.name, | ||
url: ctx.urlRewriter.rewriteFileUrl(link.url), | ||
size: link.size, | ||
} | ||
}), | ||
...(def.allowText && link.text && { text: link.text }), | ||
} | ||
return render | ||
}, | ||
@@ -51,0 +39,0 @@ |
@@ -8,23 +8,17 @@ import type { ImageLinkContent } from "@prismicio/types-internal/lib/content" | ||
renderV1(link: ImageLinkContent): unknown { | ||
let render: Record<string, unknown> = { | ||
kind: link.kind, | ||
...(link.text && { text: link.text }), | ||
} | ||
if ("url" in link) { | ||
render = { | ||
...render, | ||
id: link.id, | ||
name: link.name, | ||
url: ctx.urlRewriter.optimizeImageUrl(link.url), | ||
size: link.size, | ||
height: link.height, | ||
width: link.width, | ||
} | ||
} | ||
return { | ||
type: "Link.image", | ||
value: { | ||
image: render, | ||
image: { | ||
kind: link.kind, | ||
...("url" in link && { | ||
id: link.id, | ||
url: ctx.urlRewriter.optimizeImageUrl(link.url), | ||
name: link.name, | ||
size: link.size, | ||
width: link.width, | ||
height: link.height, | ||
}), | ||
...(link.text && { text: link.text }), | ||
}, | ||
}, | ||
@@ -35,21 +29,15 @@ } | ||
renderV2(def: MediaLinkDef | AnyLinkDef, link: ImageLinkContent): unknown { | ||
let render: Record<string, unknown> = { | ||
return { | ||
link_type: "Media", | ||
kind: link.kind, | ||
...(def.allowText && link.text && { text: link.text }), | ||
} | ||
if ("url" in link) { | ||
render = { | ||
...render, | ||
...("url" in link && { | ||
id: link.id, | ||
url: ctx.urlRewriter.optimizeImageUrl(link.url), | ||
name: link.name, | ||
url: ctx.urlRewriter.optimizeImageUrl(link.url), | ||
size: link.size, | ||
width: link.width, | ||
height: link.height, | ||
width: link.width, | ||
} | ||
}), | ||
...(def.allowText && link.text && { text: link.text }), | ||
} | ||
return render | ||
}, | ||
@@ -56,0 +44,0 @@ |
@@ -73,3 +73,3 @@ import type { LinkContent } from "@prismicio/types-internal/lib/content" | ||
renderMocks(def: Link, content: LinkContent): unknown { | ||
if (content.value.__TYPE__ === "ImageLink" && (isMediaLinkDef(def) || isAnyLinkDef(def))) { | ||
if ((isMediaLinkDef(def) || isAnyLinkDef(def)) && content.value.__TYPE__ === "ImageLink") { | ||
return ImageLinkRenderer(ctx).renderMocks(def.config as MediaLinkDef | AnyLinkDef, content.value) | ||
@@ -76,0 +76,0 @@ } else if ((isDocumentLinkDef(def) || isAnyLinkDef(def)) && content.value.__TYPE__ === "DocumentLink") { |
import type { MediaLinkContent } from "@prismicio/types-internal/lib/content" | ||
import type { MediaLinkDef, LinkRenderer } from "../../../models" | ||
import type { LinkRenderer, MediaLinkDef } from "../../../models" | ||
@@ -5,0 +5,0 @@ const MediaLinkRenderer: LinkRenderer<MediaLinkDef, MediaLinkContent> = { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1049772
24895
+ Added@prismicio/types-internal@2.7.0(transitive)
- Removed@prismicio/types-internal@2.7.0-alpha.8(transitive)