Skip to content

This repository serves as a practical guide on utilizing the Contentful CLI Tool for various common scenarios.

Notifications You must be signed in to change notification settings

chigoKawa/contentful-developer-examples

Repository files navigation

Getting Started

This repository serves as a practical guide on utilizing the Contentful CLI Tool for various common scenarios. Makes more sense if you attend the Contentful Learning Center training class.

Folder structure:
  • migrations
    • Contains all the migration scripts used in the commands.
  • exports
    • Holds exported files from migrations.
  • util
    • Contains an example utility script that generates an internal name field.
  • mini-website
    • A small Next.js example project that uses Contentful.
    • Has it's own ReadMe file

Commands

To export all content and content types from a space

contentful space export --space-id "[your-space-id]" --environment-id "[your-space-environment]" --content-file exports/all.json

Export only the content model

contentful space export --space-id "[your-space-id]" --environment-id "[your-space-environment]" --content-file exports/only-content-model.json --skip-content --skip-roles --skip-webhooks

Export only the CONTENT

contentful space export --space-id "[your-space-id]" --environment-id "[your-space-environment]" --content-file exports/just-content.json --content-only

Import to another space

contentful space import --space-id "[your-other-space-id]" --environment-id "[your-space-environment]" --content-file exports/all.json

Export using filters

contentful space export --space-id "[your-space-id]" --environment-id "[your-space-environment]" --content-file exports/filtered-content.json --query-entries 'sys.contentType.sys.id[in]=landingPage'

Simulate an error

contentful space export --space-id "[your-space-id]123" --environment-id "[your-space-environment]" --content-file exports/simulate-error.json --query-entries 'sys.contentType.sys.id[in]=landingPage'

Run migration script to create blogPost content type

contentful space migration --space-id "[your-space-id]" --environment-id "[your-space-environment]" migrations/1.create-blog-post.js

Migrate content from another CMS (faked with jsonplaceholder)

contentful space migration --space-id "[your-space-id]" --environment-id "[your-space-environment]" migrations/2.migrate-posts.js -y

Transform the author name field

contentful space migration --space-id "[your-space-id]" --environment-id "[your-space-environment]" migrations/3.split_author_name_field_into_two_fields.js

Derive content entries for new author content type

contentful space migration --space-id "[your-space-id]" --environment-id "[your-space-environment]" migrations/4.create-author-type.js

Clean up

contentful space migration --space-id "[your-space-id]" --environment-id "[your-space-environment]" migrations/99.cleanup.js

License

MIT

Reach out if you have any questions Chigoriddim

About

This repository serves as a practical guide on utilizing the Contentful CLI Tool for various common scenarios.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published