Class: JekyllRedirectFrom::RedirectPage

Inherits:
Jekyll::Page
  • Object
show all
Defined in:
lib/jekyll-redirect-from/redirect_page.rb

Instance Method Summary collapse

Constructor Details

#initialize(site, base, dir, name) ⇒ RedirectPage

Initialize a new RedirectPage.

site - The Site object. base - The String path to the source. dir - The String path between the source and the file. name - The String filename of the file.



9
10
11
12
13
14
15
16
17
# File 'lib/jekyll-redirect-from/redirect_page.rb', line 9

def initialize(site, base, dir, name)
  @site = site
  @base = base
  @dir  = dir
  @name = name

  self.process(name)
  self.data = {}
end

Instance Method Details

#generate_redirect_content(item_url) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/jekyll-redirect-from/redirect_page.rb', line 19

def generate_redirect_content(item_url)
  self.output = self.content = <<-EOF
<!DOCTYPE html>
<meta charset=utf-8>
<title>Redirecting...</title>
<link rel=canonical href="#{item_url}">
<meta http-equiv=refresh content="0; url=#{item_url}">
<h1>Redirecting...</h1>
<a href="#{item_url}">Click here if you are not redirected.</a>
<script>location='#{item_url}'</script>
EOF
end