refactor
parent
5555ecb943
commit
a7069debfb
|
@ -2,8 +2,7 @@
|
|||
|
||||
<!-- find category index -->
|
||||
|
||||
<% cat_match = %r{^/#{@category}/}
|
||||
cat_index = @site.printed_items.find{|i| i.path.match(cat_match) and i[:is_category]} %>
|
||||
<% cat_index = @site.printed_items.find{|i| i.is_category? @category and i[:is_category]} %>
|
||||
|
||||
<!-- header -->
|
||||
|
||||
|
@ -12,7 +11,7 @@ cat_index = @site.printed_items.find{|i| i.path.match(cat_match) and i[:is_categ
|
|||
<!-- find items in category -->
|
||||
|
||||
<% items = @site.printed_items.select do |i|
|
||||
i.path.match cat_match and
|
||||
i.is_category? @category and
|
||||
not i[:is_category] and
|
||||
not i.draft? # hide drafts, but make them reachable
|
||||
end %>
|
||||
|
|
|
@ -26,6 +26,10 @@ class Nanoc3::Item
|
|||
def article?
|
||||
not self[:is_category] and not draft? and cognitive?
|
||||
end
|
||||
|
||||
def is_category? category
|
||||
!!path.match(%r{^/#{category}/})
|
||||
end
|
||||
end
|
||||
|
||||
class Nanoc3::Site
|
||||
|
|
|
@ -35,6 +35,6 @@ class Nanoc3::Item
|
|||
|
||||
def mindkiller?
|
||||
topics = %w{history}
|
||||
!!self[:mindkiller] || !!path.match(%r{^/(#{topics.join("|")})/})
|
||||
!!self[:mindkiller] || !!topics.select{|t| is_category? t}
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue