Skip to content

How I use Notion and Astro to publish my monthly learnings

Posted on:
5 min Frontend Development Discuss on HN

I have been using Notion for about 2 years now and I really like it. I started using it with the Weekly to-do list and Reading list templates to manage a my weekly tasks and reading lists.

At Cryptlex, around August 2023, I was looking for an alternative to GitHub Projects, around the time Notion came out with project management features. I added Notion as one of the alternatives to consider, next to Asana, Jira, Linear and others. Eventually, we picked Notion despite it’s project management features being relatively limited because of how flexible it is (we call it a database with a UI on steroids) with diverse use cases and would also prevent us from using a separate tool for our internal wiki like Confluence.

After playing around with the Tasks and Projects templates at work, I wanted to unite my personal tasks, and reading databases to use the same structure.

Using the Tasks template

I was documenting research programs and jobs I wanted to apply to, interesting products I came across, things I have read, personal projects, and a lot more in separate databases and pages on Notion. Toward the end of December 2023, I migrated all these databases to the new Tasks and Projects templates to have a single source of truth for planning my productivity.

A screenshot of the Tasks database. It has the following columns visible in the "In Progress" tab: "Task name", "Type", "Status", "Complete", "Link", "Due", and "Project".

Networking, videos, lectures, articles, writing and travel, all in one place.

Tracking completed tasks

I go through the effort of saving all this information for the following reasons:

  1. I get a structured record of things that I have done and I can reflect on these experiences better.
  2. If I want to find something I have read or watched in the past, it is a simple search away.
  3. I like sharing what I have been learning with my colleagues and friends, which is much easier with this approach.

Previously, to achieve 3, I would sort the completed tasks by the Last Edited property. However, this started failing as soon as I wanted to update the database schema for all tasks. This meant that I would need a separate property “Completion Date” to track this information.

At first, I thought of using an automation to set the Completion Date but Automations are only available on paid plans. Thankfully, using the new database buttons feature allowed me to achieve the workflow I needed.

Automations aren’t available in the Free plan.
A screenshot of the Tasks database. It has the following columns visible in the "In Progress" tab: "Task name", "Type", "Status", "Complete", "Link", "Due", and "Project".

Using buttons allowed me to achieve the workflow I needed.

Automating publishing

My learnings were consolidated and more structured after I moved all the information to a single database. I’ve been curating a weekly learning list to share with my friends and colleagues for a while now and I wanted to leverage the structure to automate publishing this information.

I added a “Publish” checkbox property to the Tasks database to mark pages I will publish to my website and started creating an integration. The @notionhq/client for JavaScript made it easy to make this integration.

return notion.databases.query({
  database_id: databaseId,
  // This is unlikely to exceed 200, but if it does, good luck to me.
  page_size: 200,
  filter: {
    and: [
      // Status is Done
      {
        property: "Status",
        status: {
          equals: "Done",
        },
      },
      // Publish is true
      {
        property: "Publish",
        checkbox: {
          equals: true,
        },
      },
      // Date greater than or equal to
      {
        property: COMPLETION_TIME_PROPERTY_NAME,
        date: {
          on_or_after: after.toISOString(),
        },
      },
      // Date less than or equal to
      {
        property: COMPLETION_TIME_PROPERTY_NAME,
        date: {
          on_or_before: before.toISOString(),
        },
      },
    ],
  },
  sorts: [
    {
      property: COMPLETION_TIME_PROPERTY_NAME,
      direction: "descending",
    },
  ],
});

Combined with Astro’s static-site generation using the getStaticPaths() function, the end result is the Things I have learned page on this website.

Foreword

There are a few things I still want to figure out.

  1. How would I optimize the build process? Currently, in the getStaticPaths() function, I run a loop to get all publishable entries from every month since December 01, 2023. However, this will slow down the build process as the number of months increases and I expect it to break the build at some point.
  2. As an extension of the previous, how would I optimize cost if the API calls were paid? This is often a constraint in projects that have a larger scale than my personal website.
  3. How should I trigger a rebuild of the website on the 1st of every month? With the Cloudflare integration on my GitHub repo, pushing to main triggers a rebuild. As of now, a simple solution would be to make an empty commit and push it every month.