Class: Sitepress::Extensions::IndexRequestPath
- Inherits:
-
Object
- Object
- Sitepress::Extensions::IndexRequestPath
- Defined in:
- lib/sitepress/extensions/index_request_path.rb
Overview
Removes files beginning with “_” from the resource collection.
Constant Summary collapse
- FILE_NAME =
Name of the file that we’ll want to change to a / path
"index.html".freeze
Instance Method Summary collapse
-
#initialize(file_name: FILE_NAME) ⇒ IndexRequestPath
constructor
A new instance of IndexRequestPath.
- #process_resources(node) ⇒ Object
Constructor Details
#initialize(file_name: FILE_NAME) ⇒ IndexRequestPath
Returns a new instance of IndexRequestPath.
8 9 10 |
# File 'lib/sitepress/extensions/index_request_path.rb', line 8 def initialize(file_name: FILE_NAME) @file_name = file_name end |
Instance Method Details
#process_resources(node) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/sitepress/extensions/index_request_path.rb', line 12 def process_resources(node) node.flatten.each do |r| asset = r.asset if asset.path.basename.to_s.start_with? @file_name request_path = Pathname.new("/").join(r.request_path).dirname.cleanpath.to_s node.formats.remove(r) node.add(path: request_path, asset: asset) end end end |