http://tom.preston-werner.com/2008/11/17/blogging-like-a-hacker.html
.
-Categories for posts are derived from the directory structure the posts were
-found within.
-A post that appears in the directory foo/bar/_posts is placed in the categories
-'foo' and 'bar'.
-By selecting posts from particular categories in your Liquid templates, you will
-be able to host multiple blogs within a site.
+Categories for posts are derived from the directory structure the posts were
+found within. A post that appears in the directory foo/bar/_posts is placed in
+the categories 'foo' and 'bar'. By selecting posts from particular categories
+in your Liquid templates, you will be able to host multiple blogs within a
+site.
Files that do not reside in directories prefixed with an underscore are
mirrored into a corresponding directory structure in the generated site. If a
@@ -182,7 +181,7 @@ h3. Site
--lsi (latent semantic indexing) option.
site.categories.CATEGORY
- The list of all posts in category CATEGORY.
+ The list of all Posts in category CATEGORY.
h3. Post
@@ -200,12 +199,21 @@ h3. Post
An identifier unique to the Post (useful in RSS feeds).
e.g. /2008/12/14/my-post
+ post.categories
+ The list of categories to which this post belongs. Categories are
+ derived from the directory structure above the _posts directory. For
+ example, a post at /work/code/_posts/2008-12-24-closures.textile
+ would have this field set to ['work', 'code'].
+
+ post.topics
+ The list of topics for this Post. Topics are derived from the directory
+ structure beneath the _posts directory. For example, a post at
+ /_posts/music/metal/2008-12-24-metalocalypse.textile would have this field
+ set to ['music', 'metal'].
+
post.content
The content of the Post.
- post.categories
- The list of categories to which this post belongs.
-
h2. YAML Front Matter
Any files that contain a YAML front matter block will be processed by Jekyll
diff --git a/lib/jekyll/post.rb b/lib/jekyll/post.rb
index 76f3cf85..53bcbb22 100644
--- a/lib/jekyll/post.rb
+++ b/lib/jekyll/post.rb
@@ -8,7 +8,7 @@ module Jekyll
attr_accessor :lsi
end
- MATCHER = /^(\d+-\d+-\d+)-(.*)(\.[^.]+)$/
+ MATCHER = /^(.+\/)*(\d+-\d+-\d+)-(.*)(\.[^.]+)$/
# Post name validator. Post filenames must be like:
# 2008-11-05-my-awesome-post.textile
@@ -18,7 +18,7 @@ module Jekyll
name =~ MATCHER
end
- attr_accessor :date, :slug, :ext, :categories
+ attr_accessor :date, :slug, :ext, :categories, :topics
attr_accessor :data, :content, :output
# Initialize this Post instance.
@@ -27,15 +27,17 @@ module Jekyll
# +categories+ is an Array of Strings for the categories for this post
#
# Returns url: /test/source/2008/11/21/complex.html
\ndate: #{Time.parse("2008-11-21")}
\nid: /test/source/2008/11/21/complex
url: /2008/11/21/complex.html
\ndate: #{Time.parse("2008-11-21")}
\nid: /2008/11/21/complex