Sha256: 2164a03de49753ac946b4538c26a74c01276ebae139643c558bed2c17a46e09b

Contents?: true

Size: 779 Bytes

Versions: 3

Compression:

Stored size: 779 Bytes

Contents

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

3 entries across 3 versions & 1 rubygems

Version Path
jekyll-feed-0.9.2 lib/jekyll-feed/meta-tag.rb
jekyll-feed-0.9.1 lib/jekyll-feed/meta-tag.rb
jekyll-feed-0.9.0 lib/jekyll-feed/meta-tag.rb