Class: Plate::StaticPage
Overview
A static page is left unmodified and is transferred over to the published site exactly as it is.
Instance Attribute Summary
Attributes inherited from Page
#body, #content, #file, #meta, #partials, #raw, #site
Instance Method Summary collapse
- #file_path ⇒ Object
- #layout ⇒ Object
-
#rendered_content ⇒ Object
If we need for some reason, read this file’s contents.
-
#upgrade? ⇒ Boolean
Check a static page to see if it should be converted into a Page.
-
#write! ⇒ Object
Write this page to the destination.
Methods inherited from Page
#<=>, #==, #basename, #directory, #downgrade?, #engines, #extension, #extensions, #file?, #file_name, #format_extension, #id, #initialize, #inspect, #keywords, #load!, #loaded?, #path, #relative_file, #reload!, #rendered_body, #slug, #title_for_url, #to_s, #url
Methods included from Callbacks
Constructor Details
This class inherits a constructor from Plate::Page
Instance Method Details
#file_path ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/plate/static_page.rb', line 5 def file_path base = Pathname.new(File.join(self.site.source, 'content')) current = Pathname.new(self.file) dirs = current.relative_path_from(base) "/#{dirs}" end |
#layout ⇒ Object
14 15 16 |
# File 'lib/plate/static_page.rb', line 14 def layout nil end |
#rendered_content ⇒ Object
If we need for some reason, read this file’s contents
19 20 21 |
# File 'lib/plate/static_page.rb', line 19 def rendered_content @rendered_content ||= File.read(self.file) end |
#upgrade? ⇒ Boolean
Check a static page to see if it should be converted into a Page
24 25 26 |
# File 'lib/plate/static_page.rb', line 24 def upgrade? rendered_content.start_with?('---') end |
#write! ⇒ Object
Write this page to the destination. For static files this just results in copying the file over to the destination
30 31 32 33 34 |
# File 'lib/plate/static_page.rb', line 30 def write! path = File.join(site.build_destination, file_path) FileUtils.mkdir_p(File.dirname(path)) FileUtils.cp(self.file, path) end |