gilbert.site module¶
- class gilbert.site.Site(root: Path)¶
Bases:
objectConfiguration of main site.
- emit(event: str) None¶
Emit a named event to all registered callbacks.
- get_context(obj: Page, **kwargs) Context¶
Build a template context object.
Applies all registered
context generators.
- init()¶
Create a new site root.
Ensures the template, pages, content, and destination directories for this site exist, creating them if they don’t.
Creates a skeleton
config.ymlfile.
- load_content()¶
Builds the ‘content’ collection for this site, loading all content.
- load_pages()¶
Builds the ‘pages’ collection for this site, loading all content.
- load_plugin(package_name: str) bool¶
Helper function for importing a plugin and handling its initialisation.
- load_plugins()¶
Loads all configured plugins, as well as the site-local
`plugins.py, if found.
- on(event: str, handler: Callable[[Site], None]) None¶
Registers a callback function for a given event.
- classmethod register_context_provider(func: Callable[[dict], dict])¶
Adds a new context provider to the Site.
Context Providers are applied every time a render needs a template context.
- classmethod register_loader(ext: str, func: Callable[[Path], tuple[None | ByteString | str, dict]])¶
Register a file type loader by extension.
- render()¶
Loads all content and pages, then renders the site.
- render_pages()¶
Render all pages in this site.
- class gilbert.site.emits(event: str)¶
Bases:
objectMethod decorator to cause a method to emit before- and after- events.