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.
This commit is contained in:
Kumi 2024-05-25 14:57:52 +02:00
parent ee6cc2de6d
commit 6c5faf6c19
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -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])