Skip to content

Commit 62d1f30

Browse files
committed
Fixed missing trailing slashes causing 302s
1 parent 68fbd9d commit 62d1f30

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

categories/plugin.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,12 @@ def on_post_build(self, **_):
8989
self.clean_temp_dir()
9090

9191
def on_page_markdown(self, markdown: str, page: Page, **_):
92-
"""Replaces any alias tags on the page with markdown links."""
92+
"""Appends the category links section for a page to the markdown."""
9393
relative_url = get_relative_url(str(self.cat_path), page.file.url)
9494
if page.file.url not in self.pages:
9595
return markdown
9696
links = list(map(
97-
lambda c: f"- [{c}]({relative_url}/{self.categories[c]['slug']})",
97+
lambda c: f"- [{c}]({relative_url}/{self.categories[c]['slug']}/)",
9898
sorted(self.pages[page.file.url])
9999
))
100100
return (
@@ -121,7 +121,7 @@ def register_page(self, cat_name: str, page_url: str, page_title: str) -> None:
121121
self.add_category(cat_name)
122122
self.categories[cat_name]['pages'].append({
123123
'title': page_title,
124-
'url': page_url
124+
'url': f"{page_url}{'' if page_url.endswith('/') else '/'}"
125125
})
126126

127127
# Each page also stores which categories it belongs to
@@ -183,7 +183,7 @@ def on_files(self, files, config, **_):
183183
self.define_categories(files)
184184
for category in self.categories.values():
185185
joined = "\n".join(map(
186-
lambda p: f"- [{p['title']}](../../{p['url']}/)",
186+
lambda p: f"- [{p['title']}](../../{p['url']})",
187187
sorted(category['pages'], key=lambda p: p['title'])
188188
))
189189

0 commit comments

Comments
 (0)