Sha256: dbf3e38c231594791c9b350d33ec80142bbf484c70e933b65412d980d282bf24
Contents?: true
Size: 1.45 KB
Versions: 1
Compression:
Stored size: 1.45 KB
Contents
require 'jekyll' require 'liquid' module JekyllThemeGuidesMbland class ShouldExpandNavTag < ::Liquid::Tag NAME = 'jekyll_theme_guides_mbland_should_expand_nav'.freeze ::Liquid::Template.register_tag(NAME, self) attr_reader :parent_reference, :url_reference def initialize(_tag_name, markup, _tokens) references = markup.split(',').map(&:strip) @parent_reference = references.shift @url_reference = references.shift end def render(context) scope = context.scopes.detect { |s| s.member?(url_reference) } parent_url = scope[url_reference] page_url = context['page']['url'] page_url == parent_url || page_url.start_with?(parent_url) || expand_nav_default(scope, context) end private def expand_nav_default(scope, context) default = scope[parent_reference]['expand_nav'] default = context['site']['expand_nav'] if default.nil? default.nil? ? false : default end end class PopLastUrlComponent < ::Liquid::Tag NAME = 'jekyll_theme_guides_mbland_pop_last_url_component'.freeze ::Liquid::Template.register_tag(NAME, self) attr_reader :reference def initialize(_tag_name, markup, _tokens) @reference = markup.strip end def render(context) scope = context.scopes.detect { |s| s.member?(reference) } parent_url = scope[reference] result = File.dirname(parent_url) result == '/' ? result : "#{result}/" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
jekyll-theme-guides-mbland-1.0.5 | lib/jekyll-theme-guides-mbland/tags.rb |