【发布时间】:2014-10-02 21:05:04
【问题描述】:
我正在尝试为我的 Middleman 网站创建一个索引文件,并希望在该文件中包含我网页的原始“内容”。即
/source/mypage.md:
---
title: My Page
---
# This is my page
With *my markdown*
和
/source/myotherpage.md:
---
title: My Other Page
---
# Here is my other page
我想要在/source/site_index.json.erb 的第三页,当输出看起来像这样时:
[
{'title': 'My Page', 'body': '#This is my page\nWith *my markdown\n'},
{'title': 'My Other Page', 'body': '#Here is my other page\n'}
]
我可以使用类似的方法获取标题等,但我不知道如何获取原始正文:
[
<% sitemap.resources.select{|resource| resource.content_type == 'text/html; charset=utf-8' unless resource.data.ignore }.each do |resource| %>
{
"title": <%= resource.data.title.to_json %>,
"body": <%= nil %>
} ,
<% end %>
]
【问题讨论】:
标签: ruby sitemap sprockets middleman