Skip to content
This repository has been archived by the owner on Feb 21, 2023. It is now read-only.

sophiabrandt/json-to-buttondown-email

Repository files navigation

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.

About

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

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published