Sha256: db3c72fba629cd27b962ffff99d55a5129c316d6b24b96a7ddfcd11963aaa0c1

Contents?: true

Size: 810 Bytes

Versions: 2

Compression:

Stored size: 810 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)
      @context = context
      attrs    = attributes.map { |k, v| %(#{k}="#{v}") }.join(" ")
      "<link #{attrs} />"
    end

    private

    def config
      @context.registers[:site].config
    end

    def attributes
      {
        :type  => "application/atom+xml",
        :rel   => "alternate",
        :href  => absolute_url(path),
        :title => title,
      }.keep_if { |_, v| v }
    end

    def path
      if config["feed"] && config["feed"]["path"]
        config["feed"]["path"]
      else
        "feed.xml"
      end
    end

    def title
      config["title"] || config["name"]
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jekyll-feed-0.10.0 lib/jekyll-feed/meta-tag.rb
jekyll-feed-0.9.3 lib/jekyll-feed/meta-tag.rb