Socket
Socket
Sign inDemoInstall

contentful-to-sanity

Package Overview
Dependencies
341
Maintainers
47
Versions
28
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    contentful-to-sanity

Migration tool from Contentful to Sanity


Version published
Weekly downloads
26
increased by100%
Maintainers
47
Created
Weekly downloads
 

Changelog

Source

4.2.9 (2024-04-07)

Bug Fixes

  • use the right typesVersions export (9d54c21)

Readme

Source

contentful-to-sanity

npm stat npm version

This package liberates Contentful spaces, creating Sanity projects and schemas as it goes.

Install

npm i -g contentful-to-sanity

Or use it on demand with npx:

npx contentful-to-sanity@latest --help

Usage

1. Open Contentful and navigate to your space: https://app.contentful.com/

  • Find your contentful space ID of your project (under Space settingsGeneral)
  • Create an API Key and get the Content Delivery API - access token (under SettingsAPI keysContent delivery / preview tokensadd api key)
  • Create a content management token (under SettingsAPI keysContent management tokensGenerate personal token)

2. Setup a clean Sanity v3 Studio and connect it to, or create, the Sanity project and dataset you want as your destination:

npm create sanity@latest --template clean --create-project "Your Project Name" --dataset production --output-path ./migrate

3. Run the migration, which prepares a dataset.ndjson file for the later import step:

npx contentful-to-sanity@latest -s <space-id> -t <management-token> -a <access-token> ./migrate

4. Start the dataset import process, which will finish in the background:

cd ./migrate && npx sanity dataset import ./dataset.ndjson

5. Open ./migrate/sanity.config.ts

If you chose the clean template it should look like this

import {defineConfig} from 'sanity'
import {deskTool} from 'sanity/desk'
import {visionTool} from '@sanity/vision'
import {schemaTypes} from './schemas'

export default defineConfig({
  name: 'default',
  title: '<project-name>',

  projectId: '<project-id>',
  dataset: '<dataset>',

  plugins: [deskTool(), visionTool()],

  schema: {
    types: schemaTypes,
  },
})

Now replace the schemaTypes import with the generated one:

import {defineConfig} from 'sanity'
import {deskTool} from 'sanity/desk'
import {visionTool} from '@sanity/vision'
-import {schemaTypes} from './schemas'
+import {types as schemaTypes} from './schema'

export default defineConfig({
  name: 'default',
  title: '<project-name>',

6. Try the Studio 🎉

npm dev

You don't have to wait for the npx sanity dataset import ./migrate/dataset.ndjson job to finish before the Studio is ready for use. The Studio will keep up to speed with the progress of the import job in real-time.

Commands

For more information on the available commands and their options, run contentful-to-sanity --help.

License

MIT © Sanity.io

Keywords

FAQs

Last updated on 07 Apr 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc