Generating pages from Json #101
Unanswered
petebannister
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I've been trying to figure out how to generate pages from some json data.. I'm finding it difficult to find the right information or any examples of how to do this (an example would be ideal!).
I was trying to use a script to do this and initially just trying to get at the data. I have a file called helpinfo.json in my inputs folder.
It looks something like this (but there are a lot more elements):
I want to then iterate that json to generate multiple pages, one for each 'menu'.
In a csx script I was then using:
But 'data' is empty.. If I use that same code in a cshtml file then 'data' is not empty and I can get the path of the file I want. If I use Context.Outputs instead of 'Outputs' then the build fails.
Is the Data pipeline run early in the process? Do I need to specify anything in the frontmatter to indicate that I want something from the Data pipeline?
Can you generate pages from a cshtml? In some ways that would be better as I'll have a root page that will have links to the generated pages - so I could generate those links + the pages they link to in some way?
Will I need to do something special in my bootstrapper?
Also, what would be the best way to iterate over the data?
Beta Was this translation helpful? Give feedback.
All reactions