Skip to main content

Crosspost your markdown articles to devto, medium, codenewbie and hashnode

Project description

Crossposter

Crosspost your articles to dev.to/medium.com/hashnode.com from the command line

  • Crossposter is a script(Python/BASH) to automate crossposting to platforms like dev.to, medium.com and hashnode.com. The script takes in markdown version of your post with a few inputs from you and posts it to those platforms. You would require a token/key for each of those platforms to post it from the command line.

There are two versions of the script:

The actual script is still not perfect (has a few bugs). Though it posts on dev.to and medium.com easily, the hashnode.com is buggy as it parses the raw markdown into the post and doesn't render as desired. So, its a under-development script, fell free to raise any issues or PRs on the official GitHub repo.

Crossposter Python Script

The python script initially is now a python package. You can essily install and configure it as per your requirements.

PyPI version

Dependencies for the python script:

Running the script:

Make sure you install the python package with pip or any other package manager like pipenv or poetry you would like:

pip install crossposter

# OR

pipenv install crossposter

# OR

poetry install crossposter

# OR

pipx install crossposter

Configuration

  • Create a config file config.json for customization
  • Create a folder for the output files

Inside the config file, you can specify the two attributes for the working of the script. The first is for generating the canonical_url for the post and the next is the output folder for the generated files for different platforms.

{
  "blog_link": "https://www.meetgor.com/",
  "output_folder": "crossout"
}

One it is installed, you can then specify the markdown file which you want to use as a post with:

crosspost <filename>.md

# OR with pipx

pipx run crossposter

This will prompt you for a few things, if not provided in the frontmatter of the command. There will be need of inputs like title, description, tags, status, cover-image, etc. If you provide it in the frontmatter, there will be no input prompt. Once the input is taken or the frontmatter is picked, it will set those frontmatter for various publications automatically.

# post to dev.to

crosspost <filename>.md --dev


# post to codenewbie.org

crosspost <filename>.md --cdb


# post to medium.com

crosspost <filename>.md --med

image

image

For further help on CLI command, you can get the help argument

crosspost --h

ShellScript is no longer developed because of content parsing issues, it has been converted to a python package

Though some basic functions will work in shell script like simple frontmatter, devto and medium posting.

Crossposter Shell Script

The crossposter shell script is a file to be used from a linux/unix command line in a shell environment. The procedure to execute the file is as follows:

Run the script on a bash interpreter with the command:

bash crosspost.sh

OR

bash crosspost.sh file_name.md

For posting the article you need to provide the following details:

Front-Matter

Meta data about the post

  • Title of Post
  • Subtitle of Post
  • Publish status of post(true or false)
  • Tags for the post (comma separated values)
  • Canonical Url (original url of the post)
  • Cover Image (URL of the post's image/thumbnail)

This information is a must for dev.to especially the title. This should be provide in the same order as given below:

---
title: The title of the post
subtitle: The description of your article
published: true
tags: programming, anythingelse
canonical url: url of your original blog
cover_image: coverimage_url
---

There is no need to enclose any of them with quotation marks. Published argument will be true if you want to publish it and false if you want to keep it in your Drafts.

In the demonstrations, we just need to enter the tokens once. The tokens will be stored locally in the keys.txt file and retrieved later within the script.

Posting on dev.to:

Posting on dev.to requires their API key which can be generated by going on the Dev Community API Keys. From there you can generate a new key with any name you like. You just need to enter the key to CLI once or manually enter in the keys.txt file with the format dev.to:key on the first line. This will be used for the future cross-posting whenever you execute the shell script(bash crosspost.sh)

You can provide the front matter manually in your markdown file or you will be prompted for the input. So, that is all you will require for posting on dev.to from the Command line.

Lets see the script in action

dev.to

If you want to add in more stuff to the post, you can check out the DEV.to API docs which is powered by Forem, there a ton of options you can hook to the front-matter in the shellscript.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

crossposter-0.6.0.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

crossposter-0.6.0-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file crossposter-0.6.0.tar.gz.

File metadata

  • Download URL: crossposter-0.6.0.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for crossposter-0.6.0.tar.gz
Algorithm Hash digest
SHA256 88431ef02050fdb40e9fe2b7e9377617a9a3c254c52c52ae11e1ffc8486a74f4
MD5 95c5818c092b0180f9e6ed1da6991f69
BLAKE2b-256 3685d3a6d0abd2798c1657b644771ba21ec5cdd357246b2ccf861729ed7f7f0e

See more details on using hashes here.

File details

Details for the file crossposter-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: crossposter-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 11.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for crossposter-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a511a70d48333cab1e4139d76f992e267ea1fc8edd4b55c9cd828d3cc1490944
MD5 99264084d2e815ac77c2d9df99a21cd8
BLAKE2b-256 176d7f3ce4555321dee9743f6519b73e9d6f883d8fae9e53f2af1f8bc91dd5ce

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page