Modifying the output of the jekyll-amazon tag

72 views Asked by At

I am using the jekyll-amazon gem in my Jekyll site successfully, but I would like to modify the output of the detail tag. Right now it does:

      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

but I would like to remove publisher, date, salesrank and description from the list of attributes. Can I override this method, or change the attrs list, and if so, how?

I tried the technique of putting a file in config/initializers containing the override code but that didn't seem to work.

1

There are 1 answers

0
approxiblue On BEST ANSWER

0.3.0 supports 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>