"""Recipe registry. Register new site recipes here — nothing else changes.""" from __future__ import annotations from typing import Optional from core.models import PageContext, PageMatch from .base import SiteRecipe from .linkedin import LinkedInRecipe REGISTRY: list[SiteRecipe] = [ LinkedInRecipe(), ] def enabled_recipes() -> list[SiteRecipe]: return [r for r in REGISTRY if r.enabled] def match(ctx: PageContext) -> Optional[tuple[SiteRecipe, PageMatch]]: """Return the first enabled recipe that recognises the page context.""" for recipe in enabled_recipes(): m = recipe.matches(ctx) if m is not None: return recipe, m return None