Skip to content

Instantly share code, notes, and snippets.

@iamkevingreen
Last active December 11, 2017 11:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iamkevingreen/208997b3b69e6450e065bfd933bf4d35 to your computer and use it in GitHub Desktop.
Save iamkevingreen/208997b3b69e6450e065bfd933bf4d35 to your computer and use it in GitHub Desktop.
const contentfulAPI = require('./contentful')
const shopifyAPI = require('./shopify')
const config = require('../config')
const buildBlogPost = require('../layouts/article')
module.exports = (data) => {
const articleId = data.fields.articleId['en-US']
contentfulAPI.getEntries({
content_type: 'passports',
'fields.articleId': articleId,
include: 8
}).then(({ items }) => {
const { fields } = items[0]
// Returns Template literals!
const createBlogPost = buildBlogPost(fields)
shopifyAPI.article.update(config.shopify.blogId, fields.articleId, {
title: fields.passportTitle,
body_html: createBlogPost,
author: fields.author
})
.then(res => `Pushed data to shopify!`)
.catch(err => console.error(err))
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment