Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports = function addField(
root,
key,
entity,
field,
node,
entitiesRepo,
i18n,
additionalNodesToCreate,
additionalNodesPrefix = ''
) {
const value = localizedRead(
entity,
camelize(field.apiKey),
field.localized,
i18n,
);
switch (field.fieldType) {
case 'link': {
root[`${key}___NODE`] = itemNodeId(value, i18n.locale, entitiesRepo);
break;
}
case 'rich_text':
case 'links': {
root[`${key}___NODE`] = (value || []).map(id =>
itemNodeId(id, i18n.locale, entitiesRepo),
);
node => {
node.locale = locale;
['name', 'locales', 'domain', 'internalDomain', 'noIndex'].forEach(
key => (node[key] = entity[key]),
);
const globalSeo = localizedRead(
entity,
'globalSeo',
entity.locales.length > 1,
i18n,
);
if (globalSeo) {
node.globalSeo = objectAssign({}, globalSeo);
if (globalSeo.fallbackSeo) {
node.globalSeo.fallbackSeo = {
title: node.globalSeo.fallbackSeo.title,
description: node.globalSeo.fallbackSeo.description,
twitterCard: node.globalSeo.fallbackSeo.twitterCard,
image___NODE:
node.globalSeo.fallbackSeo.image &&