From 6c5faf6c1909172ae70a17d063fd66d4451e195e Mon Sep 17 00:00:00 2001 From: Kumi Date: Sat, 25 May 2024 14:57:52 +0200 Subject: [PATCH] feat(main.py): Normalize external links for sitemap To ensure consistency within our sitemap, we've introduced logic that normalizes external channel links to relative paths. This change detects links starting with "https://" and transforms them into relative paths by stripping the protocol and domain parts. This adjustment facilitates better integration with the site's navigation structure, eliminating potential issues with external link handling and improving the user experience when accessing these channels through the sitemap. --- src/structables/main.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/structables/main.py b/src/structables/main.py index 53537c9..d980377 100644 --- a/src/structables/main.py +++ b/src/structables/main.py @@ -492,6 +492,10 @@ def route_sitemap(path=""): for li in main.select("ul.sitemap-listing li"): channel = li.a.text channel_link = li.a["href"] + + if channel_link.startswith("https://"): + channel_link = f'/{"/".join(channel_link.split("/")[3:])}' + channels.append([channel, channel_link]) groups.append(["", "", channels])