Permalink
Browse files

Added a 'handsome' permalink option for /YYYY/mm/post-slug/ URLs

modfied the /lib/jekyll/post.rb to include an otpion for "handsome"
post slugs to omit the date of a post from the URL if the site is
compiled with this option.

Also amended the documentation to reflect this change.
  • Loading branch information...
1 parent b85eb4a commit 9ccb01434f33ff5f577990c518e9ccc7089d5336 @tychoish committed Apr 5, 2009
Showing with 14 additions and 4 deletions.
  1. +4 −2 README.textile
  2. +10 −2 lib/jekyll/post.rb
View
@@ -170,9 +170,11 @@ read from the filename (and is required!) to be used elsewhere in Jekyll.
If you want WordPress-style pretty URLs that leave off the .html, you can
change the permalink style to 'pretty' and directories corresponding to the
date parts and post name will be made and an index.html will be placed in the
-leaf directory resulting in URLs like 2008/11/17/blogging-like-a-hacker/.
+leaf directory resulting in URLs like 2008/11/17/blogging-like-a-hacker/. If
+you prefer to leave off the day from the permalink (eg.
+2008/11/blogging-like-a-hacker/), you can change the option to 'handsome.'
- $ jekyll --permalink [date|none|pretty]
+ $ jekyll --permalink [date|none|pretty|handsome]
h2. Configuration File
View
@@ -86,6 +86,8 @@ def process(name)
# permalink is absent, set to the default date
# e.g. "/2008/11/05/" if the permalink style is :date, otherwise nothing
#
+ # If the permalink is set to handsome, a differet date string is generated.
+ #
# Returns <String>
def dir
if permalink
@@ -94,6 +96,8 @@ def dir
prefix = self.categories.empty? ? '' : '/' + self.categories.join('/')
if [:date, :pretty].include?(self.site.permalink_style)
prefix + date.strftime("/%Y/%m/%d/")
+ elsif [:date, :handsome].include?(self.site.permalink_style)
+ prefix + date.strftime("/%Y/%m/")
else
prefix + '/'
end
@@ -114,7 +118,11 @@ def permalink
#
# Returns <String>
def url
- ext = self.site.permalink_style == :pretty ? '' : '.html'
+ if self.site.permalink_style == :pretty or :handsome
+ ext = ''
+ else
+ ext = '.html'
+ end
permalink || self.id + ext
end
@@ -174,7 +182,7 @@ def write(dest)
path = File.join(dest, self.url)
- if self.site.permalink_style == :pretty
+ if self.site.permalink_style == :pretty or :handsome
FileUtils.mkdir_p(path)
path = File.join(path, "index.html")
end

1 comment on commit 9ccb014

henrik commented on 9ccb014 Apr 13, 2009

Broken code. Try this and see:

p (nil == :bar or :baz)
p (:bar == :bar or :baz)
p (:baz == :bar or :baz)

You could do

[:pretty, :handsome].include?(self.site.permalink_style)

instead.

Please sign in to comment.