Today, I present you ๐ New Blog Post a simple way to create and publish dev.to blog posts from within Visual Studio Code.
Installation
To install the or search for ๐ New Blog Post
in the extensions go to the marketplace https://marketplace.visualstudio.com/items?itemName=timdeschryver.new-blog-post.
Writing a dev.to post
The default template of this extension is the dev.to
template. To create create a new blog post, right click in the explorer or use the command palette and select ๐ New Blog Post
Publishing to dev.to
In order to be able to publish your post to dev.to
, you have to first create an API access token.
You can create one at https://dev.to/settings/account. Once you have your token copy paste the token in your VSCode settings with the post.publishToken
setting:
{
"post.publishToken": "jbVJ8mwfY2WrPUGfDWjx4xxB"
}
To add this to your config, search via the command palette for settings
When you have added the token to your settings, go back to your post and you can use the ๐ Publish to dev.to
command in the command palette.
Why
I created this extension to get familiar with VSCode extensions.
Also, my workflow to write my blog posts is to:
- write them within VSCode
- publish them to GitHub
- there's a now trigger that automatically deploys a new version to timdeschryver.dev
- manually cross-post on dev.to
To make it a little bit easier to myself, I think this extension is a good addition to save a few minutes ๐.
More info
For more info and the source code of this extension, go to the GitHub repo
Top comments (32)
Installed! Please everyone let us know if there are other APIs we can provide to improve this experience so folks feel like they have full confidence in this process. Really fun stuff!!!
Thanks Ben!
If I encounter something I will definitely create an issue on GitHub ๐
Maybe one thing that took my a couple of minutes, would be to add some kind of validation responses in the response. For example: if the title has not been filled in, the response is
500: Internal Server Error
.But as I'm writing this, I also noticed that the api docs mentioned these validation messages - so it is probably me who's doing something wrong ๐
If you want I can create an issue for this and we can take it from there.
Could still benefit from a proper status code, in this case it sounds like you were missing information, so maybe a 400 is appropriate?
422 would probably be more appropriate, but yes, a 4xx status is the way to go.
Yes, I think having a 4xx would make these "errors" more understandable for us.
Nice tool! Thanks to share it :)
I visited your website, could you explain a bit your flow you used to update your website based on Now to create a new post on your site? I'm curious about it!
thanks
Thank Cyril!
I'm using Sapper as a static site generator (you could use more popular ones like Gatbsy, Gridsome, Next, ...). When I push changes to GitHub, Now has a trigger to build the website and deploy it to their servers.
In your repo, you should have a now.json for config, and a now-build script.
You can find out more info on Now for GitHub, if you have a question, feel free to DM me.
+1 for
now
.now
is great.Really cool - between this and VS Code's Spotify extension I may never have to leave my editor now
Spotify extension? Holy Mowly! That goes to the 'search it after exams' list ๐๐
Thanks Gabe! ๐
Nice job, just hoping that token is not your real one!
It WAS my real one.
The thing was that I couldn't revoke my access token, so I had to delay the publication of this post. Good thing the dev.to team solved this issue in a day ๐
Phew! Gotta be wary of those sorts of things!
Awesome VSCode extension! I made a CLI @hagnerd/devto inspired by this extension for any non-VSCode users. I'm sure it's a little rough around the edges still, but figured anyone who stumbled on this post might be interested. :)
Using this now! I had a question about code snippets but I was able to figure it out using markdown. Thanks for sharing!
Yes, the post you write is completely in markdown. I'm sorry I did not mention it.
I'm getting an "internal server error" when I try to publish. Any ideas how I could troubleshoot this? I'm not extremely fluent with VS Code extensions yet.
This version of the extension, simply calls the dev.to API and shows the response of the API. I will work on this, so these errors will be more readable in one of the upcoming versions.
I think you're getting this error because one of the front matter properties are not filled in - for more info see the api docs and search for front matter.
For now, feel free to DM me your blog post (or a trimmed down version) and I can take a look.
That makes sense! I didn't have the cover image and canonical url filled out. I'll let you know how it goes with my next post, planning on making another by early next week.
For what its worth, I just tried it with an empty image and canonical and it seems to be working on my end. The only required field (that I know of) is the title
Wow, it's amazing!
Awesome ๐ฅ๐ฅ
Thanks Bhupesh! ๐
Sounds awesome! I'll give it a try tomorrow (left my laptop at the office)
Cool! Feedback is always appreciated ๐
this is awesome, thanks!