JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 21
  • Score
    100M100P100Q47718F
  • License MIT

Unofficial SDK for the Delivery part of Kentico Cloud

Package Exports

  • kentico-cloud-delivery-js-sdk

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (kentico-cloud-delivery-js-sdk) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Delivery SDK for Javascript

Unofficial SDK for the Delivery part of Kentico Cloud. Not production ready yet!

API

Delivery

Initilizes object with its Project ID that represents a Kentico Cloud project.

Parameters

Examples

var project = new Delivery('82594550-e25c-8219-aee9-677f600bad53');

getContentAsPromise

Returns promise with data specified by array of params.

Parameters

  • params array Url parameters that are used for requesting Kentico Cloud storage.

Examples

// returns [{items: [...]}, {items: [...]}]
project.getContentAsPromise(['?system.type=navigation', '?system.type=homepage'])

Returns promise Returns promise with array of responses for each passed parameter from the Kentico Cloud storage.

categorizeContent

Returns object where each content item is assigned to one category according to their position in given arrays. Number of content items and categories must match.

Parameters

  • content array Content items returned from the "getContentAsPromise" method.
  • categories array Names of categories.

Examples

// returns {navigation: {items: [...]}, homepage: {items: [...]}}
project.getContentAsPromise(['?system.type=navigation', '?system.type=homepage'])
.then(function (data) {
  return project.categorizeContent(data, ['navigation', 'homepage']);
})

Returns object Returns object where contect items are property values and categories are property name oereder by their position in given arrays.

getNeededValues

Returns values from content items according to given config

Parameters

  • content array Categorized content items returned from the "categorizeContent" method.
  • config object Model that descibes values you beed to get from the content parameter.

Examples

// Returns
// {
//   homepage: [{
//     system: {
//       id: '...',
//       name: '...'
//     },
//     elements: {
//       page_title: '...',
//       header: '...',
//       logos: [{
//         system: {
//           codename: '...'
//         },
//         elements: {
//           image: ['...'],
//           url: '...'
//         }
//       }]
//     }
//   }],
//   blog: [{
//     system: {
//       id: '...',
//       name: '...'
//     },
//     elements: {
//       page_title: '...',
//       publish_date: '...',
//       header_image: ['...', '...']
//     },{
//     system: {
//       id: '...',
//       name: '...'
//     },
//     elements: {
//       page_title: '...',
//       publish_date: '...',
//       header_image: ['...', '...']
//     }
//   }]
// }
project.getContentAsPromise(['?system.type=home', '?system.type=blog_post'])
.then(function (data) {
  return project.categorizeContent(data, ['hompage', 'blog']);
}).then(function (data) {
  return project.getNeededValues(data, {
    homepage: {
      system: ['id', 'name'],
      elements: ['page_title', 'header', {
        name: 'logos',
        system: ['codename'],
        elements: ['image', 'url']
      }]
    },
    blog: {
      system: ['id', 'name'],
      elements: ['page_title', 'publish_date', 'header_image']
    }
  });
);

Returns object Returns content items values that are positioned according to the config parameter.