Gatsby plugin to import your medium posts from a backup as markdown files.
MIT License
Gatsby plugin to import your medium posts from a backup as markdown files.
We assume you've already created gatsby website using command like this:
gatsby new example https://github.com/gatsbyjs/gatsby-starter-hello-world
cd example
npm i -s gatsby-source-filesystem gatsby-transformer-remark gatsby-source-medium-backup
Go to gatsby-config.js
and configure folder for your processed markdown pages first:
const markdownPages = `${__dirname}/src/markdown-pages`
Then inside the plugins
section add gatsby-source-medium-backup
first and specify location of your medium backfile inside source
:
{
resolve: 'gatsby-source-medium-backup',
options: {
source: `${__dirname}/medium-export.zip`,
destination: markdownPages,
},
},
Add markdown generation after above plugin!
// markdown
{
resolve: `gatsby-source-filesystem`,
options: {
path: markdownPages,
name: `markdown-pages`,
//prefix: 'blog' // optional: prefix all slugs
h1h2: true, // optional: convert all h3 and h4 to h1 and h2
// h2h3: true, // optional: convert all h3 and h4 to h2 and h3
},
},
`gatsby-transformer-remark`,
Here's official guide from Medium.
This section essentially follows original guideline for adding markdown pages here
./src/templates/blogTemplate.js
, which will be used as a page template for your blog posts../gatsby-node.js
to generate blog posts using markdown files during the build time.cd example
gatsby develop
Navigate to http://localhost:8000/404 and you'll see your markdown pages generated.
Make sure to put absolute path for your medium archive.
This plugin generate following metadata for each post:
{
"title": "How to build a react-native plugin in 2021",
"author": "Eugene Hauptmann",
"authorLink": "https://medium.com/@eugenehauptmann",
"canonical": "https://medium.com/@eugenehauptmann/how-to-build-a-react-native-plugin-in-2021-60704edc0c28",
"timestamp": "2021-04-06T00:58:51.984Z",
"exportDate": "April 6, 2021"
}
Thank you to our sponsors:
Copyright (c) 2021 Eugene Hauptmann