How to use the datocms-client.localizedRead function in datocms-client

To help you get started, we’ve selected a few datocms-client examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github datocms / gatsby-source-datocms / src / hooks / sourceNodes / createNodeFromEntity / item / addField.js View on Github external
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),
      );
github datocms / gatsby-source-datocms / src / hooks / sourceNodes / createNodeFromEntity / site / index.js View on Github external
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 &&