Fix blog linking.

This commit is contained in:
Sergio Martínez Portela 2023-10-03 00:07:45 +02:00
parent 302ec0b764
commit abfd4b16c5
5 changed files with 7 additions and 6 deletions

View file

@ -122,6 +122,7 @@ def slugify(title):
slug = unidecode(title).lower()
slug = SLUG_REMOVE_RE.sub('', slug)
slug = SLUG_HYPHENATE_RE.sub('-', slug)
slug = slug.strip('-')
return slug.strip()
@ -167,7 +168,7 @@ def get_out_path(front_matter):
out_path = os.path.join(str(front_matter['date'].year), front_matter['slug'])
if front_matter.get('lang', LANG_PRIORITY[0]) != LANG_PRIORITY[0]:
out_path = os.path.join(str(front_matter['date'].year), front_matter['lang'], front_matter['slug'])
out_path = os.path.join(front_matter['lang'], str(front_matter['date'].year), front_matter['slug'])
return out_path
@ -388,7 +389,7 @@ def render_categories(docs, dest_top):
result = CATEGORY_LIST_TEMPLATE.render(
posts=posts,
)
path = os.path.join(dest_top, "tags", tag, "index.html")
path = os.path.join(dest_top, "tags", tag.replace('/', '_'), "index.html")
os.makedirs(os.path.dirname(path), exist_ok=True)
with open(path, 'wt') as f:
f.write(result)