Using Data files in other documents #118
-
I was attempting this because I thought it would be possible to do, but I didn't find the way it should work: I have a yaml document with a list of names and emails:
I want to iterate and show them from a cshtml file. Using the idea from https://www.statiq.dev/web/content-and-data/data I can get the document itself. What I am not able to find is how to get the users and iterate over the list. Attempting to accomplish this, I have been mainly wishing for a few things in the documentation:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
The key here is knowing that YAML files with nested objects get represented as nested documents (I.e. One way to explore this is using the REPL that you get when you run in Granted, you kind of have to know what you're dealing with in terms of objects to really dig through it (or do a lot of So now that we know what the structure looks like by exploring it via the REPL after an execution, I can write code like this in Razor:
Totally agree! My main task right now is to finish up Statiq Docs which generates exactly that kind of site. It's not totally from scratch either - I'm porting over most of the code from Wyam, so the API docs will eventually look something like this: https://wyam.io/api/wyam.common.io/. I'm hoping to have this finished sometime in the next couple months.
Also totally agree! There's a framework in place for actual runnable examples, but I've only gotten so far as to do some for archives. I really want to get Statiq Docs finished and get some API documentation up first, but examples will be the next thing I focus on after that. |
Beta Was this translation helpful? Give feedback.
-
Okay, kinda related question: I have a content file, I would expect that setting both to false would generate the homepage-notice.html file but not save it to the output directory, but it doesn't seem to, the On the other hand, I don't think I have got the proper way to include this content in the
But that seems overly complicated (and I'm not disposing of the textreader, as is said I should do in the comments for the My first approach to this was to try to just load the markdown code from some metadata value and pass that through the markdown compiler, but I don't think that's actually doable? Thanks! |
Beta Was this translation helpful? Give feedback.
The key here is knowing that YAML files with nested objects get represented as nested documents (I.e.
IDocument
) within the root document. So in this case, theusers.yaml
file (assuming that's what it's called) will end up in theOutputs
collection and that document that represents the data file will have a key of "users" which contains a list of documents, each with a "name" and "mail" key.One way to explore this is using the REPL that you get when you run in
preview
mode:Granted, you kind of have to know what you're dealing with in terms of objects to really dig through it (or do a lot of
.GetType().ToString()
calls to figure it out). One enhancement that'll make this easier is the a…