class Jekyll::Tags::BibTag
Generate Bibliography for all citations used on that page.
Example:
{% bibliography %}
Public Class Methods
Calls superclass method
# File _plugins/jekyll-scholar.rb, line 135 def initialize(tag_name, text, tokens) super @text = text.strip end
Public Instance Methods
# File _plugins/jekyll-scholar.rb, line 140 def render(context) site = context.registers[:site] Gtn::Scholar.load_bib(site) # Which page is rendering this tag? source_page = context.registers[:page]['path'] global_bib = site.config['cached_global_bib'] # citeproc = site.config['cached_citeproc'] # We have our page's citations citations = site.config['citation_cache'][source_page] || [] # For each of these citation IDs, we need to get the formatted version + pull out # year, month for sorting. unique_citations = citations.each_with_object(Hash.new(0)) do |b, a| a[b] += 1 end.keys # Remove nil citations unique_citations = unique_citations.reject { |c| global_bib[c].nil? } # And now sort them by date + names sorted_citations = unique_citations.sort do |a, b| global_bib[a].date.to_s + global_bib[a].names.join(' ') <=> global_bib[b].date.to_s + global_bib[b].names.join(' ') end out = '<ol class="bibliography">' out += sorted_citations.map do |c| r = Gtn::Scholar.render_citation(c) %(<li id="#{c}">#{r}</li>) end.join("\n") out += '</ol>' out end