Module: Jekyll::PaginateV2::AutoPages

Defined in:
lib/jekyll-paginate-v2-redux/autopages/utils.rb,
lib/jekyll-paginate-v2-redux/autopages/defaults.rb,
lib/jekyll-paginate-v2-redux/autopages/autoPages.rb,
lib/jekyll-paginate-v2-redux/autopages/pages/tagAutoPage.rb,
lib/jekyll-paginate-v2-redux/autopages/pages/baseAutoPage.rb,
lib/jekyll-paginate-v2-redux/autopages/pages/categoryAutoPage.rb,
lib/jekyll-paginate-v2-redux/autopages/pages/collectionAutoPage.rb

Defined Under Namespace

Classes: BaseAutoPage, CategoryAutoPage, CollectionAutoPage, TagAutoPage, Utils

Constant Summary collapse

DEFAULT =

The default configuration for the AutoPages

{
  'enabled'     => false,
  'tags'        => {
    'layouts'       => ['autopage_tags.html'],
    'title'         => 'Posts tagged with :tag',
    'permalink'     => '/tag/:tag',
    'enabled'       => true

  },
  'categories'  => {
    'layouts'       => ['autopage_category.html'],
    'title'         => 'Posts in category :cat',
    'permalink'     => '/category/:cat',
    'enabled'       => true
  },
  'collections' => {
    'layouts'       => ['autopage_collection.html'],
    'title'         => 'Posts in collection :coll',
    'permalink'     => '/collection/:coll',
    'enabled'       => true
  } 
}

Class Method Summary collapse

Class Method Details

.autopage_create(autopage_config, pagination_config, posts_to_use, configkey_name, indexkey_name, createpage_lambda) ⇒ Object

STATIC: this function actually performs the steps to generate the autopages. It uses a lambda function to delegate the creation of the individual

page types to the calling code (this way all features can reuse the logic).


54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/jekyll-paginate-v2-redux/autopages/autoPages.rb', line 54

def self.autopage_create(autopage_config, pagination_config, posts_to_use, configkey_name, indexkey_name, createpage_lambda )
  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...

      index_keys.each do |index_key, value|
        # Iterate over each layout specified in the config
        ap_sub_config ['layouts'].each do | layout_name |
          # Use site.dest here as these pages are never created in the actual source but only inside the _site folder
          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