gilbert.site module

class gilbert.site.Site(root: pathlib.Path)

Bases: object

Configuration of main site.

emit(event: str) → None

Emit a named event to all registered callbacks.

get_context(obj: gilbert.content.Page, **kwargs) → stencil.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 an skeleton config.yml file.

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[[pathlib.Path], Tuple[Union[None, ByteString, str], Dict[KT, VT]]])

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: object

Method decorator to cause a method to emit before- and after- events.