style(sitemap): pretty-print generated sitemap.xml with 2-space indent

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Vinta Chen
2026-05-03 20:16:13 +08:00
parent a9a58ce06b
commit 9379e0a42c
+3 -1
View File
@@ -234,7 +234,9 @@ def write_sitemap_xml(path: Path, urls: Sequence[tuple[str, str]]) -> None:
lastmod_el = ET.SubElement(url_el, f"{{{SITEMAP_NS}}}lastmod")
lastmod_el.text = lastmod
ET.ElementTree(urlset).write(path, encoding="utf-8", xml_declaration=True)
tree = ET.ElementTree(urlset)
ET.indent(tree, space=" ")
tree.write(path, encoding="utf-8", xml_declaration=True)
with path.open("ab") as f:
f.write(b"\n")