Class: Lifer::URIStrategy::Pretty

Inherits:
Lifer::URIStrategy show all
Defined in:
lib/lifer/uri_strategy/pretty.rb

Overview

The pretty URI strategy ensures that all entries are indexified, making their URLs “pretty” in the browser. “Pretty” because browsers often do not show “index.html” at the end of the URL because it’s implicit.

For example:

entry.md ---> entry/index.html

Instance Attribute Summary

Attributes inherited from Lifer::URIStrategy

#root

Instance Method Summary collapse

Methods inherited from Lifer::URIStrategy

#initialize

Constructor Details

This class inherits a constructor from Lifer::URIStrategy

Instance Method Details

#output_file(entry) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/lifer/uri_strategy/pretty.rb', line 13

def output_file(entry)
  basename = File.basename entry.file,
    Lifer::Utilities.file_extension(entry.file)

  Pathname entry.file.to_s
    .gsub(/#{root}[\/]{0,1}/, "")
    .gsub(/#{basename}(\..+)/, "#{basename}/index.#{file_extension(entry)}")
end