Skip to content

Commit

Permalink
redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
FelixMartel committed Jul 9, 2024
1 parent dd1f572 commit 10d9c76
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
14 changes: 12 additions & 2 deletions build.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json
from glob import glob
from os import path, mkdir
from os import path, mkdir, makedirs
from datetime import date

main_layout = open("src/main_layout.html").read()
Expand Down Expand Up @@ -96,6 +96,13 @@ def build_sitemap(page_metas):

f.write('</urlset>')

def build_redirects(redirect_meta):
for src, dst in redirect_meta.items():
makedirs(f"build/{src}", exist_ok=True)
file_out = open(f"build/{src}/index.html","w")
file_out.write(f'<meta http-equiv="refresh" content="0; url=https://blog.lixtelnis.com/{dst}">')
file_out.close()

pages = glob("src/pages/*/meta.json")
page_metas = [(page, json.load(open(page))) for page in pages]

Expand All @@ -105,4 +112,7 @@ def build_sitemap(page_metas):
build_page(page_meta)

build_rss(page_metas)
build_sitemap(page_metas)
build_sitemap(page_metas)

redirect_meta = json.load(open("redirects.json"))
build_redirects(redirect_meta)
4 changes: 4 additions & 0 deletions redirects.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"en/": "",
"en/weakhash/": "weakhash/"
}

0 comments on commit 10d9c76

Please sign in to comment.