@@ -9,6 +9,7 @@ class Archives < Jekyll::Generator
99
1010 DEFAULTS = {
1111 'layout' => 'archive' ,
12+ 'enabled' => [ ] ,
1213 'permalinks' => {
1314 'year' => '/:year/' ,
1415 'month' => '/:year/:month/' ,
@@ -46,23 +47,46 @@ def generate(site)
4647
4748 # Read archive data from posts
4849 def read
49- tags . each do |name , posts |
50- @archives << Archive . new ( @site , name , "tag" , posts )
50+ read_tags
51+ read_categories
52+ read_dates
53+ end
54+
55+ def read_tags
56+ if enabled? "tags"
57+ tags . each do |name , posts |
58+ @archives << Archive . new ( @site , name , "tag" , posts )
59+ end
5160 end
52- categories . each do |name , posts |
53- @archives << Archive . new ( @site , name , "category" , posts )
61+ end
62+
63+ def read_categories
64+ if enabled? "categories"
65+ categories . each do |name , posts |
66+ @archives << Archive . new ( @site , name , "category" , posts )
67+ end
5468 end
69+ end
70+
71+ def read_dates
5572 years . each do |year , posts |
56- @archives << Archive . new ( @site , { :year => year } , "year" , posts )
73+ @archives << Archive . new ( @site , { :year => year } , "year" , posts ) if enabled? "year"
5774 months ( posts ) . each do |month , posts |
58- @archives << Archive . new ( @site , { :year => year , :month => month } , "month" , posts )
75+ @archives << Archive . new ( @site , { :year => year , :month => month } , "month" , posts ) if enabled? "month"
5976 days ( posts ) . each do |day , posts |
60- @archives << Archive . new ( @site , { :year => year , :month => month , :day => day } , "day" , posts )
77+ @archives << Archive . new ( @site , { :year => year , :month => month , :day => day } , "day" , posts ) if enabled? "day"
6178 end
6279 end
6380 end
6481 end
6582
83+ # Checks if archive type is enabled in config
84+ def enabled? ( archive )
85+ @config [ "enabled" ] == true || @config [ "enabled" ] == "all" || if @config [ "enabled" ] . is_a? Array
86+ @config [ "enabled" ] . include? archive
87+ end
88+ end
89+
6690 # Renders the archives into the layouts
6791 def render
6892 payload = @site . site_payload
0 commit comments