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):
262 text=True, 262 text=True,
263 ) 263 )
264 264
265 # Fix to remove annoying cleberg-net.html file
266 os.remove(".build/cleberg-net.html")
267
265 if result.returncode != 0: 268 if result.returncode != 0:
266 print("Error running publish.el:") 269 print("Error running publish.el:")
267 print(result.stderr, file=sys.stderr) 270 print(result.stderr, file=sys.stderr)
268 sys.exit(1) 271 sys.exit(1)
269 272
270 273
271def generate_sitemap(public_dir="public", base_url="https://cleberg.net"): 274def generate_sitemap(build_dir=".build", base_url="https://cleberg.net"):
272 """ 275 """
273 Generates a sitemap.xml based on contents of the public directory. 276 Generates a sitemap.xml based on contents of the .build directory.
274 Only includes .html files (except 404.html). 277 Only includes .html files (except 404.html).
275 """ 278 """
276 sitemap_entries = [] 279 sitemap_entries = []
277 for root, dirs, files in os.walk(public_dir): 280 for root, dirs, files in os.walk(build_dir):
278 for filename in files: 281 for filename in files:
279 if filename.endswith(".html") and filename != "404.html": 282 if filename.endswith(".html") and filename != "404.html":
280 full_path = os.path.join(root, filename) 283 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)
282 url_path = "/" + quote(rel_path.replace(os.sep, "/")) 285 url_path = "/" + quote(rel_path.replace(os.sep, "/"))
283 # Remove index.html for cleaner URLs 286 # Remove index.html for cleaner URLs
284 if url_path.endswith("/index.html"): 287 if url_path.endswith("/index.html"):
@@ -302,8 +305,9 @@ def generate_sitemap(public_dir="public", base_url="https://cleberg.net"):
302{os.linesep.join(sitemap_entries)} 305{os.linesep.join(sitemap_entries)}
303</urlset> 306</urlset>
304""" 307"""
305 # Write to public/sitemap.xml 308 # Write to .build/sitemap.xml
306 sitemap_path = os.path.join(public_dir, "sitemap.xml") 309 print(build_dir)
310 sitemap_path = os.path.join(build_dir, "sitemap.xml")
307 with open(sitemap_path, "w", encoding="utf-8") as f: 311 with open(sitemap_path, "w", encoding="utf-8") as f:
308 f.write(sitemap_xml) 312 f.write(sitemap_xml)
309 print( 313 print(
publish.el +1 −1
@@ -1,5 +1,5 @@
1;; Explicitly load packages for Doom Emacs 1;; 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")
3(add-to-list 'load-path "~/.config/emacs/.local/straight/repos/weblorg") 3(add-to-list 'load-path "~/.config/emacs/.local/straight/repos/weblorg")
4(add-to-list 'load-path "~/.config/emacs/.local/straight/repos/templatel") 4(add-to-list 'load-path "~/.config/emacs/.local/straight/repos/templatel")
5 5