GithubHelp home page GithubHelp logo

sophiabrandt / json-to-buttondown-email Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 0.0 225 KB

fetch blog posts from JSON API and send as a newsletter draft to buttondown.email

License: MIT License

JavaScript 100.00%
buttondown newsletter json

json-to-buttondown-email's Introduction

Project Status: Active โ€“ The project has reached a stable, usable state and is being actively developed. MIT License

json-to-buttondown-email

json-to-buttondown-email is a Node.js script to send newsletter drafts from a JSON API to buttondown.email.

The script fetches blog posts from a JSON endpoint.
After some HTML formatting, the blog posts are sent off to the email service's REST API.

Github Actions ensure that the script runs periodically.

I've created this script for my personal use, but feel free to fork it and make it your own.

Requirements

For local development:

Usage

The script creates a new draft for buttondown.email.
Go to https://buttondown.email/emails/drafts to edit your draft and send it to your newsletter subscribers.

The script does not send emails automatically. You can change the Buttondown API endpoint if you like a different behavior.

  1. Fork the repository and clone it to your computer.

  2. Create encrypted secrets for your repository:

  • POST_LIMIT (number of posts to fetch from your blog)
  • BLOG_NAME
  • BUTTONDOWN_EMAIL_TOKEN (this is the access token from buttondown.email)
  • EMAIL
  • JSON_ENDPOINT
  • MASTODON_URL

Note: We want to keep the buttondown access token secret.

  1. The script runs every Monday at 19:05 UTC. You can specify a different interval. Adjust .github/workflows/send.yml:
on:
  push:
  workflow_dispatch:
  schedule:
    # Change the line below, see https://crontab.guru/ for help
    - cron: "5 19 * * 1"
  1. The script creates a newsletter from the latest blog post. The value is hard-coded in fetch.js as the blogPostLimit.
/*
Change setting below for a different limit.
The maximum depends on your API endpoint, of course.
*/
const blogPostLimit = 1;

Roadmap

json-to-buttondown-email is a script that I created to send newsletter drafts when I release a new blog post.

I don't plan any new features.

If someone has a better idea for a free rss/json-to-rest-api workflow, I'm all ears.

Contributing

To contribute to json-to-buttondown-email, follow these steps:

  1. Fork this repository.
  2. Create a branch: git checkout -b <branch_name>.
  3. Make your changes and commit them: git commit -m '<commit_message>'
  4. Push to the original branch: git push origin <project_name>/<location>
  5. Create the pull request.

Alternatively see the GitHub documentation on creating a pull request.

License

MIT ยฉ 2020, Sophia Brandt.

json-to-buttondown-email's People

Contributors

sophiabrandt avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

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.