Class: J1Feed::MetaTag

Inherits:
Liquid::Tag
  • Object
show all
Includes:
Jekyll::Filters::URLFilters
Defined in:
lib/starter_web/_plugins/seo/j1-feed.rb

Instance Method Summary collapse

Instance Method Details

#render(context) ⇒ Object



247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
# File 'lib/starter_web/_plugins/seo/j1-feed.rb', line 247

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