-
Notifications
You must be signed in to change notification settings - Fork 385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ponzu gen content with JSON file #279
Comments
Hi @joshdstockdale - there has been some discussion (though quite a while ago) where something similar to your example schema was suggested. See this ticket for some more context: I haven't done much thinking about this, but I agree that it could be a useful feature. One question I have about this approach is if I don't use a I'm glad to see more people thinking about this -- and would be happy to consider a spec for how it would work in order to get it in as a feature. |
Hi guys, This feature to (re)generate content from a file is something that I think would be very useful. I've read this and previous discussion also. I think the most simple format is this one, but I made some tweak to the structure. So I try to write it myself and here is the PR #327 Let me tell you how it works Now the CLI to generate content accept 2 new optional flags Example: $ ponzu gen content review --source Will try to load On the other side Example: $ ponzu gen content review title:"string" body:"string":richtext rating:"int" --output will write to { "body": "string:richtext", "rating": "int", "title": "string" } limitation This feature still have a lot of rooms for improvements, this is some of them that I can think of:
Let me know what you guys think 🥂 |
@junnotantra you're in the zone my friend :) This looks excellent thank you for furthering it. Again, I'm really time poor at moment, but someone will get to this as soon as possible. Two observations after only (admittedly) scanning the above, apologies if I missed:
Will look further ASAP. Maybe @ponzu-cms/team or @joshdstockdale may want to input. |
Hi @olliephillips ,
yes, it just works like usual
This also crossed my mind when I'm making the changes. Not sure if it's worth it, I think to just use the content directory to centralize everything. But this sure can be an improvement. If anyone else think this is a must have feature for now, just let me know. |
Just two observations / comments:
I think the use of multiple
In order to make this as elegant as possible, if the
This way, users can add Does that make sense? Happy to clarify. Thanks, |
Hi @nilslice
Currently I only a few contents in my projects, so I haven't feel weighed down yet. But using one global json file sounds better. Will work on it.
Adding comment at first line is OK for me. But not sure if it's necessary to differentiate file name when we generate using IMO it might confuse the user as well if there are two different file can be generated. Maybe anyone else have another thought about this @olliephillips @joshdstockdale |
Have you thought about generating the content from a provided json schema?
ponzu gen content -f song.json
And the schema in the song.json would validate against the intended output of the API. For instance, this schema:
{ "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "properties": { "data":{ "type":"array", "items":[{ "type":"object", "properties":{ "uuid": {"type":"string"}, "id": {"type":"integer"}, "slug": {"type":"string"}, "timestamp": {"type":"string", "format":"datetime"}, "updated": {"type":"string", "format":"datetime"}, "title": {"type":"string"}, "artist": {"type":"string"}, "opinion": {"type":"string"}, "img_url": {"type":"string", "format":"url"}, }, "required":["title","artist","img_url"] }] } } }
Would generate the backend form and content type. Then when data is loaded into that content type, it would output json from the api like:
{ "data": [ { "uuid": "3d3e4b20-939c-4663-b7d0-f3fa6b172b4a", "id": 1, "slug": "song-3d3e4b20-939c-4663-b7d0-f3fa6b172b4a", "timestamp": "2018-09-08T02:23:02Z", "updated": "2018-09-08T02:23:02Z", "title": "Song 1", "artist": "Thomas Thomas", "rating": 1, "opinion": "Good, but redundant", "img_url": "http://zoohoo.dallaszoo.com/wp-content/uploads/2016/10/IMG_4093-Jax-Mandrill-CS.jpg" } ] }
Which validates against the above schema. And there could be additional fields added to the schema that would handle things like :richtext
The text was updated successfully, but these errors were encountered: