devto -- publish to dev.to from your terminal
devto
is a CLI tool that helps submit articles to DEV from the terminal. It makes use of the APIs that DEV kindly provides in OpenAPI specification. devto
mainly does two things:
-
It collects all image links from the Markdown file into a
devto.yml
file with thegenerate
subcommand. For example, if we have./image-1.png
and./image-2.png
in the Markdown file, we will get the following:images: ./image-1.png: "" ./image-2.png: ""
-
It submits the article to DEV with the
submit
subcommand. Thesubmit
subcommand creates a new article in DEV and updates thedevto.yml
with the resultingarticle_id
.devto
will use thisarticle_id
in the following execution to perform an update operation instead of creating a new entry for the same article.
The DEV API does not have a way of uploading images yet. If we submit a Markdown content with relative paths of image links, DEV will not be able to show those images. As a workaround of this problem, we need to provide a full path for the images either manually via the devto.yml
file or using the --prefix
flag.
The Markdown file must contains at least the title property of the Jekyll front matter, like in:
---
title: An example title
description: ...
tags: ...
cover_image: ...
---
You can find more information about the usage via the --help
flag.
devto --help
brew install shihanng/devto/devto
curl -sLO https://github.com/shihanng/devto/releases/latest/download/devto_linux_amd64.deb
dpkg -i devto_linux_amd64.deb
rpm -ivh https://github.com/shihanng/devto/releases/latest/download/devto_linux_amd64.rpm
The release page contains binaries built for various platforms. Download the version matches your environment (e.g. linux_amd64
) and place the binary in the executable $PATH
e.g. /usr/local/bin
:
curl -sL https://github.com/shihanng/devto/releases/latest/download/devto_linux_amd64.tar.gz | \
tar xz -C /usr/local/bin/ devto
With Go already installed in your system, use go get
go get github.com/shihanng/devto
or clone this repo and make install
git clone https://github.com/shihanng/devto.git
cd devto
make install
Description | CLI Flag | Environment Variable | config.yml |
---|---|---|---|
DEV API key is needed to talk with DEV API. | --api-key |
DEVTO_API_KEY |
api-key |
api-key: abcd1234
Want to add missing feature? Found bug đ? Pull requests and issues are welcome. For major changes, please open an issue first to discuss what you would like to change â¤ď¸.
make lint
make test
should help with the idiomatic Go styles and unit-tests.
How to generate DEV's API client
make gen
See pkg/devto
for client documentation.