Skip to content

Instantly share code, notes, and snippets.

@jplitza
Created February 11, 2016 21:33
Show Gist options
  • Save jplitza/05f324afc43091df3836 to your computer and use it in GitHub Desktop.
Save jplitza/05f324afc43091df3836 to your computer and use it in GitHub Desktop.
Gollum better Global ToC
module Gollum
class Macro
class GlobalTOC < Gollum::Macro
def render(title = "Global Table of Contents")
pages = @wiki.pages.sort do |a,b|
if a.path.include?('/') and b.path.include?('/') then
a.path <=> b.path
elsif a.path.include?('/') then
1
elsif b.path.include?('/') then
-1
else
a.path <=> b.path
end
end
Gollum::FileView.new(pages, {:collapse_tree => true}).render_files.gsub('href="', 'href="/')
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment