How to bring JSON from Notion API into Unified? #166
-
Where I'm atI'm been hacking at the "vomit draft" version of this tool (which I'll explain more about below, if you're interested). It's at a point now where I've proved the basic premise to myself, so I'm ready to switch out my messy first draft for something with a bit more formal correctness. In particular, the current version naively converts raw JSON to strings, concatenates them, and saves them as a .svelte file. Where I want to beHere's pseudo-code for what I want to end up with:
I feel like I understand how all these pieces fit together, and have done a bunch of tutorial work, but none of the examples seems to quite fit my scenario, and whenever I dive in hoping that I'll figure it out along the way, my understanding gets swamped by Unified's sheer scale. The question (for now)What are the pieces I'm going to need, and where should I look to find the simplest model(s) to follow in putting them together? I feel like I'm super close to getting this, but right now my brain just keeps getting overwhelmed by the abstractness of it all. 😬 BackgroundI'm not sure if this helps at all, but here's the higher-level view of what I'm trying to do. Maybe it'll interest you. Maybe it'll just help make it clear that I'm going about this all wrong. Anyway, here's the possibly-irrelevant details of why I'm making The first part's straightforward: I find writing to be easier in Notion than any of the other tools I've tried, including heavy hitters like Ulysses and Scrivener. So, input-wise, Notion.so is the choice, which also makes it my de facto CMS. Here's where I stray slightly from conventional wisdom, which would have me making API calls to Notion from the client's machine in order to hydrate pages with the most up-to-date content. What I want to do instead…because I'm a control freak?…is pull any pages that I've marked in Notion as Ready To Publish, transform them (I think, using unified?) into Svelte pages, where the content (and sometimes settings such as "checked" for a to-do item) get translated into simple inputs to pre-conceived Svelte components, similar to what I've already implemented, and spitting the results out as .svelte files. This will allow me to store both the raw JSON and rendered Svelte in .git, which works well for what's likely to be an entirely static site, and gives me full control of the end product. Ideally, the tools I create along the way can be generic enough for others to make use of them, even if they prefer to work with streams rather than files because, say, they prefer for the site to pull pages from Notion on the fly. ¯_(ツ)_/¯ |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Very interesting, have you talked at all with the maintainer(s) of https://github.com/phuctm97/ntast and/or https://github.com/dragonman225/nast?
In short two plugins a parser and a compiler, breaking it down into utilities beyond those two is optional. |
Beta Was this translation helpful? Give feedback.
Very interesting, have you talked at all with the maintainer(s) of https://github.com/phuctm97/ntast and/or https://github.com/dragonman225/nast?
In short two plugins a parser and a compiler, breaking it down into utilities beyond those two is optional.
A parser in unified is something that takes in a string/text and outputs an AST, a compiler takes an AST an generates a string (or a svelte component).
There is some high level API info at https://github.com/unifiedjs/unified#processorparser and https://github.com/unifiedjs/unified#processorcompiler
There are s…