9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/jekyll/alternate/permalinks.rb', line 9
def render(page)
alternate_permalinks = page.data['alternate-permalinks']
alternate_permalinks ||= page.data['alternate_permalinks']
return unless alternate_permalinks.is_a? Array
site = page.site
path = Pathname.new(page.destination(site.dest))
alternate_permalinks.each do |alt|
alt = Jekyll::PathManager.join(alt, 'index.html') if alt.end_with? '/'
alt_path = Pathname.new(site.in_dest_dir(alt))
if alt_path.exist?
Jekyll.logger.warn 'Permalinks:', "#{alt_path} already exists, skipping"
else
relative_path = path.relative_path_from(alt_path.dirname)
Jekyll.logger.info 'Permalinks:', "Symlink from #{relative_path} to #{alt}"
FileUtils.mkdir_p(alt_path.dirname)
File.symlink(relative_path, alt_path)
end
end
end
|