Hi @julesman -
This is definitely possible, and pretty straightforward.
I used a structure like this for a large project where there were 60 items in an art catalogue that each got their own page.
In the /data
folder, I have a subdirectory called catalogue
.
The contents look like this:
- data/catalogue/1.yml
- data/catalogue/2.yml
- data/catalogue/3.yml
- etc…
You can see the folder in question here. Any file in this folder can be accessed programatically via data.catalogue
(returns the group) or data.catalogue.1
(returns a hash of the YAML contents of the file). When you access a single file this way, you get a hash to the effect of:
{ "filename" => file contents }
where the file contents may be another hash, array, etc.
In the config.rb
file, you can proxy through through data files like this:
data.catalogue.each do |cat, entry|
proxy “/catalogue/#{cat}.html”, “/catalogue/template.html”, :locals => {
:entry => entry
}, :ignore => true
end
So cat
is the filename of the data file being accessed, and entry
is the contents of the YAML file as a hash.
You can see the rest of the project’s source here, and the live site is here. This is an example page generated from the proxied YAML files.
best,
Eric