• Stars
    star
    122
  • Rank 292,031 (Top 6 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 3 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Cross Post a blog to multiple websites

Cross Post

GitHub license npm version

"Buy Me A Coffee"

Easily cross post your article on dev.to, Hashnode and Medium from your terminal.

Installation

In your terminal:

npm i -g cross-post-blog

Installation of MacOS with M1 chip

For Apple M1, it's best to have Node v14.

There are two ways to install this package on a MacOS with M1 chip:

Method 1: Rosetta Terminal

  1. If you don't have a Rosetta Terminal, go to Finder, then in the menu bar go to Go > Utilities. Duplicate "Terminal" and rename it to "Rosetta Terminal" or anything you want. Then click on the duplicate you create it and press "command + I" and choose "Open using Rosetta".
  2. Open the Rosetta Terminal you created, uninstall and then install Node again.
  3. Install this package again.

Method 2

  1. In the terminal run: arch -arm64 brew install pkg-config cairo pango libpng jpeg giflib librsvg
  2. Try installing this package again.

You might also need to add the following to ~/.zshrc:

export PKG_CONFIG_PATH="/opt/homebrew/Cellar:/opt/homebrew/lib/pkgconfig:/opt/homebrew/share/pkgconfig"

Usage

Set Configuration

For the simplicity of the CLI, and considering most of the APIs of each of the platforms do not allow or provide endpoints for user authentication, you will need to get your access tokens, api keys or integration tokens from your own profile before using cross post. This will just need to be done the first time or if you want to change the tokens.

The tokens are all stored on your local machine.

Here's a guide on how to do this for each of the platforms:

dev.to

  1. After logging into your account on dev.to, click on your profile image and then click on Settings

    Settings

  2. Then, click on the Accounts tab in the sidebar

    Accounts

  3. Scroll down to the "DEV Community API Keys" section. You need to generate a new key. Enter "Cross Post" in the description text box or any name you want then click "Generate API key"

    Generate API Key

    Copy the generated API key, then in your terminal:

    cross-post config dev

    You'll be prompted to enter the API key. Paste the API key you copied earlier and hit enter. The API key will be saved.

Hashnode

  1. After logging into your account on Hashnode, click on your profile image and then click on "Account Settings"

    Settings

  2. In the sidebar click on "Developer"

    Developer

  3. Click the "Generate" button and then copy the generated access token.

    Generate

  4. Run the following in your terminal:

    cross-post config hashnode

    First you'll be prompted to enter your access token. Then, you need to enter your Hashnode username. The reason behind that is that when later posting on hashnode your publication id is required, so your username will be used here to retreive the publication id. Once you do and everything goes well, the configuration will be saved successfully.

Medium

  1. After logging into Medium, click on your profile image and then click on "Settings"

    Settings

  2. Then click on "Integration Tokens" in the sidebar

    Integration Tokens

  3. You have to enter description of the token then click "Get integration token" and copy the generated token.

    Generate token

  4. In your terminal run:

    cross-post config medium

    Then enter the integration token you copied. A request will also be sent to Medium to get your authorId as it will be used later to post your article on Medium. Once that is done successfully, your configuration will be saved.

Cross Posting Your Articles

To cross post your articles, you will use the following command:

cross-post run <url> [options]

Where url is the URL of your article that you want to cross post. options can be:

  1. -p, --platforms [platforms...] The platform(s) you want to post the article on. By default if this option is not included, it will be posted on all the platforms. An example of its usage:

    cross-post run <url> -p dev hashnode
  2. -t, --title [title] The title by default will be taken from the URL you supplied, however, if you want to use a different title you can supply it in this option.

  3. -s, --selector [selector] by default, the selector config value or the article selector will be used to find your article in the URL you pass as an argument. However, if you need a different selector to be used to find the article, you can pass it here.

  4. -pu, --public by default, the article will be posted as a draft (or hidden for hashnode due to the limitations of the Hashnode API). You can pass this option to post it publicly.

  5. -i, --ignore-image this will ignore uploading an image with the article. This helps avoid errors when an image cannot be fetched.

  6. -is, --image-selector [imageSelector] this will select the image from the page based on the selector you provide, instead of the first image inside the article. This option overrides the default image selector in the configurations.

  7. -iu, --image-url [imageUrl] this will use the image URL you provide as a value of the option and will not look for any image inside the article.

  8. -ts, --title-selector [titleSelector] this will select the title from the page based on the selector you provide, instead of the first heading inside the article. This option overrides the default title selector in the configurations.

This command will find the HTML element in the URL page you pass as an argument and if found, it will extract the title (if no title is passed in the arguments) and cover image.

Cross Posting Local Markdown Files

Starting from version 1.2.3, you can now post local markdown files to the platforms. Instead of passing a URL, pass the path to the file with the option -l or --local.

For example:

cross-post run /path/to/test.md -l

You can also use any of the previous options mentioned.

Selector Configuration

If you need this tool to always use the same selector for the article, you can set the default selector in the configuration using the following command:

cross-post config selector

Then, you'll be prompted to enter the selector you want. After you set the default selector, all subsequent run commands will use the same selector unless you override it using the option --selector.

Image Selector Configuration

If you need this tool to always use the same selector for the image, you can set the default image selector in the configuration using the following command:

cross-post config imageSelector

Then, you'll be prompted to enter the image selector you want. After you set the default image selector, all subsequent run commands will use the same selector unless you override it using the option --image-selector.

Title Selector Configuration

If you need this tool to always use the same selector for the title, you can set the default title selector in the configuration using the following command:

cross-post config titleSelector

Then, you'll be prompted to enter the title selector you want. After you set the default title selector, all subsequent run commands will use the same selector unless you override it using the option --title-selector.

Uploading Data URI Article Images

If your website's main article image is a Data URL image, uploading it as it is would lead to an error on most platforms. There are 3 ways to avoid that:

Using a Cloudinary account

In this method, you'll need to create or use an already created Cloudinary account and the tool will use the account to upload the image and get a URL.

Follow the steps below:

  1. Create a Cloudinary account.
  2. Get the cloud_name, api_key, and api_secret from your account.
  3. Run cross-post config cloudinary and enter the information as prompted. Remember that all keys are stored on your local machine.

That's it. Next time you run the cross-post run command, if the image is a Data URL image, it will be uploaded to Cloudinary to get a URL for it. You can delete the image once the article has been published publicly on the platforms.

Pass Image URL

You can pass an image URL as an option to cross-post run using --image-url.

Post Article Without Image

You can pass the option --ignore-image to cross-post run and the article will be published without an image.

Reset Configuration Values

you can reset configuration values for each platform like this

cross-post config reset <platform name>

for example,

cross-post config reset dev

will reset all configuration values for dev.to platform

All available reset commands are

Commands:
  dev             reset configuration for dev.to
  medium          reset configuration for medium.com
  hashnode        reset configuration for hashnode.com
  cloudinary      reset configuration for cloudinary
  all             reset all *non-platform* configuration

The command cross-post config reset all or simply, cross-post config reset will reset every configuration value except the platform configuration values.


License

MIT

More Repositories

1

awesome-resources

😎 List of helpful resources added by the community for the community!
HTML
1,399
star
2

quran-extension

Replace the new tab page with Quran verses and beautiful nature pictures.
JavaScript
86
star
3

medusa-marketplace

Create a Marketplace with Medusa
TypeScript
76
star
4

medusa-marketplace-tutorial

Code for Medusa Marketplace Tutorial
TypeScript
52
star
5

medusa-1.8-marketplace-tutorial

Code for creating a marketplace with Medusa v1.8
TypeScript
46
star
6

todos-cli

JavaScript
28
star
7

cross-post-notion

Integration to cross post articles from Notion across platforms
TypeScript
28
star
8

node-2fa-tutorial

Code for Add 2-Factor Authentication with Google Authenticator in Node.js
EJS
18
star
9

pikachu-everywhere

Repository for Chrome extension in the tutorial
JavaScript
17
star
10

use-dark-mode-hook

useDarkMode custom hook for react
JavaScript
12
star
11

chrome-screenshot-tutorial

Tutorial about Taking Screenshots in Chrome Extension
JavaScript
12
star
12

medusa-b2b

Code for Medusa B2B tutorial
TypeScript
11
star
13

chrome-commands-tutorial

Code for Tutorial on Adding Keyboard Shortcuts (commands) in Chrome Extensions
JavaScript
10
star
14

medusa-source-magento

A Medusa plugin that imports data from Magento
TypeScript
10
star
15

medusa-reviews-tutorial

Code for How to Add Product Reviews to Your Medusa Server and Next.js Storefront
TypeScript
10
star
16

medusa-comic-store

A tutorial to build a comic store with Medusa
TypeScript
10
star
17

mongodb-realm-tutorial

Code for MongoDB Realm Tutorial
JavaScript
9
star
18

grammarly-ghost

Allow Grammarly to work on Ghost's editor
JavaScript
9
star
19

history-bot

Repo for Twitter Bot tutorial: History Bot
JavaScript
8
star
20

strapi-react-native

Code for Create a Notes App with Strapi and React Native
JavaScript
7
star
21

react-i18n-tutorial

Tutorial for Internationalization In React
JavaScript
7
star
22

react-transition-group-tutorial

Code for How to Animate Components' Entrance and Exit in React Tutorial
JavaScript
7
star
23

medusa-customer-storefront

Code for How to Use Medusa JS Client to Implement Customer Profile
JavaScript
6
star
24

quran-extension-firefox

Quran In New Tab add-on for firefox
JavaScript
6
star
25

railway-deploy-demo

TypeScript
5
star
26

react-query-tutorial

Code for React Query tutorial
JavaScript
5
star
27

react-native-tutorial

React Native Tutorial
JavaScript
5
star
28

react-google-charts-tutorial

Tutorial On How to Use Google Charts in React
JavaScript
5
star
29

mediastream-tutorial

Tutorial on MediaStream API
JavaScript
4
star
30

social-search

Repository for tutorial How to Search Through Different Social Media Platforms
JavaScript
4
star
31

knex-tutorial

Code for Knex.js Tutorial
JavaScript
4
star
32

medusa-store-tutorial

Code for Medusa Store Tutorial
JavaScript
4
star
33

react-qr-tutorial

Code for React QR Tutorial
JavaScript
4
star
34

firefox-alarms-addon

GitHub Repository for Firefox AddOn Tutorial for SitePoint
JavaScript
3
star
35

butter-blog

Code for Butter Blog Tutorial with Laravel
PHP
3
star
36

nextjs-storefront-v2-deploy

TypeScript
3
star
37

laravel-mongodb-tutorial

Code for the Laravel and MongoDB tutorial
PHP
3
star
38

b2b-server

Code base for B2B server
JavaScript
3
star
39

laravel-pdf-tutorial

Tutorial for Creating PDF with Laravel
PHP
3
star
40

reservations-system

PHP
3
star
41

react-forms-tutorial

Code for How to Create and Validate Forms in React using Formik and Yup tutorial
JavaScript
3
star
42

swag-storefront

JavaScript
2
star
43

react-context-tutorial

Code for React Context Tutorial
JavaScript
2
star
44

laravel-react-router

Laravel React Router Tutorial
PHP
2
star
45

my-blog-v2

CSS
2
star
46

react-transifex-tutorial

Code for How to Internationalize (i18n) a React App with Transifex
JavaScript
2
star
47

quran-extension-api

API for Quran extension
JavaScript
2
star
48

quran-extension-website

Website for Quran In New Tab Extension
CSS
2
star
49

railway-test

JavaScript
2
star
50

node-csv-tutorial

Code for Read and Write CSV files using Node.js and Express
HTML
2
star
51

medusa-railway-v2

TypeScript
2
star
52

marketplace-v2

TypeScript
2
star
53

fingerprinting-tutorial

Browser Fingerprinting tutorial with FingerprintJS
JavaScript
2
star
54

symbl-tutorial

Tutorial code for Symbl.ai
HTML
2
star
55

the-bf-meter-api

API for The Beginner-Friendly Meter. The Community Rates How Beginner Friendly a Repository Is.
2
star
56

create-medusa-app-demo

Playing around with create medusa app
TypeScript
2
star
57

my-search-results

An extension for saving search results
JavaScript
2
star
58

strapi-laravel-blog

Code for Laravel blog with Strapi
PHP
2
star
59

chrome-omnibox-tutorial

Tutorial on How to Use Chrome's Omnibox API
JavaScript
2
star
60

medusa-admin-tutorial

Code for Medusa's admin tutorial
JavaScript
2
star
61

laravel-resources-tutorial

Tutorial on Laravel Resources
PHP
2
star
62

react-navigation-tutorial

Code for React Native Navigation Tutorial
JavaScript
2
star
63

sudoku-restored

JavaScript
1
star
64

gatsby-unsplash-plugin

Tutorial on Creating a Gatsby Plugin
1
star
65

search-social-images

1
star
66

admin-test-deployment

1
star
67

gatsby-starter-medusa2

1
star
68

admin2

TypeScript
1
star
69

tinymce-plugin-tutorial

TinyMCE Plugin Tutorial
JavaScript
1
star
70

article-analytics

Retrieve article analytics from different platforms such as Dev.to
JavaScript
1
star
71

my-website-v2

JavaScript
1
star
72

foxit-examples

Examples of PDF manipulation features and how to implement them with Foxit
HTML
1
star
73

agora-tutorial

Code for Agora.io tutorial
EJS
1
star
74

swag-admin

TypeScript
1
star
75

laravel-rbac-tutorial

Code for Laravel RBAC Tutorial
PHP
1
star
76

railway-medusa-test

JavaScript
1
star
77

react-shop

Repository for the React + Tailwind CSS tutorial for SitePoint
JavaScript
1
star
78

test-repo

1
star
79

use-online

React Custom Hook Tutorial - Use Online
JavaScript
1
star
80

digitalocean-test

JavaScript
1
star
81

nextjs-starter-medusa-1

TypeScript
1
star
82

muslim-reminders

Muslim Reminders app built with Ionic
TypeScript
1
star
83

laravel-elasticsearch

Code for Laravel with Elasticsearch and Okta tutorial
PHP
1
star
84

numbers-trivia

Source code for tutorial
JavaScript
1
star
85

sajari-no-results-tutorial

Tutorial for Sajari's no results page
EJS
1
star
86

social-summary

JavaScript
1
star