Class: Jekyll::Authors::AuthorUrlTag
- Inherits:
-
Liquid::Tag
- Object
- Liquid::Tag
- Jekyll::Authors::AuthorUrlTag
- Defined in:
- lib/jekyll-authors.rb
Overview
Returns a correctly formatted author url based on site configuration.
Use without arguments to return the url of the author list page.
{% author_url %}
Use with argument to return the url of a specific catogory page. The argument can be either a string or a variable in the current context.
{% author_url author_name %}
{% author_url author_var %}
Instance Method Summary collapse
-
#initialize(tag_name, text, tokens) ⇒ AuthorUrlTag
constructor
A new instance of AuthorUrlTag.
- #render(context) ⇒ Object
Constructor Details
#initialize(tag_name, text, tokens) ⇒ AuthorUrlTag
Returns a new instance of AuthorUrlTag.
132 133 134 135 |
# File 'lib/jekyll-authors.rb', line 132 def initialize(tag_name, text, tokens) super @author = text end |
Instance Method Details
#render(context) ⇒ Object
137 138 139 140 141 142 143 |
# File 'lib/jekyll-authors.rb', line 137 def render(context) base_url = context.registers[:site].config['base-url'] || '/' = context.registers[:site].config['author_dir'] || 'authors' = context[@author] || @author.strip.tr(' ', '-').downcase .empty? ? "#{base_url}#{}" : "#{base_url}#{}/#{}" end |