Class: Jekyll::Post

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll-i18n.rb

Overview

XXX this could probably be made more Ruby-like.

Instance Method Summary collapse

Instance Method Details

#_urlObject



102
# File 'lib/jekyll-i18n.rb', line 102

alias_method :_url, :url

#urlObject

Enhances original by applying /LANG/URL



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/jekyll-i18n.rb', line 104

def url			
	@url = _url
	lang = data['lang']
	# For 'mul' we generate multiple pages — inappropriate to have a url here
	# For 'und' there is no language — return
	if lang == 'mul' or lang == 'und'
		return @url
	end
	
	# Gets filename
	name = Pathname.new(@url).basename.to_s
	# this could be bad if the directory has the same name as the file
	# XXX substitute the last occurance in a string, not the first
	nameWithoutLang = @url.sub(name, name.sub('.'+lang, ''))
	nameWithoutLang == '/index/' ? "/#{lang}/index.html" : "/#{lang}"+nameWithoutLang
end