Class: Jekyll::AltUrls
- Inherits:
-
Generator
- Object
- Generator
- Jekyll::AltUrls
- Defined in:
- lib/jekyll/alt_urls.rb,
lib/jekyll/alt_urls/version.rb,
lib/jekyll/alt_urls/redirect_page.rb
Defined Under Namespace
Classes: RedirectPage
Constant Summary collapse
- VERSION =
"0.1.0"
Instance Method Summary collapse
- #alt_urls(page_or_post) ⇒ Object
- #generate(site) ⇒ Object
- #generate_alt_urls(site, list) ⇒ Object
- #has_alt_urls?(page_or_post) ⇒ Boolean
Instance Method Details
#alt_urls(page_or_post) ⇒ Object
29 30 31 |
# File 'lib/jekyll/alt_urls.rb', line 29 def alt_urls(page_or_post) page_or_post.data['alt_urls'] end |
#generate(site) ⇒ Object
5 6 7 8 9 |
# File 'lib/jekyll/alt_urls.rb', line 5 def generate(site) original_pages = site.pages.dup generate_alt_urls(site, site.posts) generate_alt_urls(site, original_pages) end |
#generate_alt_urls(site, list) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/jekyll/alt_urls.rb', line 11 def generate_alt_urls(site, list) list.each do |item| if has_alt_urls?(item) alt_urls(item).flatten.each do |alt_url| redirect_page = RedirectPage.new(site, site.source, File.dirname(alt_url), File.basename(alt_url)) redirect_page.generate_redirect_content(item.url) site.pages << redirect_page end end end end |
#has_alt_urls?(page_or_post) ⇒ Boolean
23 24 25 26 27 |
# File 'lib/jekyll/alt_urls.rb', line 23 def has_alt_urls?(page_or_post) page_or_post.data.has_key?('alt_urls') && !alt_urls(page_or_post).nil? && alt_urls(page_or_post).is_a?(Array) end |