This tool can glob a folder of markdown files with yaml frontmatter (typically found in Gatsby blogs) and ouput a Sanity.io .ndjson
-import file.
As a global CLI tool:
npm i -g markdown-to-sanity
# or
yarn add --global markdown-to-sanity
As a project dependency:
npm i markdown-to-sanity
# or
yarn add markdown-to-sanity
As CLI:
> markdown-to-sanity # follow the instructions
The CLI will write a ndjson
-file you can use with sanity dataset import
. Learn more about importing data to Sanity.
In a project:
const migrateFiles = require('markdown-to-sanity')
migrateFiles({
inputPath: '~/Sites/gatsby-blog/src/pages',
filename: 'production',
outputPath: './'
})