from __future__ import annotations import html import json from pathlib import Path from urllib.parse import quote BASE_DIR = Path(__file__).resolve().parent SITE_URL = "https://kandytransfers.com" LASTMOD = "2026-05-10" WHATSAPP_NUMBER = "94714496285" PHONE_NUMBER = "+94714496285" DEFAULT_IMAGE = f"{SITE_URL}/images/kandy-private-driver-hire.webp" def esc(value: str) -> str: return html.escape(value, quote=True) def wa_link(message: str) -> str: return f"https://wa.me/{WHATSAPP_NUMBER}?text={quote(message)}" def asset_prefix(filename: str) -> str: return "../" * filename.count("/") def canonical_url(filename: str) -> str: if filename == "index.html": return f"{SITE_URL}/" if filename.endswith("/index.html"): directory = filename[:-10].rstrip("/") return f"{SITE_URL}/{directory}/" return f"{SITE_URL}/{filename}" def render_json_ld(payload: dict) -> str: return json.dumps(payload, indent=2, ensure_ascii=False) def render_head( title: str, description: str, filename: str, og_title: str, og_description: str, schemas: list[dict], *, language: str = "English", locale: str = "en_US", alternates: list[tuple[str, str]] | None = None, ) -> str: page_url = canonical_url(filename) prefix = asset_prefix(filename) schema_blocks = "\n".join( f' ' for schema in schemas ) alternate_links = "\n".join( f' ' for hreflang, alt_filename in (alternates or []) ) return f"""
{esc(card['text'])}
{esc(stop['text'])}
{esc(faq['a'])}
{esc(paragraph)}
" for paragraph in section["paragraphs"]) section_html.append( f"""{esc(page['hero_subtitle'])}
{esc(page['intro_paragraphs'][0])}
{esc(page['intro_paragraphs'][1])}
{esc(item['text'])}
{esc(page['hero_subtitle'])}
{esc(page['intro_paragraphs'][0])}
{esc(page['intro_paragraphs'][1])}
{esc(item['text'])}
{esc(page['hero_subtitle'])}
{esc(page['intro_paragraphs'][0])}
{esc(page['intro_paragraphs'][1])}
{esc(card['text'])}
{esc(card['cta'])} → """ for card in cards ) def render_locale_nav(page: dict) -> str: home_url = "/" if page["lang_code"] == "en" else f"/{page['lang_code']}/" nav_items = "\n".join( f'{esc(page['hero_subtitle'])}
{esc(page['intro_paragraphs'][0])}
{esc(page['intro_paragraphs'][1])}
Start with the article that matches the part of the trip you are currently trying to solve.
{esc(page['hero_subtitle'])}
{esc(page['intro_paragraphs'][0])}
{esc(page['intro_paragraphs'][1])}
{esc(page['routes_intro'])}
{esc(page['guides_intro'])}