Fix #470.
This commit is contained in:
@@ -5,6 +5,11 @@ module Precious
|
|||||||
class Pages < Layout
|
class Pages < Layout
|
||||||
attr_reader :results, :ref
|
attr_reader :results, :ref
|
||||||
|
|
||||||
|
def prefix
|
||||||
|
return '/' if @base_url.nil?
|
||||||
|
@base_url.chomp('/').empty? ? '/' : @base_url + '/'
|
||||||
|
end
|
||||||
|
|
||||||
def title
|
def title
|
||||||
"All pages in #{@ref}"
|
"All pages in #{@ref}"
|
||||||
end
|
end
|
||||||
@@ -12,14 +17,14 @@ module Precious
|
|||||||
def breadcrumb
|
def breadcrumb
|
||||||
if @path
|
if @path
|
||||||
path = Pathname.new(@path)
|
path = Pathname.new(@path)
|
||||||
breadcrumb = [%{<a href="#{@base_url}pages/">Home</a>}]
|
breadcrumb = [%{<a href="#{prefix}pages/">Home</a>}]
|
||||||
path.descend do |crumb|
|
path.descend do |crumb|
|
||||||
title = crumb.basename
|
title = crumb.basename
|
||||||
|
|
||||||
if title == path.basename
|
if title == path.basename
|
||||||
breadcrumb << title
|
breadcrumb << title
|
||||||
else
|
else
|
||||||
breadcrumb << %{<a href="#{@base_url}pages/#{crumb}/">#{title}</a>}
|
breadcrumb << %{<a href="#{prefix}pages/#{crumb}/">#{title}</a>}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -39,7 +44,7 @@ module Precious
|
|||||||
if page_path.include?('/')
|
if page_path.include?('/')
|
||||||
folder = page_path.split('/').first
|
folder = page_path.split('/').first
|
||||||
folder_path = @path ? "#{@path}/#{folder}" : folder
|
folder_path = @path ? "#{@path}/#{folder}" : folder
|
||||||
folder_link = %{<li><a href="#{@base_url}pages/#{folder_path}/" class="folder">#{folder}</a></li>}
|
folder_link = %{<li><a href="#{prefix}pages/#{folder_path}/" class="folder">#{folder}</a></li>}
|
||||||
|
|
||||||
unless folder_links.include?(folder_link)
|
unless folder_links.include?(folder_link)
|
||||||
folder_links << folder_link
|
folder_links << folder_link
|
||||||
@@ -47,7 +52,7 @@ module Precious
|
|||||||
folder_link
|
folder_link
|
||||||
end
|
end
|
||||||
elsif page_path != ".gitkeep"
|
elsif page_path != ".gitkeep"
|
||||||
%{<li><a href="#{@base_url}#{page.escaped_url_path}" class="file">#{page.name}</a></li>}
|
%{<li><a href="#{prefix}#{page.escaped_url_path}" class="file">#{page.name}</a></li>}
|
||||||
end
|
end
|
||||||
}.compact.join("\n")
|
}.compact.join("\n")
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user