Git Product home page Git Product logo

crossposter's Introduction

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.

crossposter's People

Contributors

mr-destructive avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

crossposter's Issues

Fix Hashnode content body

Refactor the script for hashnode so that the body markdown is rendered properly.
The script currently parses the body but only raw markdown is displayed which is not desired.

You can modify the contents in the function hashnode inside the crosspost.sh script.

Prevent duplicate articles from posting

We can query the API with the username using the API token and search through the title and the body:
if those (title and body) match, we reject the post request.
else, the article is posted.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.