Skip to content

Commit 1ace46a

Browse files
committed
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.
1 parent a5e07fe commit 1ace46a

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

main.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ def cards(pages, columns=1, style="cards", force_version=False):
5050
canonical = current_page.canonical_url
5151
url_parts = re.search("//([^/]+)/([^/]+)/([^/]+)/", canonical)
5252
(site, language, version) = url_parts.groups()
53+
url_parts = re.search("^/([^/]+)/([^/]+)/", absolute_url)
54+
(language, version) = url_parts.groups()
55+
5356
version = force_version or version
5457

5558
if isinstance(pages, str):

0 commit comments

Comments
 (0)