Make a list of pages based on a given set of emoji inside a Notion block using the Notion API and Javascript SDK.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Madeline Holland b9294ec0a7 Formatting 1 month ago
screenshots Add Screenshots 1 month ago
.env.defaults Initial commit 1 month ago
.gitignore Fill in gitignore from template 1 month ago Update License 1 month ago Formatting 1 month ago
index.js Update License 1 month ago
package-lock.json Initial commit 1 month ago
package.json Initial commit 1 month ago

Notion Emoji Page link List Creator

Or, Make a list of pages based on a given set of emoji.

This is a major work in progress, errors are not handled correctly, and not all planned features are implemented! Approach cautiously. This is also my first non-trivial JavaScript project so expect some oddities! (I usually program with Rust)

To run:

  • Clone the repository

  • Install node.js

  • Copy .env.defaults to .env and configure it accordingly, explanations for the options and examples are in the file.

  • Notion Key is the Integration token given at Notion's official webpage. Follow the instructions to make a new integration then put the token in the file while keeping the "".

  • Then share a database with the integration through Notion's UI.

  • Copy the link to the database (found with the 3 dot menu for the database in the sidebar, titled "Copy link") then paste the link somewhere and remove "" and everything including and after the "?" this is the database ID, and all pages in notion have their ID in the same spot in the URL so it's easy to extract. Eventually this script will do it automatically.

  • Put that ID in NOTION_DATABASE_ID.

  • Repeat the process for NOTION_PAGE_BLOCK_ID, which is the block which will hold the link list that is generated by the script.

  • Add the Emoji to sort by in EMOJI_LIST, they must be emoji, so use a tool like Get Emoji or similar to copy them if on a device without an emoji selector.

  • Leave RATE_LIMIT where it's at, some actions will be a bit slower, like generating the list may take a few seconds depending on the size of the list, but this ensures that Notion's rate limit will not be exceeded.

  • INCLUDE_ARCHIVED lets you include pages that have been deleted in the results, it's untested but should work.

  • Setting INCLUDE_NO_ICON and INCLUDE_FILE_ICON is broken at the moment. Having an additional Page Filter is untested, most likely broken, so leave the last 3 variables untouched.

  • To install dependencies npm i

  • And Finally, run the app!
    node -r dotenv-defaults/config index.js


Given database:

A picture of a Notion database, with random pages with and without emoji icons

The final rendered list, made up of Page Link Blocks, so they can be clicked without editing, unlike database views:

A picture of a list of pages, only including pages with the construction and red minus sign icons

  • By default, pages are returned in the order that they were last edited in. This will be configurable later.

TO DO / Roadmap:

  • Split the library portion out from the main index.js.
  • Actually process the errors in a meaningful way, retrying a connection if needed.
  • Implement caching for the database object, to ensure that if the current version is up-to-date since the script was last ran with the same settings then there's no need to re-download it, minimizing the API calls.
  • Apply the same logic to the link list itself, only updating the portions that have changed in the database rather than deleting and re-creating all of it every time.
  • Implement this as a extension + mini server model, to be able to keep lists updated without manually running the script every time. As part of this, implement adding a button to the Notion UI with a web extension to automatically set up the list and database rather than doing it manually with .env.