Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make tags and tag cloud separators configurable #65

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ If your Jekyll <tt>permalink</tt> configuration is set to something other than <

Sometimes you don't want tag pages generated for certain pages. That's ok! Just add <tt>ignored_tags: [tags,to,ignore]</tt> to your <tt>_config.yml</tt>

=== Custom separators

You can change the separators used by the <tt>tags</tt> and <tt>tag_cloud</tt> filters in <tt>_config.yml</tt>. The defaults are:

tag_separator: ', '
tag_cloud_separator: ' '

=== Extra data on tag pages

You can attach extra data to generated tag pages by specifying <tt>tag_page_data</tt> in <tt>_config.yml</tt> (this also works for <tt>tag_feed_data</tt>). For example, you might want to exclude tag pages from being picked up by `jekyll-sitemap`:
Expand Down
18 changes: 16 additions & 2 deletions lib/jekyll/tagging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,16 @@ module TaggingFilters
include Helpers

def tag_cloud(site)
separator =
if Tagger.site.config['tag_cloud_separator']
Tagger.site.config['tag_cloud_separator'].to_s
else
' '
end

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

def tag_link(tag, url = tag_url(tag), html_opts = nil)
Expand All @@ -136,10 +143,17 @@ def tag_url(tag, type = :page, site = Tagger.site)
end

def tags(obj)
separator =
if Tagger.site.config['tag_separator']
Tagger.site.config['tag_separator'].to_s
else
', '
end

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(', ')
tags.join(separator)
end

def keywords(obj)
Expand Down