我正在使用 Middleman 创建一个静态网站,引用从电子表格中解析的产品。
我的表有这些列:
_________________________________
| Product Name | Price | Category |
| Pet Food | $12 | Pets |
| iPhone | $500 | Phone |
| Pet toy | $25 | Pets |
|______________|_______|__________|
我使用Pets
名为. 它为每个独特的类别创建一个页面,例如。和。Phone
product_category.html
pets.html
phone.html
问题是,考虑到我继续进行的方式,Middleman 为类别中的每个产品构建一个类别页面,然后跳过它,因为它是相同的:
remote: create build/pets.html
remote: identical build/pets.html
remote: create build/iphone.html
这是我的 config.rb 示例:
rows_by_categories = app.data.spreadsheet.sheet1.group_by { |row| row.category }
#Category Landings
app.data.spreadsheet.sheet1.each do |f|
proxy "/#{f.category.to_s.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')}.html", "/product_category.html", locals: {
f: {
categorytitle: f.category,
name: f.name,
all_in_category: rows_by_categories[f.category],
price: f.selling_price,
},
categories: rows_by_categories.keys,
}, ignore: true
end
我了解循环在我的电子表格的每一行上进行迭代,并为相应的类别重新创建一个页面。然而,我给的几次尝试,例如。修改app.data.spreadsheet.sheet1.each do |f|
成rows_by_categories.each do |f|
不成功。有什么线索吗?