来自 赵鹏 | November 6, 2017
Yesterday, I built two mirror sites for my steem posts (mirror 1,mirror 2) as backups, which are synced automatically everyday, thanks to steemsql and steemdata. The mirror sites are very useful:
- for emergency, in case that steemit.com and busy.org are down,
- as backups, in case that steemsql and steemdata are gone,
- for revision, where the posts are allowed to be modified even after 7 days,
- for more replies, thanks to disqus,
- for a stable looking, no matter how the interface of steemit changes in the future, and
- for fast browsing, especially when your posts are more than 100.
Both of these sites are free of costs, and updated automatically.
How long does it take to build a site like them?
Following my steps, it takes less than half an hour, if you are an expert on R language. For newbies, it depends on how long it takes you to learn R. Anyway, you will save much time that I wasted in many failed attempts.
Here are the steps.
Build a Hugo site with R blogdown
- Install R and RStudio.
- Created a blogdown project from RStudio's menu.
Download your posts from steemsql or steemdata
- R RODBC can visit steemsql database, and R mongolite can visit steemdata database. Either is OK.
- Download the target posts, and organize them into markdown files with R.
- Copy the markdown files into the contents folder in your site folder.
- Run the build_site() function in R blogdown.
Publish your site folder to Github
Create a new repo on Github, and publish your site folder.
Deploy with Netlify
- Log in Netlify.com with your github account.
- Created a new site, choose your site folder from github, and use hugo_0.19 as the command.
- Wait seconds or minutes, and you can visit your mirror sites!
Sync automatically everyday
- Write a .bat script on Windows, or .sh script on Linux, to call your R script, which downloads the new posts, builds the site, and syncs with Github repo.
- Use the task scheduler on Windows or crontab on Linux to run the .bat or .sh automatically everyday or every hour or whatever.
That's all. Wish you success!