-
Notifications
You must be signed in to change notification settings - Fork 105
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
Generate pages on the fly from data #159
Comments
I have ideas for the API for this, but they aren't finalized. What I currently have in the v2 alpha of Panini is the ability to convert any kind of file into a page. You write a function that takes in files matching a pattern like What I don't have is the ability to turn any arbitrary data source into a page. In your example, you're converting a single file, a JSON file, into multiple pages. |
In another variation, perhaps the output can be like this where each file under plant_records is a single record turned into a file.
|
I'm interested in this as well. If I have a JSON array, and I want to generate a page for each item in the array, where that item is passed into that page as data, there doesn't seem to be a way to do that currently. |
@gakimball can you post a copy of this function please. Currently i am only getting it to work if i put the file name but not if i use /*.md |
@w-biggs @dagostinelli |
Also looking for /*.md functionality. |
@TD540 @w-biggs @erutan I ended up writing my own. I called it spoonbill https://github.com/dagostinelli/spoonbill It doesn't use Foundation per-se. You can actually use anything you want with it. Foundation included. Basically, I replaced Panini with a Makefile and a python script that can take any-old .md file and spit out HTML. Ask me about it over at the spoon bill repository if you want to see examples of how to use it. Though simple, Spoonbill and it's Makefile together are actually very powerful. |
Oh, and to do the data.json -> .md conversion, I used another python script to do that. It is custom made for the web sites (can't really share it) But you can imagine how it might work. data.json -> convert.py -> tons of .md files
Then I used spoonbill to convert the .md files into .html files (via the makefile)
Works fast and does a great job. |
There’s plenty proper static site generators out there - I just use this occasionally for the speed / simplicity. :) Someone else was inputting content, and markdown preview didn’t want to show up on their editor due to the file extension. I ended up just telling it to treat all .html extensions as markdown. |
Current State
Put HTML and markdown into .html files stored in /pages and you get a url per page:
Requested Capability
Put HTML and markdown into a hierarchical JSON doc get a url per page:
I have a use-case for this. My project has a SQL database and we'd like to create a static, read-only site where there is 1 page per record. I can write a program to create the json file from the database and I can also generate a whole bunch of /pages/.html files from the database. In current state, I will have to generate a whole bunch of /pages/.html files.
Potential API:
The root parameter can take a directory for physical .html files and/or a hierarchical JSON doc.
The text was updated successfully, but these errors were encountered: