30 lines
798 B
Ruby
30 lines
798 B
Ruby
module Jekyll
|
|
|
|
class NavTree < Liquid::Tag
|
|
def initialize(tag_name, text, tokens)
|
|
super
|
|
end
|
|
|
|
def render(context)
|
|
site = context.registers[:site]
|
|
output = '<ul>'
|
|
temp = site.pages.sort do |x,y|
|
|
unless defined? y.data['order'] then y.data['order'] = 0 end
|
|
unless defined? x.data['order'] then x.data['order'] = 0 end
|
|
y.data['order'].to_i <=> x.data['order'].to_i
|
|
end
|
|
temp.each do |page|
|
|
if page.data['title'].nil? or page.data['shownav'] == false then next end
|
|
output += '<li><a href="'+page.url+'">'+page.data['title']+'</a></li>'
|
|
output += '<img src="/images/separator.png">'
|
|
end
|
|
output += '</ul>'
|
|
|
|
output
|
|
end
|
|
end
|
|
|
|
end
|
|
|
|
Liquid::Template.register_tag('nav_tree', Jekyll::NavTree)
|