修改 jekyll-amazon 标签的输出
Modifying the output of the jekyll-amazon tag
我在我的 Jekyll 站点中成功使用了 jekyll-amazon gem,但我想修改 detail 标签的输出。现在是:
def detail(item)
attrs = {
author: item[:author],
publisher: item[:publisher],
date: item[:publication_date] || item[:release_date],
salesrank: item[:salesrank],
description: br2nl(item[:description])
}.map { |k, v| ItemAttribute.new(k, v).to_html }.join("\n")
str = <<-"EOS"
<div class="jk-amazon-item">
#{image(item)}
<div class="jk-amazon-info">
#{title(item)}
#{attrs}
</div>
</div>
EOS
str.to_s
end
但我想从属性列表中删除出版商、日期、销售排名和描述。我可以重写此方法或更改 attrs 列表吗?如果可以,如何更改?
我尝试了将包含覆盖代码的文件放入 config/initializers 的技术,但这似乎不起作用。
0.3.0 支持 custom templates:
_config.yml:
jekyll-amazon:
template_dir: '_templates'
_templates/detail.erb:
<a href="<%= item[:detail_page_url] %>" target="_blank">
<%= item[:title] %> / <%= item[:author] %>
</a>
我在我的 Jekyll 站点中成功使用了 jekyll-amazon gem,但我想修改 detail 标签的输出。现在是:
def detail(item)
attrs = {
author: item[:author],
publisher: item[:publisher],
date: item[:publication_date] || item[:release_date],
salesrank: item[:salesrank],
description: br2nl(item[:description])
}.map { |k, v| ItemAttribute.new(k, v).to_html }.join("\n")
str = <<-"EOS"
<div class="jk-amazon-item">
#{image(item)}
<div class="jk-amazon-info">
#{title(item)}
#{attrs}
</div>
</div>
EOS
str.to_s
end
但我想从属性列表中删除出版商、日期、销售排名和描述。我可以重写此方法或更改 attrs 列表吗?如果可以,如何更改?
我尝试了将包含覆盖代码的文件放入 config/initializers 的技术,但这似乎不起作用。
0.3.0 支持 custom templates:
_config.yml:
jekyll-amazon: template_dir: '_templates'
_templates/detail.erb:
<a href="<%= item[:detail_page_url] %>" target="_blank"> <%= item[:title] %> / <%= item[:author] %> </a>