Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Layouts default to page or post. #580

Closed
wants to merge 1 commit into from

5 participants

@trans

This patch defaults layout for pages and posts to page and post respectively. In many cases (I suspect the vast majority) this is a perfect setup. And one need not worry about putting a layout entry in each markup file. This is especially useful to me using a Gollum wiki as the source of my posts b/c I can't add YAML front matter. So having default layouts makes all the difference.

This patch shouldn't have any adverse effect on previous designs since layout was effectively a mandatory field before.

@trans

Ping.

@agarie

Seems useful, but it must be documented somewhere. Just a reminder :)

@trans

Good point. I'd be happy to document in the wiki. Just guide me to the proper place to to do so.

@agarie

Well, you should put this in the documentation of the config parameters. Also, don't forget the tests, your patch probably won't get accepted without them.

@ixti

Don't forget the tests :D

@kevinSuttle

Great idea. +1

@parkr
Owner

@trans Please make these edits on the current master - you can update the docs now that they're in the same branch. And don't forget tests! :smiley:

@parkr
Owner

Closing this pull request in favour of one submitted on the current master, with docs changes and tests added.

@parkr parkr closed this
@trans

Hi, Sorry I am a bit confused. Did someone else submit this? Or are you still asking me to submit a new one?

@parkr
Owner

No, I meant one that has yet to be submitted -- by you :)

@parkr
Owner

Merged in e8c74fe, adding tests & docs now.

@parkr parkr referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 17, 2012
  1. @trans

    Layouts default to page or post.

    trans authored
This page is out of date. Refresh to see the latest.
Showing with 24 additions and 0 deletions.
  1. +12 −0 lib/jekyll/page.rb
  2. +12 −0 lib/jekyll/post.rb
View
12 lib/jekyll/page.rb
@@ -24,6 +24,18 @@ def initialize(site, base, dir, name)
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 '/'
View
12 lib/jekyll/post.rb
@@ -60,6 +60,18 @@ def initialize(site, source, dir, name)
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
+
# Spaceship is based on Post#date, slug
#
# Returns -1, 0, 1
Something went wrong with that request. Please try again.