Wytch::Page
Represents a single page in a Wytch site.
Description
Represents a single page in a Wytch site.
Pages are defined by Ruby content files in the content directory. Each content file is evaluated in the context of a Page instance, allowing it to set metadata and configure the view class.
Methods
def metadata
- Returns:
- (Hash) — arbitrary metadata set by the content file
def render
Renders the page using its configured view class.
- Returns:
- (String) — the rendered HTML
def path
Returns the URL path for this page.
- Returns:
- (String) — the URL path (e.g., "/" for index, "/about" for about.rb)
def virtual_path
Returns the virtual path derived from the file path.
- Returns:
- (String) — the path without directory prefix or .rb suffix
def build_path
Returns the output file path for the built page.
- Returns:
- (String) — the build path (e.g., "about/index.html")
def add(helper_module)
Extends this page instance with a helper module. Called from content files to add helper methods.
- Parameters:
helper_module(Module) — the module to extend this page with
- Returns:
- (void) —
def view(view_class)
Sets the view class for rendering this page. Called from content files to specify which Phlex view to use.
- Parameters:
view_class(Class) — a Phlex view class that accepts the page in its initializer
- Returns:
- (void) —
def include_in_sitemap?
Whether this page should be included in the sitemap. Override in subclasses to exclude pages.
- Returns:
- (Boolean) — true by default
def last_modified
The last modification date for sitemap generation. Override in subclasses to provide actual dates.
- Returns:
- (Date, Time, nil) — the last modified date, or nil if unknown
def change_frequency
The change frequency hint for sitemap generation. Override in subclasses to provide hints like "daily", "weekly", etc.
- Returns:
- (String, nil) — the change frequency, or nil if unknown
def priority
The priority hint for sitemap generation. Override in subclasses to provide a value between 0.0 and 1.0.
- Returns:
- (Float, nil) — the priority, or nil if unknown