Created
February 11, 2016 21:33
-
-
Save jplitza/05f324afc43091df3836 to your computer and use it in GitHub Desktop.
Gollum better Global ToC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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