from __future__ import annotations import json from dataclasses import dataclass, field from .html_utils import SafeHtml, attr, escape, trusted from .icons import _svg_icon DEFAULT_DESCRIPTION = ( "KarlDNS is a small self-hosted Dynamic DNS service for FRITZ!Box routers, " "Linux cron jobs, and home networks." ) @dataclass(frozen=True) class PageOptions: extra_styles: SafeHtml = field(default_factory=lambda: trusted("")) extra_scripts: SafeHtml = field(default_factory=lambda: trusted("")) description: str = DEFAULT_DESCRIPTION preload_logo: bool = False canonical_url: str | None = None image_url: str | None = None image_alt: str | None = None structured_data: dict[str, object] | None = None def _top_nav(label: str | None = None, links: SafeHtml | None = None) -> SafeHtml: account_html = "" if label: account_html = f'' if links is None: links = trusted( 'API' 'llms.txt' ) theme_toggle = f""" """ return trusted(f""" Skip to content """) def _site_footer() -> SafeHtml: return trusted(f""" """) def _page( title: str, body: SafeHtml, options: PageOptions | None = None, ) -> str: if not isinstance(body, SafeHtml): raise TypeError("body must be a SafeHtml fragment built by a template helper") options = options or PageOptions() return f"""
{_canonical_tag(options.canonical_url)} {_social_meta_tags( title=title, description=options.description, canonical_url=options.canonical_url, image_url=options.image_url, image_alt=options.image_alt, )}