-
Notifications
You must be signed in to change notification settings - Fork 249
Generate page from json directly #358
Comments
Well. Thanks for a interesting feature request. AFAIK This is currently not possible with Statinamic. But there is workaround, you can save your json data to files and let's Statinamic handle the rest like normal. |
@thangngoc89 hmm, interesting, thanks for suggesting. Save json data to json file or create markdown from json? |
That depends on which kind of data. Could you show me an example data structure of the JSON ? |
Real json date i can provide in next week. For now i have schema of fields which wp-api can provide: |
That's more than enough. You have 2 options here:
---json
// Dump all data you need here with JSON.stringify()
---
Main content put in there
In the integrating process, if there is any complications, you can ping me. This is a great use case that can a great show off for Statinamic ;) |
If you want to have statinamic working from with static/client build, you can simply generate files from your wp-api with the following content
This way, you can consume this files via content-loader with an empty rendering method (since body will already be html). statinamic will be able to generate collection data from those files. For assets (wordpress media), it should not be an issue since wordpress generate full url for media in the wysiwyg. A script that generate from wp-api to statinamic ready files will be highly appreciated for me (and the community haha). |
For the record, I'm building something similar to you. Take posts from Discourse forum API and build static site with that. If you need a hint, take a look https://github.com/thangngoc89/dnh-blog (most interested parts is in |
@kuzvac any update maybe? |
No, for now, we built layout pages with static data. |
Now we are supposed to be able to do this via phenomic loader plugins. Will need some tests I guess. https://phenomic.io/docs/usage/plugins/ |
@MoOx I was looking for a way to handle data files and render them with react components, and looked at Phenomic's plugin pipeline, but the PhenomicLoader only deals with front-matter and markdown, in your docs, and it's documented that "body is what will be injected in Phenomic's |
We can totally adjust our loader to accept file like yml and json directly. |
Yeah, as a work-around, it's a good one, since if you ever want to add a markdown content, you easily can without changing your structure that much.
Ideally, with means to smartly parse the source file paths into data (something like route: {
from: 'animals/:category/:name',
to: 'animals/:name',
save: [
'category',
'name'
]
} Phenomic is the existing technology closest to allowing me to do that, yet I don't really know if I can leverage Phenomic to do it, or if I'll end up having to write my own webpack loaders and plugins anyway. My guts say I could, but my brains, rummaging through the docs and the code, can't find a solution :/ |
To make it easy we can add native support for raw data. Anyway, the current way to consume data & collection will be refactored and improved, and API will probably change a little bit. |
I guess you're right, Phenomic gives me all the tools I need, I just need to engineer my way through the problem. Curiosity satisfied regarding raw data transformation. Thanks! |
If you want to take a look and play with things a little bit, here is where current transformations are made Lines 31 to 38 in 38662d0
|
Going to be fixed with #925 |
Can i use it for display pages from json directly, not from markdown?
Use case: I get json that need statinamic from wordpress (through wp-api, and some modifications). Feed this json to statinamic (route setups manually or dynamic), and statinamic render my pages.
It's really to do?
The text was updated successfully, but these errors were encountered: