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:
parent
ee6cc2de6d
commit
6c5faf6c19
1 changed files with 4 additions and 0 deletions
|
@ -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])
|
||||
|
||||
|
|
Loading…
Reference in a new issue