Sha256: 73b55f0e921ea1ebc42b0f0b075f96039d59e9401e33af552fc96c7d17830c22

Contents?: true

Size: 748 Bytes

Versions: 5

Compression:

Stored size: 748 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
      @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
      config.dig("feed", "path") || "feed.xml"
    end

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

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
rams-jekyll-feed-0.13.0 lib/jekyll-feed/meta-tag.rb
jekyll-feed-0.13.0 lib/jekyll-feed/meta-tag.rb
jekyll-feed-0.12.1 lib/jekyll-feed/meta-tag.rb
jekyll-feed-0.12.0 lib/jekyll-feed/meta-tag.rb
jekyll-feed-0.11.0 lib/jekyll-feed/meta-tag.rb