zernonia / vue3-notion

An unofficial Notion renderer (Vue 3) version
https://vue3-notion.vercel.app/
MIT License
132 stars 20 forks source link

Database support to create blog pages from Notion tables #11

Open conradlin opened 2 years ago

conradlin commented 2 years ago

Describe the solution you'd like I'd love to work together with you to develop database support so we can iterate on posts and create the custom CMS page for each.

Describe alternatives you've considered Previously, I was using Gatsby <> Notion integration but its since been depreciated. Your solution is great but doesn't allow me to add a custom blog template for blog pages, and also specify slug, page descriptions, etc.

Additional context I hosted a livestream today where I built with your tool live and would love to continue developing more!

zernonia commented 2 years ago

Hi @conradlin The Collection view (aka Database) is quite challenging, PR is most welcomed ya!

If you really want a quick solution to retrieve Database data, you can use Official Notion API.

hacknug commented 2 years ago

Describe alternatives you've considered Previously, I was using Gatsby <> Notion integration but its since been depreciated. Your solution is great but doesn't allow me to add a custom blog template for blog pages, and also specify slug, page descriptions, etc.

You can currently use $notion.getPageTable() to get the entries of a database. Note this will not fetch the content for each individual entry, only its properties (if you need the content, you'll need to use $notion.getPageBlocks()).

One of the issues I encountered when building my project was that I needed to get schema of a database to be able to implement a way to filter my posts. I could have used the values inside each post but I wanted to also show categories that don't have any post attached.

This led me to fork notion-api-worker to apply a small change. In my fork, getPageTable() returns both the rows data (just like the original does) as well as the schema definition. You can try my worker in case you also need that data to build your site: https://notion.incoming.workers.dev/v1 (getPageBlocks and getPageTable accept a second parameter with a custom URL for the worker).


If you want to be able to manually sort your database entries without relying on a property of the table, this is your only option. Notion's public API doesn't support database's views, so using the private API is the only way I've found to be able to drag'n'drop entries to sort them any way I want.

I reached out to support asking if/when will they add support for Views and I got the same response I got for years when asking about the status of the public API, so I wouldn't count of having it any time soon. They're a small team and usually take their time to build everything the way they consider best.