Commit 546ef90768
Unsigned
Layout: unified · split
build.py +10 −6
| @@ -262,23 +262,26 @@ def run_emacs_publish(dev_mode=True): | ||
| 262 | 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 | 268 | if result.returncode != 0: |
| 266 | 269 | print("Error running publish.el:") |
| 267 | 270 | print(result.stderr, file=sys.stderr) |
| 268 | 271 | sys.exit(1) |
| 269 | 272 | |
| 270 | 273 | |
| 271 | def generate_sitemap(public_dir="public", base_url="https://cleberg.net"): | |
| 274 | def 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 | 277 | Only includes .html files (except 404.html). |
| 275 | 278 | """ |
| 276 | 279 | sitemap_entries = [] |
| 277 | for root, dirs, files in os.walk(public_dir): | |
| 280 | for root, dirs, files in os.walk(build_dir): | |
| 278 | 281 | for filename in files: |
| 279 | 282 | if filename.endswith(".html") and filename != "404.html": |
| 280 | 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 | 285 | url_path = "/" + quote(rel_path.replace(os.sep, "/")) |
| 283 | 286 | # Remove index.html for cleaner URLs |
| 284 | 287 | if url_path.endswith("/index.html"): |
| @@ -302,8 +305,9 @@ def generate_sitemap(public_dir="public", base_url="https://cleberg.net"): | ||
| 302 | 305 | {os.linesep.join(sitemap_entries)} |
| 303 | 306 | </urlset> |
| 304 | 307 | """ |
| 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") | |
| 307 | 311 | with open(sitemap_path, "w", encoding="utf-8") as f: |
| 308 | 312 | f.write(sitemap_xml) |
| 309 | 313 | print( |
publish.el +1 −1
| @@ -1,5 +1,5 @@ | ||
| 1 | 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 | 3 | (add-to-list 'load-path "~/.config/emacs/.local/straight/repos/weblorg") |
| 4 | 4 | (add-to-list 'load-path "~/.config/emacs/.local/straight/repos/templatel") |
| 5 | 5 | |