Module: Jekyll::TaggingFilters

Includes:
Helpers
Defined in:
lib/jekyll/tagging.rb

Instance Method Summary collapse

Methods included from Helpers

#jekyll_tagging_slug

Instance Method Details

#active_tag_data(site = Tagger.site) ⇒ Object



151
152
153
154
# File 'lib/jekyll/tagging.rb', line 151

def active_tag_data(site = Tagger.site)
  return site.config['tag_data'] unless site.config["ignored_tags"]
  site.config["tag_data"].reject { |tag, set| site.config["ignored_tags"].include? tag }
end

#keywords(obj) ⇒ Object



145
146
147
148
149
# File 'lib/jekyll/tagging.rb', line 145

def keywords(obj)
  return '' if not obj['tags']
  tags = obj['tags'].dup
  tags.join(',')
end

#tag_cloud(site) ⇒ Object



122
123
124
125
126
# File 'lib/jekyll/tagging.rb', line 122

def tag_cloud(site)
  active_tag_data.map { |tag, set|
    tag_link(tag, tag_url(tag), :class => "set-#{set}")
  }.join(' ')
end


128
129
130
131
# File 'lib/jekyll/tagging.rb', line 128

def tag_link(tag, url = tag_url(tag), html_opts = nil)
  html_opts &&= ' ' << html_opts.map { |k, v| %Q{#{k}="#{v}"} }.join(' ')
  %Q{<a href="#{url}"#{html_opts}>#{tag}</a>}
end

#tag_url(tag, type = :page, site = Tagger.site) ⇒ Object



133
134
135
136
# File 'lib/jekyll/tagging.rb', line 133

def tag_url(tag, type = :page, site = Tagger.site)
  url = File.join('', site.config["baseurl"].to_s, site.config["tag_#{type}_dir"], ERB::Util.u(jekyll_tagging_slug(tag)))
  site.permalink_style == :pretty || site.config['tag_permalink_style'] == 'pretty' ? url << '/' : url << '.html'
end

#tags(obj) ⇒ Object



138
139
140
141
142
143
# File 'lib/jekyll/tagging.rb', line 138

def tags(obj)
  tags = obj['tags'].dup
  tags.map! { |t| t.first } if tags.first.is_a?(Array)
  tags.map! { |t| tag_link(t, tag_url(t), :rel => 'tag') if t.is_a?(String) }.compact!
  tags.join(', ')
end