Created
August 22, 2018 17:17
-
-
Save oirodolfo/753e52969e79bbbbd304713b10d35d5b to your computer and use it in GitHub Desktop.
Contentful update for SEO
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict'; | |
| let contentful = require('contentful-management'); | |
| let params = require('../config/default.json').contentful; | |
| let client = contentful.createClient({ | |
| accessToken: params.managementToken | |
| }); | |
| // Landing pages | |
| client.getSpace(params.spaceId).then((space) => { | |
| space.getEntries({ | |
| content_type: 'landingPage', | |
| limit: 1000 | |
| }).then((entries) => { | |
| console.log('Found %s entries', entries.length); | |
| entries.forEach((entry) => { | |
| let field = entry.fields.text; | |
| field && Object.keys(field).forEach((lang) => { | |
| field[lang] = field[lang].replace(/(<\/?\s*)h2/g, '$1h1'); | |
| field[lang] = field[lang].replace(/(<\/?\s*)h3/g, '$1h2'); | |
| field[lang] = field[lang].replace(/ ng-binding/g, ''); | |
| console.log('================='); | |
| console.log(field[lang]); | |
| console.log('================='); | |
| }); | |
| space.updateEntry(entry) | |
| .catch((err) => console.log(err)) | |
| .then((entry) => space.publishEntry(entry)); | |
| }); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment