mirror of
https://github.com/olehomelchenko/olehomelchenko.com.git
synced 2026-02-04 18:44:36 +00:00
fix: allow trailing slashes on articles
This commit is contained in:
@@ -15,13 +15,15 @@ project:
|
||||
- "!static/"
|
||||
- "!templates/"
|
||||
- "!themes/"
|
||||
post-render:
|
||||
- python3 reorganize-urls.py
|
||||
|
||||
filters:
|
||||
- vega-lite.lua
|
||||
|
||||
website:
|
||||
title: "Oleh Omelchenko"
|
||||
site-url: "https://olehomelchenko.com"
|
||||
site-url: "https://olehomelchenko.com/"
|
||||
description: "Data visualization and analysis blog"
|
||||
|
||||
navbar:
|
||||
|
||||
38
reorganize-urls.py
Executable file
38
reorganize-urls.py
Executable file
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Post-render script to reorganize HTML files into pretty URL structure.
|
||||
Converts posts/post-name.html to posts/post-name/index.html for trailing slash support.
|
||||
"""
|
||||
import os
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
|
||||
def reorganize_html_files(site_dir="_site"):
|
||||
"""Reorganize HTML files into directory structure for pretty URLs."""
|
||||
site_path = Path(site_dir)
|
||||
|
||||
# Directories to process (add more as needed)
|
||||
directories_to_process = ["posts", "til", "portfolio", "projects"]
|
||||
|
||||
for directory in directories_to_process:
|
||||
dir_path = site_path / directory
|
||||
if not dir_path.exists():
|
||||
continue
|
||||
|
||||
# Find all HTML files except index.html
|
||||
for html_file in dir_path.glob("*.html"):
|
||||
if html_file.name == "index.html":
|
||||
continue
|
||||
|
||||
# Create directory with same name as file (without .html)
|
||||
new_dir = dir_path / html_file.stem
|
||||
new_dir.mkdir(exist_ok=True)
|
||||
|
||||
# Move file to directory as index.html
|
||||
new_file = new_dir / "index.html"
|
||||
shutil.move(str(html_file), str(new_file))
|
||||
print(f"Moved {html_file} -> {new_file}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
reorganize_html_files()
|
||||
print("URL reorganization complete!")
|
||||
Reference in New Issue
Block a user