UNPKG

5.72 kBMarkdownView Raw
1# gatsby-source-medium-backup
2
3[![GitHub license](https://img.shields.io/github/license/eugenehp/gatsby-source-medium-backup.svg?color=blue&style=for-the-badge)](./LICENSE)
4[![npm](https://img.shields.io/npm/v/gatsby-source-medium-backup.svg?color=green&style=for-the-badge)](https://www.npmjs.com/package/gatsby-source-medium-backup)
5[![npm downloads](https://img.shields.io/npm/dw/gatsby-source-medium-backup.svg?label=npm%20downloads&style=for-the-badge)](https://npmcharts.com/compare/gatsby-source-medium-backup?minimal=true)
6[![total npm downloads](https://img.shields.io/npm/dt/gatsby-source-medium-backup.svg?label=total%20npm%20downloads&style=for-the-badge)](https://npmcharts.com/compare/gatsby-source-medium-backup?minimal=true)
7[![GitHub watchers](https://img.shields.io/github/watchers/eugenehp/gatsby-source-medium-backup.svg?style=for-the-badge)](https://github.com/eugenehp/gatsby-source-medium-backup/watchers)
8[![GitHub stars](https://img.shields.io/github/stars/eugenehp/gatsby-source-medium-backup.svg?label=GitHub%20stars&style=for-the-badge)](https://github.com/eugenehp/gatsby-source-medium-backup/stargazers)
9[![GitHub forks](https://img.shields.io/github/forks/eugenehp/gatsby-source-medium-backup.svg?style=for-the-badge)](https://github.com/eugenehp/gatsby-source-medium-backup/network/members)
10[![open bugs](https://img.shields.io/github/issues-raw/eugenehp/gatsby-source-medium-backup/bug.svg?color=d73a4a&label=open%20bugs&style=for-the-badge)](https://github.com/eugenehp/gatsby-source-medium-backup/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+label%3Abug)
11[![total open issues](https://img.shields.io/github/issues-raw/eugenehp/gatsby-source-medium-backup.svg?label=total%20open%20issues&style=for-the-badge)](https://github.com/eugenehp/gatsby-source-medium-backup/issues)
12[![GitHub pull requests](https://img.shields.io/github/issues-pr-raw/eugenehp/gatsby-source-medium-backup.svg?style=for-the-badge)](https://github.com/eugenehp/gatsby-source-medium-backup/pulls)
13
14[![Packagephobia](https://badgen.net/packagephobia/install/gatsby-source-medium-backup)](https://packagephobia.com/result?p=gatsby-source-medium-backup)
15[![Bundlephobia](https://badgen.net/bundlephobia/min/gatsby-source-medium-backup)](https://bundlephobia.com/result?p=gatsby-source-medium-backup@0.0.1)
16
17Gatsby plugin to import your medium posts from a backup as markdown files.
18
19## Installation
20
21We assume you've already [created gatsby website](https://www.gatsbyjs.com/docs/tutorial/part-zero/#create-a-gatsby-site) using command like this:
22
23```shell
24gatsby new example https://github.com/gatsbyjs/gatsby-starter-hello-world
25```
26
27### Install dependencies
28
29```shell
30cd example
31npm i -s gatsby-source-filesystem gatsby-transformer-remark gatsby-source-medium-backup
32```
33
34### Configure your gatsby plugins
35
36Go to `gatsby-config.js` and configure folder for your processed markdown pages first:
37
38```javascript
39const markdownPages = `${__dirname}/src/markdown-pages`
40```
41
42Then inside the `plugins` section add `gatsby-source-medium-backup` first and specify location of your medium backfile inside `source`:
43
44```javascript
45{
46 resolve: 'gatsby-source-medium-backup',
47 options: {
48 source: `${__dirname}/medium-export.zip`,
49 destination: markdownPages,
50 },
51},
52```
53
54Add markdown generation **after** above plugin!
55
56```javascript
57// markdown
58{
59 resolve: `gatsby-source-filesystem`,
60 options: {
61 path: markdownPages,
62 name: `markdown-pages`,
63 //prefix: 'blog' // optional: prefix all slugs
64 h1h2: true, // optional: convert all h3 and h4 to h1 and h2
65 // h2h3: true, // optional: convert all h3 and h4 to h2 and h3
66 },
67},
68`gatsby-transformer-remark`,
69```
70
71### Download your medium archive
72
73[Here](https://help.medium.com/hc/en-us/articles/115004745787-Download-your-information)'s official guide from Medium.
74
751. On your homepage, click on your profile picture and click Settings.
762. Scroll down to the Download your information section.
773. Click Download . zip and confirm by clicking Export.
784. A link to download your archive will be sent to you by email when it is finished.
79
80### Configure your gatsby blog posts generation
81
82This section essentially follows original guideline for adding markdown pages [here](https://www.gatsbyjs.com/docs/how-to/routing/adding-markdown-pages/)
83
841. Create [`./src/templates/blogTemplate.js`](./src/templates/blogTemplate.js), which will be used as a page template for your blog posts.
852. Configure your [`./gatsby-node.js`](./gatsby-node.js) to generate blog posts using markdown files during the build time.
86
87### Now run your gatsby
88
89```shell
90cd example
91gatsby develop
92```
93
94Navigate to [http://localhost:8000/404](http://localhost:8000/404) and you'll see your markdown pages generated.
95
96<img width="900" alt="Screen Shot 2021-04-08 at 20 26 36" src="https://user-images.githubusercontent.com/1857263/114124179-b8f62980-98a8-11eb-890c-94feb7eeedcf.png">
97
98
99## Troubleshooting
100
1011. Make sure to put absolute path for your medium archive.
102
1032. This plugin generate following metadata for each post:
104
105```json
106{
107 "title": "How to build a react-native plugin in 2021",
108 "author": "Eugene Hauptmann",
109 "authorLink": "https://medium.com/@eugenehauptmann",
110 "canonical": "https://medium.com/@eugenehauptmann/how-to-build-a-react-native-plugin-in-2021-60704edc0c28",
111 "timestamp": "2021-04-06T00:58:51.984Z",
112 "exportDate": "April 6, 2021"
113}
114```
115
116## Sponsorship
117
118Thank you to our sponsors:
119
120[<img width="300px" src="https://user-images.githubusercontent.com/1857263/114124204-c4e1eb80-98a8-11eb-80ab-64683c24bbc5.png" alt="Reactive Lions™" target="_blank">](https://www.reactivelions.com)
121
122## License
123
124[MIT](./LICENSE)
125
126Copyright (c) 2021 Eugene Hauptmann