Commit ded44ca9e8
Unsigned
Layout: unified · split
build.py +10 −6
| @@ -281,14 +281,16 @@ def generate_sitemap(public_dir="public", base_url="https://cleberg.net"): | ||
| 281 | 281 | rel_path = os.path.relpath(full_path, public_dir) |
| 282 | 282 | url_path = "/" + quote(rel_path.replace(os.sep, "/")) |
| 283 | 283 | # Remove index.html for cleaner URLs |
| 284 | if url_path.endswith('/index.html'): | |
| 285 | url_path = url_path[:-10] or '/' | |
| 286 | elif url_path == '/index.html': | |
| 287 | url_path = '/' | |
| 284 | if url_path.endswith("/index.html"): | |
| 285 | url_path = url_path[:-10] or "/" | |
| 286 | elif url_path == "/index.html": | |
| 287 | url_path = "/" | |
| 288 | 288 | loc = f"{base_url}{url_path}" |
| 289 | 289 | |
| 290 | 290 | # Last modified time |
| 291 | lastmod = datetime.utcfromtimestamp(os.path.getmtime(full_path)).strftime("%Y-%m-%d") | |
| 291 | lastmod = datetime.utcfromtimestamp( | |
| 292 | os.path.getmtime(full_path) | |
| 293 | ).strftime("%Y-%m-%d") | |
| 292 | 294 | |
| 293 | 295 | sitemap_entries.append(f""" <url> |
| 294 | 296 | <loc>{loc}</loc> |
| @@ -304,7 +306,9 @@ def generate_sitemap(public_dir="public", base_url="https://cleberg.net"): | ||
| 304 | 306 | sitemap_path = os.path.join(public_dir, "sitemap.xml") |
| 305 | 307 | with open(sitemap_path, "w", encoding="utf-8") as f: |
| 306 | 308 | f.write(sitemap_xml) |
| 307 | print(f"Sitemap generated at {sitemap_path} with {len(sitemap_entries)} entries.") | |
| 309 | print( | |
| 310 | f"Sitemap generated at {sitemap_path} with {len(sitemap_entries)} entries." | |
| 311 | ) | |
| 308 | 312 | |
| 309 | 313 | |
| 310 | 314 | def deploy_to_server(build_dir, server): |