Giter Club home page Giter Club logo

notion2ical's Introduction

notion2ical

A small script that, when called, will interrogate a Notion database and return all of the items in iCal format.

This allows you to add an iCal calendar to your regular Calendar app (Google, Apple, Outlook, etc) and the events are items that are taken from your Notion database. As you make changes in Notion, the events in the calendar will change automatically.

My Notion database is a Kanban board. The properties that are important to this script are:

  • Title is the title of the task and is used for the title of the event.
  • Status is a select property and the important values are "Doing", "Done" and "Not Doing". These determine if they should be included in the calendar, and if they should show an empty checkbox (๐Ÿ”ฒ Doing), a checked checkbox (โœ… Done), or a red cross (โŒ Not Doing).
  • When is a date property and is used to determine the day.
  • Tags is a multi-select property and a way to add hashtags to the end of the event.

Here is a screenshot of Notion database:

README-notion.png

Here is a screenshot of my calendar app showing the calendar that was generated by this script:

README-calendar.png

Pre-requisites

I wrote this using PHP 8.1. It would probably work with PHP 8.0, I'm not sure.

You need to have Composer installed.

How to use it

Install

git clone https://github.com/andrewbrereton/notion2ical.git
cd notion2ical
composer install

Configure environment variables

Create your .env file from the example provided:

cp .env.example .env

Open .env file to set the values for each variable.

Do it!

php src/notion2ical.php

The script will get the most recent 100 items from your Notion database, build up an iCal file, and upload it to your Gist.

Importing into calendar application

Once the script has been run, your calendar will be available at:

https://gist.githubusercontent.com/YOUR_GITHUB_USERNAME/GITHUB_GIST_ID/raw/notion2ical.ical

In your favourite calendar tool, there is generally the ability to subscribe to an online calendar. Use the URL above.

Scheduling update

Executing the PHP script every time you want to update your calendar may become a bit tedious.

I have a cronjob that runs every 5 minutes to ensure the iCal file on my Gist is always up-to-date.

*/5 * * * * root /usr/bin/php /opt/notion2ical/src/notion2ical.php &>/dev/null

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.