Is it possible to iterate through a data file using tags and categories based on a product data file? E.g.:
# toys.yml
- name: Fire Truck
id: 1
description: Red
category: Automobile
url: toys/fire-truck
tags: red, truck
- name: Freight Train
id: 2
description: Fast delivery mail
url: toys/freight-train
category: Train
tags: freight, train, rail
I'm using Proxy pages to generate pages.
data.toys.each do |t|
proxy toys.path, "toys.html", locals: { toy: t}, ignore: true
end
The index.html.erb
template would be:
<div class="toys">
<% data.toys.each do |t| %>
<h1><%= t.name %></h1>
<p><%= t.desription %></p>
<span class="category"><%= t.category %></span> // I would like this to be linked to generate categories based on the toys.yml file
<span class="tags"><%= t.tags %></span> // The same as category, generated tag pages based on the toys.yml
<% end %>
</div>
How can I do this? Should I just create:
- Individual toy pages eg. firetruck.md and not worry about generating pages and using meta data as a way to create category and tag pages?
- Or, should I create a
category.yml
can populate it with the categories, is there a way to link it totoys.yml
unique id?
I'm learning about static pages and wanted to know ways to implement this without building a db backed app.