Class: Wytch::ContentLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/wytch/content_loader.rb

Overview

Discovers and loads content files into Page objects.

The ContentLoader scans the content directory for Ruby files and instantiates Page objects for each one. It uses the configured page_class from the Site.

Instance Method Summary collapse

Instance Method Details

#load_contentHash{String => Page}

Loads all content files and returns a hash of pages.

Scans the content directory recursively for .rb files, creates a Page instance for each, and returns them keyed by path.

Returns:

  • (Hash{String => Page})

    pages keyed by their URL path



19
20
21
22
23
24
25
26
27
28
# File 'lib/wytch/content_loader.rb', line 19

def load_content
  pages = {}

  Dir.glob(File.join("**", "*.rb"), base: content_dir).each do |file_path|
    page = load_page(file_path)
    pages[page.path] = page
  end

  pages
end