Class: Jekyll::Plugins::PaginateV3::Pagination::Model
- Inherits:
-
Object
- Object
- Jekyll::Plugins::PaginateV3::Pagination::Model
- Defined in:
- lib/jekyll-paginate-v3/pagination/model/core.rb,
lib/jekyll-paginate-v3/pagination/model/pagination_pipeline.rb,
lib/jekyll-paginate-v3/pagination/model/group_navigation_and_pages.rb
Overview
Group navigation and generated-page metadata helpers for Model.
Structure: grouped index sets are ordered, converted into paginator
payloads, and then applied to every generated pagination page.
Instance Method Summary collapse
-
#initialize(site:, site_config:, log_lambda:, scoped_log_lambda_builder:, add_item_lambda:, remove_item_lambda:) ⇒ Model
constructor
A new instance of Model.
-
#run ⇒ Object
Runs the full pagination pipeline for the current site build.
Constructor Details
#initialize(site:, site_config:, log_lambda:, scoped_log_lambda_builder:, add_item_lambda:, remove_item_lambda:) ⇒ Model
Returns a new instance of Model.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/jekyll-paginate-v3/pagination/model/core.rb', line 20 def initialize(site:, site_config:, log_lambda:, scoped_log_lambda_builder:, add_item_lambda:, remove_item_lambda:) @site = site @site_config = site_config @log_lambda = log_lambda @active_log_lambda = log_lambda @scoped_log_lambda_builder = scoped_log_lambda_builder @add_item_lambda = add_item_lambda @remove_item_lambda = remove_item_lambda @nested_separator = site_config.dig('syntax', 'separator') @split_delimiter = site_config.dig('syntax', 'split') @equivalents = site_config['equivalents'] @item_keyword = site_config.dig('keywords', 'items') || Config::KEYWORD_DEFAULTS.fetch('items') @generated_index_sets = {} @clone_collection_cache = {} @template_search_reports = [] @template_search_report_lookup = {} @template_search_duration_seconds = 0.0 @item_resolution_pages = nil @item_resolution_documents_by_collection = nil end |
Instance Method Details
#run ⇒ Object
Runs the full pagination pipeline for the current site build.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/jekyll-paginate-v3/pagination/model/core.rb', line 42 def run log("Pagination pipeline start: compatibility=#{@site_config['compatibility'] || 'none'} templates.location=#{@site_config.dig('templates', 'location')} generate.count=#{@site_config.dig('templates', 'generate')&.length || 0}", 'debug') generated_template_report = build_generated_templates generated_template_count = generated_template_report['total'].to_i log("Generated #{generated_template_count} template(s).", 'debug') capture_item_resolution_sources! search_started_at = monotonic_seconds templates = discover_templates @template_search_duration_seconds = monotonic_seconds - search_started_at if templates.empty? log('Enabled, but no pagination templates were discovered.', 'warn') return build_run_report(processed_templates: 0, generated_template_report: generated_template_report) end log("Discovered #{templates.length} pagination template(s).", 'debug') enabled_templates = [] disabled_templates = 0 templates.each do |template| next unless template.data['pagination'].is_a?(Hash) template_pagination_source = Utils.safe_hash(template.data['pagination']) template_pagination = merged_template_pagination_config(template, template_pagination_source) template_config = Config::Normaliser.normalise_template_config(@site_config, template_pagination) template_log_lambda = scoped_log_lambda(template_config['debug']) unless template_config['enabled'] disabled_templates += 1 with_log_lambda(template_log_lambda) do log("Skipping template '#{Utils.relative_item_path(template)}' because merged `pagination.enabled` is false.", 'debug') end next end validate_required_template_config!(template, template_config) enabled_templates << [template, template_config, template_pagination_source, template_log_lambda] end if enabled_templates.empty? log('Discovered pagination templates, but all resolved to `pagination.enabled: false` after config merge.', 'warn') return build_run_report(processed_templates: 0, generated_template_report: generated_template_report) end processed = 0 enabled_templates.each do |template, template_config, template_pagination_source, template_log_lambda| with_log_lambda(template_log_lambda) do log("Paginating template '#{Utils.relative_item_path(template)}' with items=#{template_config['items']} filters=#{template_config['filters']}.", 'debug') begin template_pagination_report = paginate_template(template, template_config, template_pagination_source) record_template_search_report_totals(template, template_pagination_report) rescue StandardError => error log("Template '#{Utils.relative_item_path(template)}' failed: #{error.class}: #{error.}", 'error') raise end end processed += 1 end log("Skipped #{disabled_templates} discovered template(s) because merged `pagination.enabled` is false.", 'debug') if disabled_templates.positive? log("Pagination pipeline complete: processed #{processed} template(s).", 'debug') build_run_report(processed_templates: processed, generated_template_report: generated_template_report) end |