Class: JekyllBlocker::Utilities

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll-blocker/utilities.rb

Class Method Summary collapse

Class Method Details

.read_jekyll_file(path) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/jekyll-blocker/utilities.rb', line 4

def read_jekyll_file(path)
  out = { data: {}, content: File.read(path) }

  if out[:content] =~ Jekyll::Document::YAML_FRONT_MATTER_REGEXP
    out[:content] = Regexp.last_match.post_match
    out[:data] = YAML.safe_load(Regexp.last_match(1))
  end

  out
end