Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Put the path into the url so the dir method will return the expected inf... #506

Closed
wants to merge 1 commit into from

2 participants

@Painted-Fox

...ormation.

Currently the dir method for a page will always return nil because it expects the path to be in the url. However, the path is not included in the url except the version we pass to the view layer.

This change inserts the path into the object's url so that the dir method can function as expected.

@fotos fotos referenced this pull request
Merged

Added path in url. #536

@fotos

Damn... I just redid this fix.

I decided to use your fix which was a bit cleaner but added some tests.
Perhaps you should close this pull request to avoid confusion?

@Painted-Fox

Okay. Good luck getting it accepted. I'd like to see this one fixed.

Closing since #536 duplicates this request, but adds tests.

@Painted-Fox Painted-Fox closed this
@fotos

@MrWerewolf certainly took some time but I managed to get it merged! ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 4 deletions.
  1. +5 −4 lib/jekyll/page.rb
View
9 lib/jekyll/page.rb
@@ -46,9 +46,9 @@ def permalink
# Returns the template String.
def template
if self.site.permalink_style == :pretty && !index? && html?
- "/:basename/"
+ "/:path/:basename/"
else
- "/:basename:output_ext"
+ "/:path/:basename:output_ext"
end
end
@@ -62,6 +62,7 @@ def url
permalink
else
{
+ "path" => @dir
"basename" => self.basename,
"output_ext" => self.output_ext,
}.inject(template) { |result, token|
@@ -105,7 +106,7 @@ def render(layouts, site_payload)
# Returns the Hash representation of this Page.
def to_liquid
self.data.deep_merge({
- "url" => File.join(@dir, self.url),
+ "url" => self.url,
"content" => self.content })
end
@@ -117,7 +118,7 @@ def to_liquid
def destination(dest)
# The url needs to be unescaped in order to preserve the correct
# filename.
- path = File.join(dest, @dir, CGI.unescape(self.url))
+ path = File.join(dest, CGI.unescape(self.url))
path = File.join(path, "index.html") if self.url =~ /\/$/
path
end
Something went wrong with that request. Please try again.