Module: JekyllAeo::Utils::MdUrl

Defined in:
lib/jekyll-aeo/utils/md_url.rb

Class Method Summary collapse

Class Method Details

.dest_path(obj, site) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/jekyll-aeo/utils/md_url.rb', line 20

def self.dest_path(obj, site)
  html_path = obj.destination(site.dest)
  dir = File.dirname(html_path)
  base = File.basename(html_path)
  if base == "index.html" && dir != site.dest
    File.join(File.dirname(dir), "#{File.basename(dir)}.md")
  else
    html_path.sub(/\.html\z/, ".md")
  end
end

.for(url, baseurl = "") ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/jekyll-aeo/utils/md_url.rb', line 6

def self.for(url, baseurl = "")
  baseurl = baseurl.to_s.chomp("/")
  md_path = if url == "/"
              "/index.md"
            elsif url.end_with?("/")
              url.sub(%r{/\z}, ".md")
            elsif url.end_with?(".html")
              url.sub(/\.html\z/, ".md")
            else
              "#{url}.md"
            end
  "#{baseurl}#{md_path}"
end