Class: BridgetownFeed::Generator

Inherits:
Bridgetown::Generator
  • Object
show all
Defined in:
lib/bridgetown-feed/generator.rb

Constant Summary collapse

MINIFY_REGEX =

Matches all whitespace that follows

1. A '>', which closes an XML tag or
2. A '}', which closes a Liquid tag

We will strip all of this whitespace to minify the template

%r!(?<=>|})\s+!.freeze

Instance Method Summary collapse

Instance Method Details

#generate(site) ⇒ Object

Main plugin action, called by Bridgetown-core



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/bridgetown-feed/generator.rb', line 14

def generate(site)
  @site = site
  collections.each do |name, meta|
    Bridgetown.logger.info "Bridgetown Feed:", "Generating feed for #{name}"
    (meta["categories"] + [nil]).each do |category|
      path = feed_path(collection: name, category: category)
      next if file_exists?(path)

      @site.generated_pages << make_page(path, collection: name, category: category)
    end
  end
end