from pathlib import Path

DOCS_PATH = Path(__file__).parent.parent / "docs"


def head_snippet(path: Path) -> str:
    return (path / "assets" / "fluid-head-snippet.html").read_text()


def on_post_page(output: str, page, config) -> str:
    """Hook to inject custom HTML into the head of each page in mkdocs build."""
    snippet = head_snippet(DOCS_PATH)
    return output.replace("</head>", f"{snippet}</head>", 1)
