posty.site module
- class posty.site.Site(site_path: str = '.', config_path: str | None = None, config: Config | None = None)[source]
Bases:
objectRepresentation of an entire site with posts and pages. This is the main class that conrols everything.
- Parameters:
site_path – Path to the directory containing site content (pages, posts, templates)
config_path – Path to the config file, defaults to
$SITE_PATH/config.yml
- property copyright: str
Returns a string of the copyright info, based on the configured author and the years of the first and last post
- new_page(name: str = 'New Page') None[source]
Create a new page in the site directory from the skeleton page
- new_post(name: str = 'New Post') None[source]
Create a new post in the site directory from the skeleton post
- page(slug: str) Page[source]
Returns a Page object by its slug
- Parameters:
slug – slug of the page to find
- Returns:
A page dict
- Raises:
PostyError – if no page could be found
- post(slug: str) Post[source]
Returns a Post object by its slug
- Parameters:
slug – slug of the post to find
- Returns:
A post dict
- Raises:
PostyError – if no post could be found