Class: Jekyll::Gallery::SeoImage

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll/gallery/seo.rb

Overview

Expand the image:cover paths to accomplish the Jekyll-Gallery filesystem standards and return a path compatible with the Jekyll-Seo-Tag plugin.

Class Method Summary collapse

Class Method Details

.setupObject



11
12
13
14
15
16
17
18
# File 'lib/jekyll/gallery/seo.rb', line 11

def self.setup
  Jekyll::Hooks.register :documents, :pre_render do |document|
    image = document["image"]
    collection = document.type

    update_frontmatter(image, collection)
  end
end

.update_frontmatter(image, collection) ⇒ Object

Raises:



20
21
22
23
24
25
26
27
28
# File 'lib/jekyll/gallery/seo.rb', line 20

def self.update_frontmatter(image, collection)
  return unless image.is_a? Hash
  return if image["cover"].nil?

  file = Helper.expand_local_file(image["cover"], collection)
  raise MissingFile, file unless File.exist?(file)

  image["path"] = Helper.expand_remote_file(image["cover"], collection)
end