Class: JekyllDynamicAssets::Processor

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll_dynamic_assets/processor.rb

Overview

Asset link generator

Instance Method Summary collapse

Constructor Details

#initialize(site:, page:) ⇒ Processor

Returns a new instance of Processor.



6
7
8
9
10
11
12
13
# File 'lib/jekyll_dynamic_assets/processor.rb', line 6

def initialize(site:, page:)
  @config = site.config["dynamic_assets"] || {}
  @page = page
  @page_config = page["dynamic_assets"] || {}
  @path = @page["path"] || @page["relative_path"] || "unknown"

  sub_configs(site:)
end

Instance Method Details

#assetsObject

Get all link tags to assets for this page



16
17
18
19
20
21
22
23
24
25
# File 'lib/jekyll_dynamic_assets/processor.rb', line 16

def assets
  all_assets = combined_assets
  asset_insertions = []
  all_assets.each do |dir, asset, format_string|
    directory = dir.start_with?("http") ? dir : prepare_dir(dir)
    asset_link = directory + asset
    asset_insertions << format_string % asset_link
  end
  asset_insertions
end