Commit 546ef90768

546ef90768496052223a12b6c1d5d751631ede42

parent: ded44ca9e8

Unsigned

cmc <hello@cleberg.net> · 2025-07-19 02:03 UTC

FIX: update build script and generate sitemap.xml

Layout: unified · split

build.py +10 −6
@@ -262,23 +262,26 @@ def run_emacs_publish(dev_mode=True):
262262 text=True,
263263 )
264264
265 # Fix to remove annoying cleberg-net.html file
266 os.remove(".build/cleberg-net.html")
267
265268 if result.returncode != 0:
266269 print("Error running publish.el:")
267270 print(result.stderr, file=sys.stderr)
268271 sys.exit(1)
269272
270273
271def generate_sitemap(public_dir="public", base_url="https://cleberg.net"):
274def generate_sitemap(build_dir=".build", base_url="https://cleberg.net"):
272275 """
273 Generates a sitemap.xml based on contents of the public directory.
276 Generates a sitemap.xml based on contents of the .build directory.
274277 Only includes .html files (except 404.html).
275278 """
276279 sitemap_entries = []
277 for root, dirs, files in os.walk(public_dir):
280 for root, dirs, files in os.walk(build_dir):
278281 for filename in files:
279282 if filename.endswith(".html") and filename != "404.html":
280283 full_path = os.path.join(root, filename)
281 rel_path = os.path.relpath(full_path, public_dir)
284 rel_path = os.path.relpath(full_path, build_dir)
282285 url_path = "/" + quote(rel_path.replace(os.sep, "/"))
283286 # Remove index.html for cleaner URLs
284287 if url_path.endswith("/index.html"):
@@ -302,8 +305,9 @@ def generate_sitemap(public_dir="public", base_url="https://cleberg.net"):
302305{os.linesep.join(sitemap_entries)}
303306</urlset>
304307"""
305 # Write to public/sitemap.xml
306 sitemap_path = os.path.join(public_dir, "sitemap.xml")
308 # Write to .build/sitemap.xml
309 print(build_dir)
310 sitemap_path = os.path.join(build_dir, "sitemap.xml")
307311 with open(sitemap_path, "w", encoding="utf-8") as f:
308312 f.write(sitemap_xml)
309313 print(
publish.el +1 −1
@@ -1,5 +1,5 @@
11;; Explicitly load packages for Doom Emacs
2(add-to-list 'load-path "~/.config/emacs/.local/straight/repos/emacs-htmlize")
2(add-to-list 'load-path "~/.config/emacs/.local/straight/repos/htmlize")
33(add-to-list 'load-path "~/.config/emacs/.local/straight/repos/weblorg")
44(add-to-list 'load-path "~/.config/emacs/.local/straight/repos/templatel")
55