diff --git a/material/plugins/search/plugin.py b/material/plugins/search/plugin.py index 19e93fbff..71da0cb50 100644 --- a/material/plugins/search/plugin.py +++ b/material/plugins/search/plugin.py @@ -56,7 +56,7 @@ class SearchIndex(BaseIndex): else: log.warning( "Skipping 'tags' due to invalid syntax [%s]: %s", - page.file.src_path, + page.file.src_uri, page.meta["tags"] ) diff --git a/material/plugins/social/plugin.py b/material/plugins/social/plugin.py index ba02883ef..290485663 100644 --- a/material/plugins/social/plugin.py +++ b/material/plugins/social/plugin.py @@ -31,6 +31,7 @@ from mkdocs.commands.build import DuplicateFilter from mkdocs.config.base import Config from mkdocs.config import config_options as opt from mkdocs.plugins import BasePlugin +import posixpath from shutil import copyfile from tempfile import TemporaryFile from zipfile import ZipFile @@ -245,7 +246,7 @@ class SocialPlugin(BasePlugin[SocialPluginConfig]): # Generate meta tags def _generate_meta(self, page, config): directory = self.config.cards_dir - file, _ = os.path.splitext(page.file.src_path) + file, _ = os.path.splitext(page.file.src_uri) # Compute page title title = page.meta.get("title", page.title) @@ -258,7 +259,7 @@ class SocialPlugin(BasePlugin[SocialPluginConfig]): description = page.meta["description"] # Resolve image URL - url = "{}.png".format(os.path.join( + url = "{}.png".format(posixpath.join( config.site_url, directory, file diff --git a/material/plugins/tags/plugin.py b/material/plugins/tags/plugin.py index f4c55c47f..69f9e2514 100644 --- a/material/plugins/tags/plugin.py +++ b/material/plugins/tags/plugin.py @@ -121,11 +121,9 @@ class TagsPlugin(BasePlugin[TagsPluginConfig]): content = [f"## {tag}", ""] for page in pages: - # Ensure forward slashes, as we have to use the path of the source - # file which contains the operating system's path separator. url = utils.get_relative_url( - page.file.src_path.replace(os.path.sep, "/"), - self.tags_file.src_path.replace(os.path.sep, "/") + page.file.src_uri, + self.tags_file.src_uri ) # Render link to page diff --git a/src/plugins/search/plugin.py b/src/plugins/search/plugin.py index 19e93fbff..71da0cb50 100644 --- a/src/plugins/search/plugin.py +++ b/src/plugins/search/plugin.py @@ -56,7 +56,7 @@ class SearchIndex(BaseIndex): else: log.warning( "Skipping 'tags' due to invalid syntax [%s]: %s", - page.file.src_path, + page.file.src_uri, page.meta["tags"] ) diff --git a/src/plugins/social/plugin.py b/src/plugins/social/plugin.py index ba02883ef..290485663 100644 --- a/src/plugins/social/plugin.py +++ b/src/plugins/social/plugin.py @@ -31,6 +31,7 @@ from mkdocs.commands.build import DuplicateFilter from mkdocs.config.base import Config from mkdocs.config import config_options as opt from mkdocs.plugins import BasePlugin +import posixpath from shutil import copyfile from tempfile import TemporaryFile from zipfile import ZipFile @@ -245,7 +246,7 @@ class SocialPlugin(BasePlugin[SocialPluginConfig]): # Generate meta tags def _generate_meta(self, page, config): directory = self.config.cards_dir - file, _ = os.path.splitext(page.file.src_path) + file, _ = os.path.splitext(page.file.src_uri) # Compute page title title = page.meta.get("title", page.title) @@ -258,7 +259,7 @@ class SocialPlugin(BasePlugin[SocialPluginConfig]): description = page.meta["description"] # Resolve image URL - url = "{}.png".format(os.path.join( + url = "{}.png".format(posixpath.join( config.site_url, directory, file diff --git a/src/plugins/tags/plugin.py b/src/plugins/tags/plugin.py index f4c55c47f..69f9e2514 100644 --- a/src/plugins/tags/plugin.py +++ b/src/plugins/tags/plugin.py @@ -121,11 +121,9 @@ class TagsPlugin(BasePlugin[TagsPluginConfig]): content = [f"## {tag}", ""] for page in pages: - # Ensure forward slashes, as we have to use the path of the source - # file which contains the operating system's path separator. url = utils.get_relative_url( - page.file.src_path.replace(os.path.sep, "/"), - self.tags_file.src_path.replace(os.path.sep, "/") + page.file.src_uri, + self.tags_file.src_uri ) # Render link to page