Class: JekyllFeed::MetaTag

Inherits:
Liquid::Tag
  • Object
show all
Includes:
Jekyll::Filters::URLFilters
Defined in:
lib/jekyll-feed/meta-tag.rb

Instance Method Summary collapse

Instance Method Details

#render(context) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/jekyll-feed/meta-tag.rb', line 8

def render(context)
  # Jekyll::Filters::URLFilters requires `@context` to be set in the environment.
  @context = context

  config = context.registers[:site].config
  path   = config.dig("feed", "path") || "feed.xml"
  title  = config["title"] || config["name"]

  attributes = {
    :type => "application/atom+xml",
    :rel  => "alternate",
    :href => absolute_url(path),
  }
  attributes[:title] = title if title

  attrs = attributes.map { |k, v| "#{k}=#{v.to_s.encode(:xml => :attr)}" }.join(" ")
  "<link #{attrs} />"
end