Sha256: a4a857603b6668893c199bac1c3525e46305532a6aec13c6ab8049303ede4af3

Contents?: true

Size: 768 Bytes

Versions: 4

Compression:

Stored size: 768 Bytes

Contents

# frozen_string_literal: true

module JekyllFeed
  class MetaTag < Liquid::Tag
    # Use Jekyll's native relative_url filter
    include Jekyll::Filters::URLFilters

    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
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
jekyll-atom-feed-0.19.0 lib/jekyll-atom-feed/meta-tag.rb
jekyll-atom-feed-0.18.0 lib/jekyll-atom-feed/meta-tag.rb
jekyll-feed-0.17.0 lib/jekyll-feed/meta-tag.rb
jekyll-feed-0.16.0 lib/jekyll-feed/meta-tag.rb