Sha256: 2fc28a4afb4905e3c4c5b8c385e309c6c607127d92a0e305ae4fa2edc2f018e1
Contents?: true
Size: 1.05 KB
Versions: 55
Compression:
Stored size: 1.05 KB
Contents
require 'webgen/tag' class PrevNextTag include Webgen::Tag::Base def call(tag, body, context) node = context.content_node while !node.is_file? node = node.parent end siblings = node.parent.children.sort siblings.delete_if { |n| !n.meta_info['in_menu'] } prev, _ = siblings. enum_for(:each_cons, 2). find { |prev, this| this == node } _, nxt = siblings. enum_for(:each_cons, 2). find { |this, nxt| this == node } content = if tag == "next" && nxt node.link_to(nxt) elsif tag == "previous" && prev node.link_to(prev) end if content if !body.empty? body.gsub '%', content else content end end end end config = Webgen::WebsiteAccess.website.config config['contentprocessor.tags.map']['previous'] = 'PrevNextTag' config['contentprocessor.tags.map']['next'] = 'PrevNextTag'
Version data entries
55 entries across 55 versions & 2 rubygems