UNPKG

@prismicio/client

Version:

The official JavaScript + TypeScript client library for Prismic

1 lines 1.13 kB
{"version":3,"file":"getOptionalLinkProperties.cjs","sources":["../../../src/lib/getOptionalLinkProperties.ts"],"sourcesContent":["import type { OptionalLinkProperties } from \"../types/value/link\"\n\n/**\n * Returns optional properties only available to link fields. Link fields can\n * have the same shape as content relationship and link to media fields,\n * requiring special treatment to extract link-specific properties.\n *\n * @param input - The content relationship or link to media field from which the\n * link properties will be extracted.\n *\n * @returns Optional link properties that `input` might have.\n */\nexport const getOptionalLinkProperties = (\n\tinput: OptionalLinkProperties,\n): OptionalLinkProperties => {\n\tconst res: OptionalLinkProperties = {}\n\n\tif (\"text\" in input) {\n\t\tres.text = input.text\n\t}\n\n\tif (\"variant\" in input) {\n\t\tres.variant = input.variant\n\t}\n\n\treturn res\n}\n"],"names":[],"mappings":";;AAYa,MAAA,4BAA4B,CACxC,UAC2B;AAC3B,QAAM,MAA8B,CAAA;AAEpC,MAAI,UAAU,OAAO;AACpB,QAAI,OAAO,MAAM;AAAA,EAAA;AAGlB,MAAI,aAAa,OAAO;AACvB,QAAI,UAAU,MAAM;AAAA,EAAA;AAGd,SAAA;AACR;;"}