是否可以使用基于产品数据文件的标签和类别来遍历数据文件?例如:
# 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
我正在使用代理页面来生成页面。
data.toys.each do |t|
proxy toys.path, "toys.html", locals: { toy: t}, ignore: true
end
index.html.erb
模板将是:
<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>
我怎样才能做到这一点?我应该创建:
- 单独的玩具页面,例如。firetruck.md 并且不用担心生成页面和使用元数据作为创建类别和标签页面的一种方式?
- 或者,我应该创建一个
category.yml
可以用类别填充它,有没有办法将它链接到toys.yml
唯一 ID?
我正在学习静态页面,并想知道如何在不构建数据库支持的应用程序的情况下实现这一点。