module Jekyll::PaginateV2::AutoPages
def self.create_autopages(site)
This function is called right after the main generator is triggered by Jekyll
def self.create_autopages(site) # Get the configuration for the auto pages autopage_config = Jekyll::Utils.deep_merge_hashes(DEFAULT, site.config['autopages'] || {}) pagination_config = Jekyll::Utils.deep_merge_hashes(Jekyll::PaginateV2::Generator::DEFAULT, site.config['pagination'] || {}) # If disabled then don't do anything if !autopage_config['enabled'] || autopage_config['enabled'].nil? Jekyll.logger.info "AutoPages:","Disabled/Not configured in site.config." return end # 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 # we could be generating quite a few empty pages but the logic is just vastly simpler than trying to # figure out what tag/category belong to which collection. posts_to_use = Utils.collect_all_docs(site.collections) ############################################### # Generate the Tag pages if enabled createtagpage_lambda = lambda do | autopage_tag_config, pagination_config, layout_name, tag, tag_original_name | site.pages << TagAutoPage.new(site, site.dest, autopage_tag_config, pagination_config, layout_name, tag, tag_original_name) end autopage_create(autopage_config, pagination_config, posts_to_use, 'tags', 'tags', createtagpage_lambda) # Call the actual function ############################################### # Generate the category pages if enabled createcatpage_lambda = lambda do | autopage_cat_config, pagination_config, layout_name, category, category_original_name | site.pages << CategoryAutoPage.new(site, site.dest, autopage_cat_config, pagination_config, layout_name, category, category_original_name) end autopage_create(autopage_config, pagination_config,posts_to_use, 'categories', 'categories', createcatpage_lambda) # Call the actual function ############################################### # Generate the Collection pages if enabled createcolpage_lambda = lambda do | autopage_col_config, pagination_config, layout_name, coll_name, coll_original_name | site.pages << CollectionAutoPage.new(site, site.dest, autopage_col_config, pagination_config, layout_name, coll_name, coll_original_name) end autopage_create(autopage_config, pagination_config,posts_to_use, 'collections', '__coll', createcolpage_lambda) # Call the actual function end # create_autopages