Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reduce the verbosity of pagination logging [again] #180

Merged
merged 4 commits into from
May 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README-AUTOPAGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
28 changes: 24 additions & 4 deletions lib/jekyll-paginate-v2/autopages/autoPages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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...

Expand All @@ -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