Merge commit 'b45fd6'

This commit is contained in:
Tom Preston-Werner 2008-12-24 11:46:44 -08:00
commit cdb0634ce8
5 changed files with 47 additions and 7 deletions

View File

@ -4,7 +4,6 @@
* Minor Enhancements
* Added post categories based on directories containing _posts [github.com/mreid]
* Added new date filter that shows the full month name [github.com/mreid]
* Make post's YAML front matter available as post.data [github.com/remi]
* Merge Post's YAML front matter into its to_liquid payload [github.com/remi]
* Restrict includes to regular files underneath _includes
* Bug Fixes

View File

@ -54,7 +54,12 @@ module Jekyll
entries = entries.reject { |e| File.directory?(e) }
entries.each do |f|
self.posts << Post.new(base, f) if Post.valid?(f)
if Post.valid?(f)
post = Post.new(base, f)
post.content = Liquid::Template.parse(post.content).render(site_payload, [Jekyll::Filters])
post.transform
self.posts << post
end
end
self.posts.sort!
@ -86,10 +91,15 @@ module Jekyll
(e != '_posts') and ['.', '_'].include?(e[0..0])
}
# we need to make sure to process _posts *first* otherwise they
# might not be available yet to other templates as {{ site.posts }}
if entries.include? '_posts'
entries.delete '_posts'
read_posts(File.join(base, '_posts'))
end
entries.each do |f|
if f == '_posts'
read_posts(File.join(base, f))
elsif File.directory?(File.join(base, f))
if File.directory?(File.join(base, f))
next if self.dest.sub(/\/$/, '') == File.join(base, f)
transform_pages(File.join(dir, f))
else

View File

@ -5,8 +5,18 @@ title: Tom Preston-Werner
h1. Welcome to my site
h2. Please read our {{ site.posts | size }} Posts
<ul>
{% for post in site.posts %}
<li>{{ post.date }} <a href="{{ post.url }}">{{ post.title }}</a></li>
{% endfor %}
</ul>
{% assign first_post = site.posts.first %}
<div id="first_post">
<h1>{{ first_post.title }}</h1>
<div>
{{ first_post.content }}
</div>
</div>

View File

@ -0,0 +1,21 @@
require File.dirname(__FILE__) + '/helper'
class TestGeneratedSite < Test::Unit::TestCase
def setup
clear_dest
source = File.join(File.dirname(__FILE__), *%w[source])
@s = Site.new(source, dest_dir)
@s.process
@index = File.read(File.join(dest_dir, 'index.html'))
end
def test_site_posts_in_index
# confirm that {{ site.posts }} is working
assert @index.include?("#{@s.posts.size} Posts")
end
def test_post_content_in_index
# confirm that the {{ post.content }} is rendered OK
assert @index.include?('<p>This <em>is</em> cool</p>')
end
end