Added option to not put file date in permalink URL

This commit is contained in:
mreid 2009-01-19 19:58:53 +11:00
parent eb70d75d44
commit 0b78c32771
4 changed files with 25 additions and 4 deletions

View File

@ -34,7 +34,7 @@ fields such as <code>title</code> and <code>date</code>.
Jekyll gets the list of blog posts by parsing the files in any
"_posts":http://github.com/mojombo/tpw/tree/master/_posts directory found in
subdirectories below the root.
Each post's filename contains the publishing date and slug (what shows up in the
Each post's filename contains (by default) the publishing date and slug (what shows up in the
URL) that the final HTML file should have. Open up the file corresponding to a
blog post:
"2008-11-17-blogging-like-a-hacker.textile":http://github.com/mojombo/tpw/tree/master/_posts/2008-11-17-blogging-like-a-hacker.textile.
@ -145,6 +145,17 @@ Default port is 4000:
$ jekyll --server [PORT]
By default, the permalink for each post begins with its date in 'YYYY/MM/DD'
format. If you do not wish to have the date appear in the URL of each post,
you can change the permalink style to 'none' so that only the 'slug' part of
the filename is used. For example, with the permalink style set to 'none' the
file '2009-01-01-happy-new-year.markdown' will have a permalink like
'http://yoursite.com/happy-new-year.html'. The date of the post will still be
read from the filename (and is required!) to be used elsewhere in Jekyll.
Example usage:
$ jekyll --permalink none
h2. Data
Jekyll traverses your site looking for files to process. Any files with YAML

View File

@ -47,6 +47,11 @@ opts = OptionParser.new do |opts|
puts 'You must have the rdiscount gem installed first'
end
end
opts.on("--permalink [TYPE]", "Use 'date' (default) for YYYY/MM/DD") do |style|
Jekyll.permalink_style = (style || 'date').to_sym
end
end
opts.parse!

View File

@ -46,12 +46,13 @@ module Jekyll
VERSION = '0.3.0'
class << self
attr_accessor :source, :dest, :lsi, :pygments, :markdown_proc
attr_accessor :source, :dest, :lsi, :pygments, :markdown_proc,:permalink_style
end
Jekyll.lsi = false
Jekyll.pygments = false
Jekyll.markdown_proc = Proc.new { |x| Maruku.new(x).to_html }
Jekyll.permalink_style = :date
def self.process(source, dest)
require 'classifier' if Jekyll.lsi

View File

@ -61,7 +61,7 @@ module Jekyll
# The generated directory into which the post will be placed
# upon generation. This is derived from the permalink or, if
# permalink is absent, set to the default date
# e.g. "/2008/11/05/"
# e.g. "/2008/11/05/" if the permalink style is :date, otherwise nothing
#
# Returns <String>
def dir
@ -69,7 +69,11 @@ module Jekyll
permalink.to_s.split("/")[0..-2].join("/")
else
prefix = self.categories.empty? ? '' : '/' + self.categories.join('/')
prefix + date.strftime("/%Y/%m/%d/")
if Jekyll.permalink_style == :date
prefix + date.strftime("/%Y/%m/%d/")
else
prefix + '/'
end
end
end