@lucidcms/core
Version:
The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.
1 lines • 1.59 kB
Source Map (JSON)
{"version":3,"file":"process-field-values.mjs","names":[],"sources":["../../../../src/services/documents-bricks/helpers/process-field-values.ts"],"sourcesContent":["import type {\n\tFieldInputSchema,\n\tInternalDocumentField,\n} from \"../../../types.js\";\n\n/**\n * Process fields and return field values by locale\n */\nconst processFieldValues = (\n\tfield: FieldInputSchema | InternalDocumentField,\n\tlocales: string[],\n\tdefaultLocale: string,\n): Map<string, unknown> => {\n\tconst valuesByLocale = new Map<string, unknown>();\n\n\tif (field.translations) {\n\t\tfor (const locale of locales) {\n\t\t\tif (field.translations[locale] !== undefined) {\n\t\t\t\tvaluesByLocale.set(locale, field.translations[locale]);\n\t\t\t} else {\n\t\t\t\tvaluesByLocale.set(locale, null);\n\t\t\t}\n\t\t}\n\t} else if (field.value !== undefined) {\n\t\tfor (const locale of locales) {\n\t\t\tif (locale === defaultLocale) {\n\t\t\t\tvaluesByLocale.set(locale, field.value);\n\t\t\t} else {\n\t\t\t\tvaluesByLocale.set(locale, null);\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfor (const locale of locales) {\n\t\t\tvaluesByLocale.set(locale, null);\n\t\t}\n\t}\n\n\treturn valuesByLocale;\n};\n\nexport default processFieldValues;\n"],"mappings":"AAQA,MAAM,GACL,EACA,EACA,IAC0B,CAC1B,IAAM,EAAiB,IAAI,IAE3B,GAAI,EAAM,aACT,IAAK,IAAM,KAAU,EAChB,EAAM,aAAa,KAAY,IAAA,GAGlC,EAAe,IAAI,EAAQ,IAAI,EAF/B,EAAe,IAAI,EAAQ,EAAM,aAAa,EAAO,OAKjD,GAAI,EAAM,QAAU,IAAA,GAC1B,IAAK,IAAM,KAAU,EAChB,IAAW,EACd,EAAe,IAAI,EAAQ,EAAM,KAAK,EAEtC,EAAe,IAAI,EAAQ,IAAI,OAIjC,IAAK,IAAM,KAAU,EACpB,EAAe,IAAI,EAAQ,IAAI,EAIjC,OAAO,CACR"}