How To Post Articles on Dev.to Using Ruby From The CLI
b0bby_seal
Posted on February 28, 2021
Requirements:
-
ruby
-v ~< 2.50 -
json
-> (gem install json
)
Steps
Generate an API key
Goto: settings -> account -> DEV Community API Keys
Click Generate
Copy the <api_key>
to your buffer
Add this line at the end of your ~/.bashrc
file
export DEVTO_KEY="<paste_api_key_here>"
Copy this gist into /usr/local/bin/
as: publish
sudo cp publish /usr/local/bin/
Modify permissions: sudo chmod +x /usr/local/bin/publish
Do a test run: publish hello_world.md DEVTO_KEY
If it worked; Great! If it didn't, leave a comment where you got stuck.
NOTE: In order to make your post public; make sure to set published: true
so that it shows on your dashboard. You can only add maximum of 4 tags when adding tags. Titles can not have special characters otherwise you will have formatting issues.
Here's the formatting I use:
---
title: Hello World,
published: true,
tags: ["helloworld", "100daysofcode"]
---
Your content goes here
Posted on February 28, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.