npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

contentful-to-sanity

v4.2.9

Published

Migration tool from Contentful to Sanity

Downloads

175

Readme

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