From 1ace46a7bdb0153821823e67e319539c218c86bf Mon Sep 17 00:00:00 2001 From: Adrien Dupuis <61695653+adriendupuis@users.noreply.github.com> Date: Wed, 13 Nov 2024 17:48:05 +0100 Subject: [PATCH] main.py: get version from abs URL The canonical URL seems to always be the "latest" version. So, previously, version was always "latest" even when on another version (like "master" for example), potentially generating a broken link. --- main.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/main.py b/main.py index 2b140533b4..6091cfe254 100644 --- a/main.py +++ b/main.py @@ -50,6 +50,9 @@ def cards(pages, columns=1, style="cards", force_version=False): canonical = current_page.canonical_url url_parts = re.search("//([^/]+)/([^/]+)/([^/]+)/", canonical) (site, language, version) = url_parts.groups() + url_parts = re.search("^/([^/]+)/([^/]+)/", absolute_url) + (language, version) = url_parts.groups() + version = force_version or version if isinstance(pages, str):