UNPKG

@lucidcms/core

Version:

The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.

1 lines 1.17 kB
{"version":3,"file":"format-ref.mjs","names":["mediaFormatter"],"sources":["../../../../../../src/libs/collection/custom-fields/fields/media/format-ref.ts"],"sourcesContent":["import type { MediaPropsT } from \"../../../../formatters/media.js\";\nimport mediaFormatter from \"../../../../formatters/media.js\";\nimport type { CFResponse, FieldRefParams } from \"../../types.js\";\n\nconst isMediaProps = (value: unknown): value is MediaPropsT => {\n\tif (typeof value !== \"object\" || value === null) return false;\n\n\treturn \"id\" in value && \"key\" in value && \"mime_type\" in value;\n};\n\nconst formatMediaRef = (\n\tvalue: unknown,\n\tparams: FieldRefParams,\n): CFResponse<\"media\">[\"ref\"] => {\n\tif (!isMediaProps(value)) return null;\n\n\treturn mediaFormatter.formatRef({\n\t\tmedia: value,\n\t\thost: params.host,\n\t\tlocales: params.localization.locales,\n\t}) satisfies CFResponse<\"media\">[\"ref\"];\n};\n\nexport default formatMediaRef;\n"],"mappings":"gDAIA,MAAM,EAAgB,GACjB,OAAO,GAAU,WAAY,EAAuB,GAEjD,OAAQ,GAAS,QAAS,GAAS,cAAe,EAGpD,GACL,EACA,IAEK,EAAa,CAAK,EAEhBA,EAAe,UAAU,CAC/B,MAAO,EACP,KAAM,EAAO,KACb,QAAS,EAAO,aAAa,OAC9B,CAAC,EANgC"}