Class: Jekyll::TransformPost
- Inherits:
-
Post
- Object
- Post
- Jekyll::TransformPost
- Defined in:
- lib/jekyll-transform.rb
Instance Method Summary collapse
- #containing_dir(source, dir) ⇒ Object
- #path ⇒ Object
-
#read_yaml(base, name) ⇒ Object
Read the YAML frontmatter.
Instance Method Details
#containing_dir(source, dir) ⇒ Object
64 65 66 |
# File 'lib/jekyll-transform.rb', line 64 def containing_dir(source, dir) return File.join(source, dir) end |
#path ⇒ Object
60 61 62 |
# File 'lib/jekyll-transform.rb', line 60 def path self.data['path'] || File.join(@dir, @name).sub(/\A\//, '') end |
#read_yaml(base, name) ⇒ Object
Read the YAML frontmatter.
base - The String path to the dir containing the file. name - The String filename of the file.
Returns nothing.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/jekyll-transform.rb', line 38 def read_yaml(base, name) begin self.content = File.read(File.join(base, name)) config_data = (site.config['transform'] || {})['post_yaml'] || {} #{'layout'=>'default'} if self.content =~ /(<!---\s+---\s*\n.*?\n?)^(---\s*$\n?)/m self.content = $POSTMATCH self.data = config_data.merge(YAML.safe_load($1)) else self.data = config_data end rescue SyntaxError => e puts "YAML Exception reading #{File.join(base, name)}: #{e.}" rescue Exception => e puts "Error reading file #{File.join(base, name)}: #{e.}" end self.data ||= {'layout'=>'post'} self.extracted_excerpt = self.extract_excerpt end |