Class: Jekyll::Page

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

Instance Method Summary collapse

Instance Method Details

#_urlObject



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

alias_method :_url, :url

#urlObject

Enhances original by applying /LANG/URL.



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/jekyll-i18n.rb', line 80

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