Comments (6)
If you would like I could also create a codesandbox with the code as well.
from react-notion.
So, I've been digging into this and it's a bit tricky. The NotionRenderer
is a recursive component... you give it the block map and it renders out the first block (initial the page) and the children of that block get the same treatment.
With a flat page as you show here, there's the page which is the main block and all its content. Essentially, for what we care about, we're rendering a flat list of content here.
The challenges comes by how NotionRenderer
renders each block. It iterates over the list, checks their type, and then renders that type. I think there's some base assumption here that things like lists would share a base block and that rendering that one block would render all its contents correctly. Unfortunately that's not the case. Every entry in a list is itself a new block. This somewhat makes sense considering the fact that a list entry could technically be... well... any other block?
So the renderer is looping through the page contents and rendering each block by its type. It sees the numbered_list
and it wraps that in an ol
... then it sees another numbered_list
and does the same. Therein lies the problem.
To really fix this it seems like the renderer can't just iterate through the blocks and render each on in turn. It needs to (at the very least) check for lists and group them in the correct ol
s or ul
s.
It's not necessarily the hardest thing, but not the easiest either. It'll make the rendering logic more complicated.
from react-notion.
Hmmm I've been looking into it as well and it seems to be an issue at the API level. The reason bullet lists work fine is because in the API response you can see that a Bullet List block has a content property that holds its children. But numbered lists don't seem to have this content property which is why it's assuming every block is a new list. I don't know how you could solve this though.
from react-notion.
@kartiknair I've got a PR
from react-notion.
@zephraph thanks for the quick work. I appreciate your help!
from react-notion.
As correctly mentioned by @kartiknair, there are still some issues with top level lists.
from react-notion.
Related Issues (20)
- Handling null properties values
- HTML IDs missing on Callout blocks for internal links
- Is it possible to style for dark mode?
- Uncaught TypeError: can't access property "caption", value.properties is undefined
- Unsupported type undefined
- Notion teamspace page images not rendering
- react-notion crashes when rendering untitled toggle block
- twitter embed HOT 1
- Grid layout is not working properly. HOT 1
- notion worker only fetching default view.
- Images are overflowing HOT 2
- How to create pretty URL slugs posts? HOT 1
- Toggle block is not showing the content when expanded HOT 3
- Are there plans to add a renderer for the official Notion API? HOT 7
- Checkboxes do not render HOT 6
- Return errors when importing unsupported content types HOT 7
- Dark mode issue HOT 5
- Allow styled links HOT 1
- Getting error Unsupported type undefined for heading & paragraph HOT 1
- How to modify href for in-page links?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-notion.