Sha256: 33ca0b3ff53a3d7cefbb2cef8e3b013137fcd38cc7df334ae2c3ac6fe9ad0ad2
Contents?: true
Size: 1.1 KB
Versions: 1
Compression:
Stored size: 1.1 KB
Contents
# frozen_string_literal: true module Jekyll module Tags class Link < Liquid::Tag class << self def tag_name name.split("::").last.downcase end end def initialize(tag_name, relative_path, tokens) super @relative_path = relative_path.strip end def render(context) site = context.registers[:site] liquid = site.liquid_renderer.file("(jekyll:link)") relative_path = liquid.parse(@relative_path).render(context) site.each_site_file do |item| return item.url if item.relative_path == relative_path # This takes care of the case for static files that have a leading / return item.url if item.relative_path == "/#{relative_path}" end raise ArgumentError, <<~MSG Could not find document '#{relative_path}' in tag '#{self.class.tag_name}'. Make sure the document exists and the path is correct. MSG end end end end Liquid::Template.register_tag(Jekyll::Tags::Link.tag_name, Jekyll::Tags::Link)
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ngage-0.0.0 | lib/ngage/jekyll/tags/link.rb |