How to use the datocms-client.buildField 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 / createItemNodes.js View on Github external
var _require = require('humps'),
    camelize = _require.camelize,
    pascalize = _require.pascalize;

var initNodeFromEntity = require('./initNodeFromEntity');
var addDigestToNode = require('./addDigestToNode');
var mId = require('./makeId');
var createTextNode = require('./createTextNode');
var createAssetNode = require('./createAssetNode');
var createSeoMetaTagsNode = require('./createSeoMetaTagsNode');

var _require2 = require('datocms-client'),
    Item = _require2.Item,
    i18n = _require2.i18n,
    buildField = _require2.buildField;

var objectEntries = require('object.entries');

var itemNodeId = function itemNodeId(repo, id, locale) {
  if (!id) {
    return null;
  }

  var itemEntity = repo.findEntity('item', id);
  return mId(itemEntity, locale);
};

module.exports = function createItemNodes(repo, itemsRepo, createNode) {
  var items = repo.findEntitiesOfType('item');
  var site = repo.findEntitiesOfType('site')[0];
github datocms / gatsby-source-datocms / createAssetNode.js View on Github external
'use strict';

var addDigestToNode = require('./addDigestToNode');

var _require = require('datocms-client'),
    buildField = _require.buildField;

var objectAssign = require('object-assign');

module.exports = function createAssetNode(parent, field, value, itemsRepo, createNode) {
  if (!value) {
    return null;
  }

  var node = objectAssign({
    id: 'DatoCmsAsset-' + value,
    parent: parent.id,
    children: [],
    internal: {
      type: 'DatoCmsAsset'
    }
  }, buildField('file', value, itemsRepo).toMap());