Skip to content

Instantly share code, notes, and snippets.

@araphiel
Last active March 15, 2021 04:12
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 araphiel/8e9d4527a61c66f4a2fdc351bcb1cf27 to your computer and use it in GitHub Desktop.
Save araphiel/8e9d4527a61c66f4a2fdc351bcb1cf27 to your computer and use it in GitHub Desktop.
Basic Contentful + MJML email example
require('dotenv').config()
const { resolve } = require('path')
const { outputFile, pathExists, removeSync } = require('fs-extra')
const contentful = require('contentful')
const { CONTENTFUL_SPACE, CONTENTFUL_ACCESS_TOKEN } = process.env
const { documentToHtmlString } = require('@contentful/rich-text-html-renderer')
const { BLOCKS, INLINES } = require('@contentful/rich-text-types')
const mjml2html = require('mjml')
const client = contentful.createClient({
space: CONTENTFUL_SPACE,
accessToken: CONTENTFUL_ACCESS_TOKEN
})
const renderOptions = {
renderNode: {
[BLOCKS.EMBEDDED_ASSET]: node => {
const { title, file } = node.data.target.fields
const { url, contentType } = file
switch (contentType) {
case 'image/jpeg':
return `<img src="http:${url}" alt="${title}" style="width:100%"/>`
default:
return node
}
},
}
}
const renderHTML = richText => documentToHtmlString(richText, renderOptions)
function mj(tag, { attributes, content, children } = {}) {
if (!tag) throw new Error('Missing mjml tag')
return {
'tagName': tag,
...(attributes && { 'attributes': attributes }),
...(content && { 'content': content }),
...(children && { 'children': children })
}
}
function generateHTML(dir, name, mjml) {
// Remove previous artifacts
const ARTIFACTS = resolve(dir)
if (pathExists(ARTIFACTS)) {
removeSync(ARTIFACTS)
console.log('Old artifacts removed...')
}
// Create HTML
const { html } = mjml2html(mjml)
const fileName = name.replace(/\s+/g, "-").toLowerCase()
return outputFile(`contentful/${fileName}.html`, html).catch(console.error);
}
client
.getEntries({ 'content_type': 'email', 'include': 4 })
.then(entries => entries.items.map(entry => {
const { internalName, title, previewText, section: sections } = entry.fields
$sections = []
sections.forEach((section, idx) => {
const { columns } = section.fields
let $columns = []
columns.forEach((column, idx) => {
let $column = []
const contents = column.fields.content
contents.forEach((item, idx) => $column[idx] = renderHTML(item.fields.text))
$columns[idx] = { content: $column }
})
$sections[idx] = { columns: $columns }
})
return {
title: title,
previewText: previewText,
internalName: internalName,
sections: $sections
}
}))
.then(emails => {
let mjml = []
emails.forEach((email, idx) => {
const { title, previewText, sections, internalName } = email
const mjHeadAttributes = [
mj('mj-title', { 'content': title }),
mj('mj-preview', { 'content': previewText }),
]
const mjSections = sections.map(({ columns }) => mj('mj-section', {
'children': columns.map(({ content }) => mj('mj-column', {
'children': content.map(item => mj('mj-text', { 'content': item }))
}))
}))
const mjHead = mj('mj-head', { 'children': mjHeadAttributes })
const mjBody = mj('mj-body', { 'children': mjSections })
const mjEmail = mj('mjml', { 'children': [mjHead, mjBody] })
mjml[idx] = {
name: internalName,
mjml: mjEmail
}
})
return mjml
})
.then(email => email.forEach(({ name, mjml }) => {
generateHTML('contentful', name, mjml)
}))
.then(() => console.log('Build complete!'))
.catch(console.error)
{
"contentTypes": [
{
"sys": {
"space": {
"sys": {
"type": "Link",
"linkType": "Space",
"id": "xrc5n1qfof2q"
}
},
"id": "email",
"type": "ContentType",
"createdAt": "2019-10-17T21:23:22.317Z",
"updatedAt": "2019-10-17T21:29:30.077Z",
"environment": {
"sys": {
"id": "master",
"type": "Link",
"linkType": "Environment"
}
},
"publishedVersion": 3,
"publishedAt": "2019-10-17T21:29:30.077Z",
"firstPublishedAt": "2019-10-17T21:23:22.878Z",
"createdBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
},
"updatedBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
},
"publishedCounter": 2,
"version": 4,
"publishedBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
}
},
"displayField": "internalName",
"name": "Email",
"description": "",
"fields": [
{
"id": "internalName",
"name": "Internal Name",
"type": "Symbol",
"localized": false,
"required": true,
"validations": [
{
"unique": true
}
],
"disabled": false,
"omitted": false
},
{
"id": "title",
"name": "Title",
"type": "Symbol",
"localized": false,
"required": true,
"validations": [
],
"disabled": false,
"omitted": false
},
{
"id": "previewText",
"name": "Preview Text",
"type": "Symbol",
"localized": false,
"required": true,
"validations": [
],
"disabled": false,
"omitted": false
},
{
"id": "section",
"name": "Sections",
"type": "Array",
"localized": true,
"required": false,
"validations": [
{
"size": {
"min": 1
},
"message": "You need at least one content section."
}
],
"disabled": false,
"omitted": false,
"items": {
"type": "Link",
"validations": [
{
"linkContentType": [
"emailSections"
]
}
],
"linkType": "Entry"
}
}
]
},
{
"sys": {
"space": {
"sys": {
"type": "Link",
"linkType": "Space",
"id": "xrc5n1qfof2q"
}
},
"id": "emailSections",
"type": "ContentType",
"createdAt": "2019-10-17T21:27:16.600Z",
"updatedAt": "2019-10-29T18:06:24.417Z",
"environment": {
"sys": {
"id": "master",
"type": "Link",
"linkType": "Environment"
}
},
"publishedVersion": 5,
"publishedAt": "2019-10-29T18:06:24.417Z",
"firstPublishedAt": "2019-10-17T21:27:16.879Z",
"createdBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
},
"updatedBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
},
"publishedCounter": 3,
"version": 6,
"publishedBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
}
},
"displayField": null,
"name": "Email > Sections",
"description": "",
"fields": [
{
"id": "columns",
"name": "Columns",
"type": "Array",
"localized": false,
"required": false,
"validations": [
{
"size": {
"min": 1,
"max": 4
},
"message": "You have must create at least 1 column, no more than 4."
}
],
"disabled": false,
"omitted": false,
"items": {
"type": "Link",
"validations": [
{
"linkContentType": [
"emailColumns"
]
}
],
"linkType": "Entry"
}
}
]
},
{
"sys": {
"space": {
"sys": {
"type": "Link",
"linkType": "Space",
"id": "xrc5n1qfof2q"
}
},
"id": "emailColumns",
"type": "ContentType",
"createdAt": "2019-10-17T21:29:10.602Z",
"updatedAt": "2019-10-29T18:06:35.130Z",
"environment": {
"sys": {
"id": "master",
"type": "Link",
"linkType": "Environment"
}
},
"publishedVersion": 9,
"publishedAt": "2019-10-29T18:06:35.130Z",
"firstPublishedAt": "2019-10-17T21:29:10.921Z",
"createdBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
},
"updatedBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
},
"publishedCounter": 5,
"version": 10,
"publishedBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
}
},
"displayField": "internalName",
"name": "Email > Columns",
"description": "Columns are children of sections (rows). These can contain text, images, etc.",
"fields": [
{
"id": "internalName",
"name": "Internal Name",
"type": "Symbol",
"localized": false,
"required": true,
"validations": [
{
"unique": true
}
],
"disabled": false,
"omitted": false
},
{
"id": "content",
"name": "Content",
"type": "Array",
"localized": false,
"required": false,
"validations": [
],
"disabled": false,
"omitted": false,
"items": {
"type": "Link",
"validations": [
{
"linkContentType": [
"generalContent"
]
}
],
"linkType": "Entry"
}
}
]
},
{
"sys": {
"space": {
"sys": {
"type": "Link",
"linkType": "Space",
"id": "xrc5n1qfof2q"
}
},
"id": "generalContent",
"type": "ContentType",
"createdAt": "2019-10-21T17:28:28.611Z",
"updatedAt": "2019-10-21T21:17:32.976Z",
"environment": {
"sys": {
"id": "master",
"type": "Link",
"linkType": "Environment"
}
},
"publishedVersion": 9,
"publishedAt": "2019-10-21T21:17:32.976Z",
"firstPublishedAt": "2019-10-21T17:28:28.865Z",
"createdBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
},
"updatedBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
},
"publishedCounter": 5,
"version": 10,
"publishedBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
}
},
"displayField": "internalName",
"name": "General Content",
"description": "",
"fields": [
{
"id": "internalName",
"name": "Internal Name",
"type": "Symbol",
"localized": false,
"required": true,
"validations": [
],
"disabled": false,
"omitted": false
},
{
"id": "text",
"name": "Text",
"type": "RichText",
"localized": true,
"required": false,
"validations": [
{
"nodes": {
}
},
{
"enabledNodeTypes": [
"heading-1",
"heading-2",
"heading-3",
"heading-4",
"heading-5",
"heading-6",
"ordered-list",
"unordered-list",
"hr",
"blockquote",
"embedded-entry-block",
"embedded-asset-block",
"hyperlink",
"asset-hyperlink",
"embedded-entry-inline"
],
"message": "Only heading 1, heading 2, heading 3, heading 4, heading 5, heading 6, ordered list, unordered list, horizontal rule, quote, block entry, asset, link to Url, link to asset, and inline entry nodes are allowed"
}
],
"disabled": false,
"omitted": false
}
]
},
{
"sys": {
"space": {
"sys": {
"type": "Link",
"linkType": "Space",
"id": "xrc5n1qfof2q"
}
},
"id": "button",
"type": "ContentType",
"createdAt": "2019-10-28T20:16:46.071Z",
"updatedAt": "2019-10-28T20:18:56.068Z",
"environment": {
"sys": {
"id": "master",
"type": "Link",
"linkType": "Environment"
}
},
"publishedVersion": 3,
"publishedAt": "2019-10-28T20:18:56.068Z",
"firstPublishedAt": "2019-10-28T20:16:47.018Z",
"createdBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
},
"updatedBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
},
"publishedCounter": 2,
"version": 4,
"publishedBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
}
},
"displayField": "internalName",
"name": "Button",
"description": "",
"fields": [
{
"id": "internalName",
"name": "Internal Name",
"type": "Symbol",
"localized": false,
"required": false,
"validations": [
],
"disabled": false,
"omitted": false
},
{
"id": "content",
"name": "Content",
"type": "Text",
"localized": false,
"required": false,
"validations": [
],
"disabled": false,
"omitted": false
},
{
"id": "templatedContent",
"name": "Templated Content",
"type": "Link",
"localized": false,
"required": false,
"validations": [
{
"linkContentType": [
"microCopy"
]
}
],
"disabled": false,
"omitted": false,
"linkType": "Entry"
},
{
"id": "link",
"name": "Link",
"type": "Symbol",
"localized": true,
"required": false,
"validations": [
],
"disabled": false,
"omitted": false
}
]
},
{
"sys": {
"space": {
"sys": {
"type": "Link",
"linkType": "Space",
"id": "xrc5n1qfof2q"
}
},
"id": "microCopy",
"type": "ContentType",
"createdAt": "2019-10-28T20:18:27.697Z",
"updatedAt": "2019-10-28T20:18:28.036Z",
"environment": {
"sys": {
"id": "master",
"type": "Link",
"linkType": "Environment"
}
},
"publishedVersion": 1,
"publishedAt": "2019-10-28T20:18:28.036Z",
"firstPublishedAt": "2019-10-28T20:18:28.036Z",
"createdBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
},
"updatedBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
},
"publishedCounter": 1,
"version": 2,
"publishedBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
}
},
"displayField": "key",
"name": "Micro Copy",
"description": "Commonly translated text",
"fields": [
{
"id": "key",
"name": "Key",
"type": "Symbol",
"localized": false,
"required": true,
"validations": [
{
"unique": true
}
],
"disabled": false,
"omitted": false
},
{
"id": "value",
"name": "Value",
"type": "Symbol",
"localized": true,
"required": false,
"validations": [
],
"disabled": false,
"omitted": false
}
]
}
],
"editorInterfaces": [
{
"sys": {
"id": "default",
"type": "EditorInterface",
"space": {
"sys": {
"id": "xrc5n1qfof2q",
"type": "Link",
"linkType": "Space"
}
},
"version": 4,
"createdAt": "2019-10-17T21:23:23.123Z",
"createdBy": {
"sys": {
"id": "7omg9I3JyXTDgUJR7fl0Jq",
"type": "Link",
"linkType": "User"
}
},
"updatedAt": "2019-10-17T21:29:30.588Z",
"updatedBy": {
"sys": {
"id": "7omg9I3JyXTDgUJR7fl0Jq",
"type": "Link",
"linkType": "User"
}
},
"contentType": {
"sys": {
"id": "email",
"type": "Link",
"linkType": "ContentType"
}
},
"environment": {
"sys": {
"id": "master",
"type": "Link",
"linkType": "Environment"
}
}
},
"controls": [
{
"fieldId": "internalName",
"widgetId": "singleLine",
"widgetNamespace": "builtin"
},
{
"fieldId": "title",
"widgetId": "singleLine",
"widgetNamespace": "builtin"
},
{
"fieldId": "previewText",
"widgetId": "singleLine",
"widgetNamespace": "builtin"
},
{
"fieldId": "section",
"settings": {
"helpText": "Sections are rows of content in your email.",
"bulkEditing": false
},
"widgetId": "entryLinksEditor",
"widgetNamespace": "builtin"
}
]
},
{
"sys": {
"id": "default",
"type": "EditorInterface",
"space": {
"sys": {
"id": "xrc5n1qfof2q",
"type": "Link",
"linkType": "Space"
}
},
"version": 6,
"createdAt": "2019-10-17T21:27:17.044Z",
"createdBy": {
"sys": {
"id": "7omg9I3JyXTDgUJR7fl0Jq",
"type": "Link",
"linkType": "User"
}
},
"updatedAt": "2019-10-29T18:06:24.869Z",
"updatedBy": {
"sys": {
"id": "7omg9I3JyXTDgUJR7fl0Jq",
"type": "Link",
"linkType": "User"
}
},
"contentType": {
"sys": {
"id": "emailSections",
"type": "Link",
"linkType": "ContentType"
}
},
"environment": {
"sys": {
"id": "master",
"type": "Link",
"linkType": "Environment"
}
}
},
"controls": [
{
"fieldId": "columns",
"settings": {
"bulkEditing": true
},
"widgetId": "entryLinksEditor",
"widgetNamespace": "builtin"
}
]
},
{
"sys": {
"id": "default",
"type": "EditorInterface",
"space": {
"sys": {
"id": "xrc5n1qfof2q",
"type": "Link",
"linkType": "Space"
}
},
"version": 10,
"createdAt": "2019-10-17T21:29:11.088Z",
"createdBy": {
"sys": {
"id": "7omg9I3JyXTDgUJR7fl0Jq",
"type": "Link",
"linkType": "User"
}
},
"updatedAt": "2019-10-29T18:06:35.817Z",
"updatedBy": {
"sys": {
"id": "7omg9I3JyXTDgUJR7fl0Jq",
"type": "Link",
"linkType": "User"
}
},
"contentType": {
"sys": {
"id": "emailColumns",
"type": "Link",
"linkType": "ContentType"
}
},
"environment": {
"sys": {
"id": "master",
"type": "Link",
"linkType": "Environment"
}
}
},
"controls": [
{
"fieldId": "internalName",
"widgetId": "slugEditor",
"widgetNamespace": "builtin"
},
{
"fieldId": "content",
"settings": {
"bulkEditing": true
},
"widgetId": "entryCardsEditor",
"widgetNamespace": "builtin"
}
]
},
{
"sys": {
"id": "default",
"type": "EditorInterface",
"space": {
"sys": {
"id": "xrc5n1qfof2q",
"type": "Link",
"linkType": "Space"
}
},
"version": 10,
"createdAt": "2019-10-21T17:28:29.046Z",
"createdBy": {
"sys": {
"id": "7omg9I3JyXTDgUJR7fl0Jq",
"type": "Link",
"linkType": "User"
}
},
"updatedAt": "2019-10-21T21:17:33.493Z",
"updatedBy": {
"sys": {
"id": "7omg9I3JyXTDgUJR7fl0Jq",
"type": "Link",
"linkType": "User"
}
},
"contentType": {
"sys": {
"id": "generalContent",
"type": "Link",
"linkType": "ContentType"
}
},
"environment": {
"sys": {
"id": "master",
"type": "Link",
"linkType": "Environment"
}
}
},
"controls": [
{
"fieldId": "internalName",
"widgetId": "singleLine",
"widgetNamespace": "builtin"
},
{
"fieldId": "text",
"widgetId": "richTextEditor",
"widgetNamespace": "builtin"
}
]
},
{
"sys": {
"id": "default",
"type": "EditorInterface",
"space": {
"sys": {
"id": "xrc5n1qfof2q",
"type": "Link",
"linkType": "Space"
}
},
"version": 4,
"createdAt": "2019-10-28T20:16:47.192Z",
"createdBy": {
"sys": {
"id": "7omg9I3JyXTDgUJR7fl0Jq",
"type": "Link",
"linkType": "User"
}
},
"updatedAt": "2019-10-28T20:18:56.739Z",
"updatedBy": {
"sys": {
"id": "7omg9I3JyXTDgUJR7fl0Jq",
"type": "Link",
"linkType": "User"
}
},
"contentType": {
"sys": {
"id": "button",
"type": "Link",
"linkType": "ContentType"
}
},
"environment": {
"sys": {
"id": "master",
"type": "Link",
"linkType": "Environment"
}
}
},
"controls": [
{
"fieldId": "internalName",
"widgetId": "singleLine",
"widgetNamespace": "builtin"
},
{
"fieldId": "content",
"widgetId": "multipleLine",
"widgetNamespace": "builtin"
},
{
"fieldId": "templatedContent",
"settings": {
"helpText": "Only choose this option if the copy is commonly translated text. This takes precedence over copy entered into the regular content box."
},
"widgetId": "entryLinkEditor",
"widgetNamespace": "builtin"
},
{
"fieldId": "link",
"widgetId": "urlEditor",
"widgetNamespace": "builtin"
}
]
},
{
"sys": {
"id": "default",
"type": "EditorInterface",
"space": {
"sys": {
"id": "xrc5n1qfof2q",
"type": "Link",
"linkType": "Space"
}
},
"version": 2,
"createdAt": "2019-10-28T20:18:28.352Z",
"createdBy": {
"sys": {
"id": "7omg9I3JyXTDgUJR7fl0Jq",
"type": "Link",
"linkType": "User"
}
},
"updatedAt": "2019-10-28T20:18:28.817Z",
"updatedBy": {
"sys": {
"id": "7omg9I3JyXTDgUJR7fl0Jq",
"type": "Link",
"linkType": "User"
}
},
"contentType": {
"sys": {
"id": "microCopy",
"type": "Link",
"linkType": "ContentType"
}
},
"environment": {
"sys": {
"id": "master",
"type": "Link",
"linkType": "Environment"
}
}
},
"controls": [
{
"fieldId": "key",
"widgetId": "singleLine",
"widgetNamespace": "builtin"
},
{
"fieldId": "value",
"widgetId": "singleLine",
"widgetNamespace": "builtin"
}
]
}
],
"entries": [
{
"sys": {
"space": {
"sys": {
"type": "Link",
"linkType": "Space",
"id": "xrc5n1qfof2q"
}
},
"id": "5QZfYsPK99mMD1Bgh7LxO0",
"type": "Entry",
"createdAt": "2019-10-21T17:29:17.087Z",
"updatedAt": "2019-10-29T18:10:40.475Z",
"environment": {
"sys": {
"id": "master",
"type": "Link",
"linkType": "Environment"
}
},
"publishedVersion": 59,
"publishedAt": "2019-10-29T18:10:40.475Z",
"firstPublishedAt": "2019-10-21T17:33:53.043Z",
"createdBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
},
"updatedBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
},
"publishedCounter": 5,
"version": 60,
"publishedBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
},
"contentType": {
"sys": {
"type": "Link",
"linkType": "ContentType",
"id": "email"
}
}
},
"fields": {
"internalName": {
"en-US": "Internal Test Email"
},
"title": {
"en-US": "Amazing Email Title"
},
"previewText": {
"en-US": "Isn't it amazing to do this in a CMS."
},
"section": {
"en-US": [
{
"sys": {
"type": "Link",
"linkType": "Entry",
"id": "6r1e7N3RkKYCLw6K5245HR"
}
},
{
"sys": {
"type": "Link",
"linkType": "Entry",
"id": "2rjdYUAgmu8HjiaqmPdiao"
}
}
]
}
}
},
{
"sys": {
"space": {
"sys": {
"type": "Link",
"linkType": "Space",
"id": "xrc5n1qfof2q"
}
},
"id": "6r1e7N3RkKYCLw6K5245HR",
"type": "Entry",
"createdAt": "2019-10-21T17:30:18.119Z",
"updatedAt": "2019-10-30T17:14:53.569Z",
"environment": {
"sys": {
"id": "master",
"type": "Link",
"linkType": "Environment"
}
},
"publishedVersion": 13,
"publishedAt": "2019-10-30T17:14:53.569Z",
"firstPublishedAt": "2019-10-21T17:33:11.849Z",
"createdBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
},
"updatedBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
},
"publishedCounter": 6,
"version": 14,
"publishedBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
},
"contentType": {
"sys": {
"type": "Link",
"linkType": "ContentType",
"id": "emailSections"
}
}
},
"fields": {
"columns": {
"en-US": [
{
"sys": {
"type": "Link",
"linkType": "Entry",
"id": "5nDNIwDWzibzY7Zjs37kuN"
}
}
]
}
}
},
{
"sys": {
"space": {
"sys": {
"type": "Link",
"linkType": "Space",
"id": "xrc5n1qfof2q"
}
},
"id": "5nDNIwDWzibzY7Zjs37kuN",
"type": "Entry",
"createdAt": "2019-10-21T17:30:38.118Z",
"updatedAt": "2019-10-21T21:18:24.645Z",
"environment": {
"sys": {
"id": "master",
"type": "Link",
"linkType": "Environment"
}
},
"publishedVersion": 28,
"publishedAt": "2019-10-21T21:18:24.645Z",
"firstPublishedAt": "2019-10-21T19:10:40.947Z",
"createdBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
},
"updatedBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
},
"publishedCounter": 2,
"version": 29,
"publishedBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
},
"contentType": {
"sys": {
"type": "Link",
"linkType": "ContentType",
"id": "emailColumns"
}
}
},
"fields": {
"internalName": {
"en-US": "Internal Test > Column 1"
},
"content": {
"en-US": [
{
"sys": {
"type": "Link",
"linkType": "Entry",
"id": "hm28uFPnMtTHjiEaN6BD9"
}
},
{
"sys": {
"type": "Link",
"linkType": "Entry",
"id": "hm28uFPnMtTHjiEaN6BD9"
}
}
]
}
}
},
{
"sys": {
"space": {
"sys": {
"type": "Link",
"linkType": "Space",
"id": "xrc5n1qfof2q"
}
},
"id": "hm28uFPnMtTHjiEaN6BD9",
"type": "Entry",
"createdAt": "2019-10-21T17:30:44.189Z",
"updatedAt": "2019-10-30T17:13:42.791Z",
"environment": {
"sys": {
"id": "master",
"type": "Link",
"linkType": "Environment"
}
},
"publishedVersion": 39,
"publishedAt": "2019-10-30T17:13:42.791Z",
"firstPublishedAt": "2019-10-21T17:32:30.129Z",
"createdBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
},
"updatedBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
},
"publishedCounter": 5,
"version": 40,
"publishedBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
},
"contentType": {
"sys": {
"type": "Link",
"linkType": "ContentType",
"id": "generalContent"
}
}
},
"fields": {
"internalName": {
"en-US": "Internal Test Content"
},
"text": {
"en-US": {
"nodeType": "document",
"data": {
},
"content": [
{
"nodeType": "paragraph",
"content": [
{
"nodeType": "text",
"value": "Isn't this Ellen????",
"marks": [
],
"data": {
}
}
],
"data": {
}
},
{
"nodeType": "paragraph",
"content": [
{
"nodeType": "text",
"value": "That we can have this text here between us?",
"marks": [
],
"data": {
}
}
],
"data": {
}
},
{
"nodeType": "embedded-asset-block",
"content": [
],
"data": {
"target": {
"sys": {
"id": "2LfRb7M5MaiBUuy1olOJqJ",
"type": "Link",
"linkType": "Asset"
}
}
}
},
{
"nodeType": "paragraph",
"content": [
{
"nodeType": "text",
"value": "Listing a small inline list",
"marks": [
],
"data": {
}
}
],
"data": {
}
}
]
}
}
}
},
{
"sys": {
"space": {
"sys": {
"type": "Link",
"linkType": "Space",
"id": "xrc5n1qfof2q"
}
},
"id": "2rjdYUAgmu8HjiaqmPdiao",
"type": "Entry",
"createdAt": "2019-10-29T18:09:41.232Z",
"updatedAt": "2019-10-29T18:10:34.365Z",
"environment": {
"sys": {
"id": "master",
"type": "Link",
"linkType": "Environment"
}
},
"publishedVersion": 2,
"publishedAt": "2019-10-29T18:10:34.365Z",
"firstPublishedAt": "2019-10-29T18:10:34.365Z",
"createdBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
},
"updatedBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
},
"publishedCounter": 1,
"version": 3,
"publishedBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
},
"contentType": {
"sys": {
"type": "Link",
"linkType": "ContentType",
"id": "emailSections"
}
}
},
"fields": {
"columns": {
"en-US": [
{
"sys": {
"type": "Link",
"linkType": "Entry",
"id": "662ff60cpzK9DPVEBOohpz"
}
}
]
}
}
},
{
"sys": {
"space": {
"sys": {
"type": "Link",
"linkType": "Space",
"id": "xrc5n1qfof2q"
}
},
"id": "662ff60cpzK9DPVEBOohpz",
"type": "Entry",
"createdAt": "2019-10-29T18:09:48.046Z",
"updatedAt": "2019-10-29T18:10:27.116Z",
"environment": {
"sys": {
"id": "master",
"type": "Link",
"linkType": "Environment"
}
},
"publishedVersion": 14,
"publishedAt": "2019-10-29T18:10:27.116Z",
"firstPublishedAt": "2019-10-29T18:10:27.116Z",
"createdBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
},
"updatedBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
},
"publishedCounter": 1,
"version": 15,
"publishedBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
},
"contentType": {
"sys": {
"type": "Link",
"linkType": "ContentType",
"id": "emailColumns"
}
}
},
"fields": {
"internalName": {
"en-US": "Random Column"
},
"content": {
"en-US": [
{
"sys": {
"type": "Link",
"linkType": "Entry",
"id": "44hiIX8JkGz2ZuK77FNRuA"
}
}
]
}
}
},
{
"sys": {
"space": {
"sys": {
"type": "Link",
"linkType": "Space",
"id": "xrc5n1qfof2q"
}
},
"id": "44hiIX8JkGz2ZuK77FNRuA",
"type": "Entry",
"createdAt": "2019-10-29T18:09:56.651Z",
"updatedAt": "2019-10-30T17:15:32.094Z",
"environment": {
"sys": {
"id": "master",
"type": "Link",
"linkType": "Environment"
}
},
"publishedVersion": 11,
"publishedAt": "2019-10-30T17:15:32.094Z",
"firstPublishedAt": "2019-10-29T18:10:22.046Z",
"createdBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
},
"updatedBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
},
"publishedCounter": 2,
"version": 12,
"publishedBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
},
"contentType": {
"sys": {
"type": "Link",
"linkType": "ContentType",
"id": "generalContent"
}
}
},
"fields": {
"internalName": {
"en-US": "Base"
},
"text": {
"en-US": {
"nodeType": "document",
"data": {
},
"content": [
{
"nodeType": "paragraph",
"content": [
{
"nodeType": "text",
"value": "Danielle Posey is amazing!",
"marks": [
],
"data": {
}
}
],
"data": {
}
},
{
"nodeType": "embedded-asset-block",
"content": [
],
"data": {
"target": {
"sys": {
"id": "1Ij399FvVTZzLSmSL9u4eM",
"type": "Link",
"linkType": "Asset"
}
}
}
},
{
"nodeType": "paragraph",
"content": [
{
"nodeType": "text",
"value": "",
"marks": [
],
"data": {
}
}
],
"data": {
}
}
]
}
}
}
}
],
"assets": [
{
"sys": {
"space": {
"sys": {
"type": "Link",
"linkType": "Space",
"id": "xrc5n1qfof2q"
}
},
"id": "2LfRb7M5MaiBUuy1olOJqJ",
"type": "Asset",
"createdAt": "2019-10-21T19:19:37.967Z",
"updatedAt": "2019-10-21T19:19:48.506Z",
"environment": {
"sys": {
"id": "master",
"type": "Link",
"linkType": "Environment"
}
},
"publishedVersion": 4,
"publishedAt": "2019-10-21T19:19:48.506Z",
"firstPublishedAt": "2019-10-21T19:19:48.506Z",
"createdBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
},
"updatedBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
},
"publishedCounter": 1,
"version": 5,
"publishedBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
}
},
"fields": {
"title": {
"en-US": "flat-neck-back-syndrom-happy-woman"
},
"file": {
"en-US": {
"url": "//images.ctfassets.net/xrc5n1qfof2q/2LfRb7M5MaiBUuy1olOJqJ/44c8d4fcc7e87f5bad24377de6d89d4f/flat-neck-back-syndrom-happy-woman.jpg",
"details": {
"size": 51475,
"image": {
"width": 507,
"height": 338
}
},
"fileName": "flat-neck-back-syndrom-happy-woman.jpg",
"contentType": "image/jpeg"
}
}
}
},
{
"sys": {
"space": {
"sys": {
"type": "Link",
"linkType": "Space",
"id": "xrc5n1qfof2q"
}
},
"id": "1Ij399FvVTZzLSmSL9u4eM",
"type": "Asset",
"createdAt": "2019-10-30T17:15:10.017Z",
"updatedAt": "2019-10-30T17:15:28.039Z",
"environment": {
"sys": {
"id": "master",
"type": "Link",
"linkType": "Environment"
}
},
"publishedVersion": 4,
"publishedAt": "2019-10-30T17:15:28.039Z",
"firstPublishedAt": "2019-10-30T17:15:28.039Z",
"createdBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
},
"updatedBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
},
"publishedCounter": 1,
"version": 5,
"publishedBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
}
},
"fields": {
"title": {
"en-US": "wmhd-info-image"
},
"file": {
"en-US": {
"url": "//images.ctfassets.net/xrc5n1qfof2q/1Ij399FvVTZzLSmSL9u4eM/7c4b2fd28c9de2d7fdcae5bd9417d2b5/wmhd-info-image.jpg",
"details": {
"size": 58515,
"image": {
"width": 490,
"height": 350
}
},
"fileName": "wmhd-info-image.jpg",
"contentType": "image/jpeg"
}
}
}
}
],
"locales": [
{
"name": "English (United States)",
"code": "en-US",
"fallbackCode": null,
"default": true,
"contentManagementApi": true,
"contentDeliveryApi": true,
"optional": false,
"sys": {
"type": "Locale",
"id": "1trpGpgm9LfHHrIpTxJdkH",
"version": 1,
"space": {
"sys": {
"type": "Link",
"linkType": "Space",
"id": "xrc5n1qfof2q"
}
},
"environment": {
"sys": {
"type": "Link",
"linkType": "Environment",
"id": "master"
}
},
"createdBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
},
"createdAt": "2019-10-17T21:15:37Z",
"updatedBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
},
"updatedAt": "2019-10-17T21:15:37Z"
}
},
{
"name": "Afrikaans",
"code": "af",
"fallbackCode": null,
"default": false,
"contentManagementApi": true,
"contentDeliveryApi": true,
"optional": false,
"sys": {
"type": "Locale",
"id": "0phBCq663Xm7QUAIHUioUx",
"version": 1,
"space": {
"sys": {
"type": "Link",
"linkType": "Space",
"id": "xrc5n1qfof2q"
}
},
"environment": {
"sys": {
"type": "Link",
"linkType": "Environment",
"id": "master"
}
},
"createdBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
},
"createdAt": "2019-10-30T17:17:19Z",
"updatedBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
},
"updatedAt": "2019-10-30T17:17:19Z"
}
}
],
"webhooks": [
],
"roles": [
{
"name": "Author",
"description": "Allows editing of content",
"policies": [
{
"effect": "allow",
"actions": [
"create"
],
"constraint": {
"and": [
{
"equals": [
{
"doc": "sys.type"
},
"Entry"
]
}
]
}
},
{
"effect": "allow",
"actions": [
"read"
],
"constraint": {
"and": [
{
"equals": [
{
"doc": "sys.type"
},
"Entry"
]
}
]
}
},
{
"effect": "allow",
"actions": [
"update"
],
"constraint": {
"and": [
{
"equals": [
{
"doc": "sys.type"
},
"Entry"
]
}
]
}
},
{
"effect": "allow",
"actions": [
"create"
],
"constraint": {
"and": [
{
"equals": [
{
"doc": "sys.type"
},
"Asset"
]
}
]
}
},
{
"effect": "allow",
"actions": [
"read"
],
"constraint": {
"and": [
{
"equals": [
{
"doc": "sys.type"
},
"Asset"
]
}
]
}
},
{
"effect": "allow",
"actions": [
"update"
],
"constraint": {
"and": [
{
"equals": [
{
"doc": "sys.type"
},
"Asset"
]
}
]
}
}
],
"permissions": {
"ContentModel": [
"read"
],
"Settings": [
],
"ContentDelivery": [
],
"Environments": [
],
"EnvironmentAliases": [
]
},
"sys": {
"type": "Role",
"id": "1tt5ZyYPrI0ISPxVIm0ABp",
"version": 0,
"space": {
"sys": {
"type": "Link",
"linkType": "Space",
"id": "xrc5n1qfof2q"
}
},
"createdBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
},
"createdAt": "2019-10-17T21:15:37Z",
"updatedBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
},
"updatedAt": "2019-10-17T21:15:37Z"
}
},
{
"name": "Editor",
"description": "Allows editing, publishing and archiving of content",
"policies": [
{
"effect": "allow",
"actions": "all",
"constraint": {
"and": [
{
"equals": [
{
"doc": "sys.type"
},
"Entry"
]
}
]
}
},
{
"effect": "allow",
"actions": "all",
"constraint": {
"and": [
{
"equals": [
{
"doc": "sys.type"
},
"Asset"
]
}
]
}
}
],
"permissions": {
"ContentModel": [
"read"
],
"Settings": [
],
"ContentDelivery": [
],
"Environments": [
],
"EnvironmentAliases": [
]
},
"sys": {
"type": "Role",
"id": "1ttCWLSH9pSer6x3t8llef",
"version": 0,
"space": {
"sys": {
"type": "Link",
"linkType": "Space",
"id": "xrc5n1qfof2q"
}
},
"createdBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
},
"createdAt": "2019-10-17T21:15:37Z",
"updatedBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
},
"updatedAt": "2019-10-17T21:15:37Z"
}
},
{
"name": "Freelancer",
"description": "Allows only editing of content they created themselves",
"policies": [
{
"effect": "allow",
"actions": [
"create"
],
"constraint": {
"and": [
{
"equals": [
{
"doc": "sys.type"
},
"Entry"
]
}
]
}
},
{
"effect": "allow",
"actions": [
"create"
],
"constraint": {
"and": [
{
"equals": [
{
"doc": "sys.type"
},
"Asset"
]
}
]
}
},
{
"effect": "allow",
"actions": [
"read"
],
"constraint": {
"and": [
{
"equals": [
{
"doc": "sys.type"
},
"Entry"
]
},
{
"equals": [
{
"doc": "sys.createdBy.sys.id"
},
"User.current()"
]
}
]
}
},
{
"effect": "allow",
"actions": [
"update"
],
"constraint": {
"and": [
{
"equals": [
{
"doc": "sys.type"
},
"Entry"
]
},
{
"equals": [
{
"doc": "sys.createdBy.sys.id"
},
"User.current()"
]
},
{
"paths": [
{
"doc": "fields.%.%"
}
]
}
]
}
},
{
"effect": "allow",
"actions": [
"delete"
],
"constraint": {
"and": [
{
"equals": [
{
"doc": "sys.type"
},
"Entry"
]
},
{
"equals": [
{
"doc": "sys.createdBy.sys.id"
},
"User.current()"
]
}
]
}
},
{
"effect": "allow",
"actions": [
"read"
],
"constraint": {
"and": [
{
"equals": [
{
"doc": "sys.type"
},
"Asset"
]
},
{
"equals": [
{
"doc": "sys.createdBy.sys.id"
},
"User.current()"
]
}
]
}
},
{
"effect": "allow",
"actions": [
"update"
],
"constraint": {
"and": [
{
"equals": [
{
"doc": "sys.type"
},
"Asset"
]
},
{
"equals": [
{
"doc": "sys.createdBy.sys.id"
},
"User.current()"
]
},
{
"paths": [
{
"doc": "fields.%.%"
}
]
}
]
}
},
{
"effect": "allow",
"actions": [
"delete"
],
"constraint": {
"and": [
{
"equals": [
{
"doc": "sys.type"
},
"Asset"
]
},
{
"equals": [
{
"doc": "sys.createdBy.sys.id"
},
"User.current()"
]
}
]
}
}
],
"permissions": {
"ContentModel": [
"read"
],
"Settings": [
],
"ContentDelivery": [
],
"Environments": [
],
"EnvironmentAliases": [
]
},
"sys": {
"type": "Role",
"id": "1tu7sAcNtrkjC6H6Zypm4T",
"version": 0,
"space": {
"sys": {
"type": "Link",
"linkType": "Space",
"id": "xrc5n1qfof2q"
}
},
"createdBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
},
"createdAt": "2019-10-17T21:15:37Z",
"updatedBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
},
"updatedAt": "2019-10-17T21:15:37Z"
}
},
{
"name": "Translator",
"description": "Allows editing of localized fields in the specified language",
"policies": [
{
"effect": "allow",
"actions": [
"read"
],
"constraint": {
"and": [
{
"equals": [
{
"doc": "sys.type"
},
"Entry"
]
}
]
}
},
{
"effect": "allow",
"actions": [
"read"
],
"constraint": {
"and": [
{
"equals": [
{
"doc": "sys.type"
},
"Asset"
]
}
]
}
},
{
"effect": "allow",
"actions": [
"update"
],
"constraint": {
"and": [
{
"equals": [
{
"doc": "sys.type"
},
"Entry"
]
},
{
"paths": [
{
"doc": "fields.%.%"
}
]
}
]
}
},
{
"effect": "allow",
"actions": [
"update"
],
"constraint": {
"and": [
{
"equals": [
{
"doc": "sys.type"
},
"Asset"
]
},
{
"paths": [
{
"doc": "fields.%.%"
}
]
}
]
}
}
],
"permissions": {
"ContentModel": [
"read"
],
"Settings": [
],
"ContentDelivery": [
],
"Environments": [
],
"EnvironmentAliases": [
]
},
"sys": {
"type": "Role",
"id": "1tuG4ikacMrss4kMHpssz5",
"version": 0,
"space": {
"sys": {
"type": "Link",
"linkType": "Space",
"id": "xrc5n1qfof2q"
}
},
"createdBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
},
"createdAt": "2019-10-17T21:15:37Z",
"updatedBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "7omg9I3JyXTDgUJR7fl0Jq"
}
},
"updatedAt": "2019-10-17T21:15:37Z"
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment