Skip to content

Commit beffab6

Browse files
committed
Use page.file.src_uri in relativize_links()
1 parent ce1cbd3 commit beffab6

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

mkdocs_snippets/plugin.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def resolve_snippet(self, markdown: str, page: Page) -> str:
8282

8383
snippet_content = self.snippets[snippet_address][snippet_id]
8484

85-
snippet_content = relativize_links(snippet_content, page.abs_url, snippet_id)
85+
snippet_content = relativize_links(snippet_content, page.file.src_uri, snippet_id)
8686

8787
snippet_content = self.preserve_indentation(snippet_content, markdown)
8888

@@ -143,11 +143,7 @@ def relativize_links(snippet_content, current_path, snippet_id) -> str:
143143
link_without_filetype = link_and_filetype[0]
144144
filetype = link_and_filetype[1]
145145

146-
if current_path is None:
147-
# The docs are hosted in the root
148-
current_path_without_filename = ''
149-
else:
150-
current_path_without_filename = current_path.rsplit("/", 2)[0]
146+
current_path_without_filename = current_path.rsplit("/", 2)[0]
151147

152148
current_path_without_filename = remove_mike_version_from_path(current_path_without_filename)
153149

0 commit comments

Comments
 (0)