From e8c74fe7a89c3b53c15e7ec10e80d0abbe2158d1 Mon Sep 17 00:00:00 2001 From: 7rans Date: Sat, 12 Jan 2013 13:48:44 -0800 Subject: [PATCH] Layouts default to page or post depending upon type. --- lib/jekyll/page.rb | 12 ++++++++++++ lib/jekyll/post.rb | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/lib/jekyll/page.rb b/lib/jekyll/page.rb index 82b82048..d3461181 100644 --- a/lib/jekyll/page.rb +++ b/lib/jekyll/page.rb @@ -24,6 +24,18 @@ module Jekyll self.read_yaml(File.join(base, dir), name) end + # Read the YAML frontmatter. + # + # base - The String path to the dir containing the file. + # name - The String filename of the file. + # + # Returns nothing. + def read_yaml(base, name) + super(base, name) + self.data['layout'] ||= 'page' + self.data + end + # The generated directory into which the page will be placed # upon generation. This is derived from the permalink or, if # permalink is absent, we be '/' diff --git a/lib/jekyll/post.rb b/lib/jekyll/post.rb index a360cb8d..6156b5be 100644 --- a/lib/jekyll/post.rb +++ b/lib/jekyll/post.rb @@ -66,6 +66,18 @@ module Jekyll end end + # Read the YAML frontmatter. + # + # base - The String path to the dir containing the file. + # name - The String filename of the file. + # + # Returns nothing. + def read_yaml(base, name) + super(base, name) + self.data['layout'] ||= 'post' + self.data + end + # Compares Post objects. First compares the Post date. If the dates are # equal, it compares the Post slugs. #