diff --git a/README-AUTOPAGES.md b/README-AUTOPAGES.md index f64b175..75d1516 100644 --- a/README-AUTOPAGES.md +++ b/README-AUTOPAGES.md @@ -42,6 +42,8 @@ autopages: # Optional, the permalink for the pagination page (:cat is replaced), # the pagination permalink path is then appended to this permalink structure permalink: '/category/:cat' + # Optional, when true logging related to category pages will be supressed. + silent: false slugify: mode: 'default' # :cat is slugified. Modes: default, raw, pretty, ascii, latin case: false # Whether to replace all uppercase letters with their lowercase counterparts @@ -52,6 +54,7 @@ autopages: - 'autopage_collection.html' title: 'Posts in collection :coll' # :coll is replaced by the collection name permalink: '/collection/:coll' + silent: false slugify: mode: 'default' # :coll is slugified. case: false @@ -62,6 +65,7 @@ autopages: - 'autopage_tags.html' title: 'Posts tagged with :tag' # :tag is replaced by the tag name permalink: '/tag/:tag' + silent: false slugify: mode: 'default' # :tag is slugified. case: false diff --git a/lib/jekyll-paginate-v2/autopages/autoPages.rb b/lib/jekyll-paginate-v2/autopages/autoPages.rb index a6b7c84..e957302 100644 --- a/lib/jekyll-paginate-v2/autopages/autoPages.rb +++ b/lib/jekyll-paginate-v2/autopages/autoPages.rb @@ -16,6 +16,8 @@ def self.create_autopages(site) return end + autopages_log(autopage_config, 'tags', 'categories', 'collections') + # TODO: Should I detect here and disable if we're running the legacy paginate code???! # Simply gather all documents across all pages/posts/collections that we have @@ -55,8 +57,6 @@ def self.autopage_create(autopage_config, pagination_config, posts_to_use, confi if !autopage_config[configkey_name].nil? ap_sub_config = autopage_config[configkey_name] if ap_sub_config ['enabled'] - Jekyll.logger.info "AutoPages:","Generating #{configkey_name} pages" - # Roll through all documents in the posts collection and extract the tags index_keys = Utils.ap_index_posts_by(posts_to_use, indexkey_name) # Cannot use just the posts here, must use all things.. posts, collections... @@ -67,11 +67,31 @@ def self.autopage_create(autopage_config, pagination_config, posts_to_use, confi createpage_lambda.call(ap_sub_config, pagination_config, layout_name, index_key, value[-1]) # the last item in the value array will be the display name end end - else - Jekyll.logger.info "AutoPages:","#{configkey_name} pages are disabled/not configured in site.config." end end end + def self.autopages_log(config, *config_keys) + enabled, disabled = [], [] + config_keys.each do |key| + key_config = config[key] # config for key + next if config.nil? || key_config['silent'] + + (key_config['enabled'] ? enabled : disabled) << key + end + + Jekyll.logger.info("AutoPages:","Generating pages for #{_to_sentence(enabled)}") unless enabled.empty? + Jekyll.logger.info("AutoPages:","#{_to_sentence(disabled)} pages are disabled/not configured in site.config") unless disabled.empty? + end + + def self._to_sentence(array) + if array.empty? + "" + elsif array.length == 1 + array[0].to_s + else + array[0..-2].join(", ") + " & " + array.last + end + end end # module PaginateV2 end # module Jekyll