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)

View File

@ -38,7 +38,7 @@
</time>
<ul class="post-tags">
{% for post_tag in post_tags %}
<li class="post-tag"><a href="{{ base_path }}/tags/{{ post_tag }}/"</a>{{ post_tag }}</a></li>
<li class="post-tag"><a href="{{ base_path }}/tags/{{ post_tag |urlencode|replace('/', '_') }}/"</a>{{ post_tag }}</a></li>
{% endfor %}
</ul>
</div>

View File

@ -42,7 +42,7 @@
<div class="post-metadata">
<ul class="post-tags">
{% for post_tag in post.post_tags %}
<li class="post-tag"><a href="../tags/{{ post_tag }}/"</a>{{ post_tag }}</a></li>
<li class="post-tag"><a href="../tags/{{ post_tag |urlencode|replace('/', '_') }}/">{{ post_tag }}</a></li>
{% endfor %}
</ul>
</div>

View File

@ -40,7 +40,7 @@
</time>
<ul class="post-tags">
{% for post_tag in post.post_tags %}
<li class="post-tag"><a href="tags/{{ post_tag }}/"</a>{{ post_tag }}</a></li>
<li class="post-tag"><a href="tags/{{ post_tag |urlencode|replace('/', '_') }}/"</a>{{ post_tag }}</a></li>
{% endfor %}
</ul>
</div>

View File

@ -42,7 +42,7 @@
<div class="post-metadata">
<ul class="post-tags">
{% for post_tag in post.post_tags %}
<li class="post-tag"><a href="../../tags/{{ post_tag }}/"</a>{{ post_tag }}</a></li>
<li class="post-tag"><a href="../../tags/{{ post_tag |urlencode|replace('/', '_') }}/">{{ post_tag }}</a></li>
{% endfor %}
</ul>
</div>