Class: Perron::Resource::Slug
- Inherits:
-
Object
- Object
- Perron::Resource::Slug
- Defined in:
- lib/perron/resource/slug.rb
Instance Method Summary collapse
- #create ⇒ Object
-
#initialize(resource, frontmatter) ⇒ Slug
constructor
A new instance of Slug.
Constructor Details
#initialize(resource, frontmatter) ⇒ Slug
Returns a new instance of Slug.
10 11 12 13 |
# File 'lib/perron/resource/slug.rb', line 10 def initialize(resource, frontmatter) @resource = resource @frontmatter = frontmatter end |
Instance Method Details
#create ⇒ Object
15 16 17 18 19 20 |
# File 'lib/perron/resource/slug.rb', line 15 def create return "/" if Perron.configuration.allowed_extensions.any? { @resource.filename == "root.#{it}" } @frontmatter.slug.presence || @resource.filename.sub(/^[\d-]+-/, "").delete_suffixes(dot_prepended_allowed_extensions) end |