1
0
mirror of https://github.com/squidfunk/mkdocs-material.git synced 2024-11-28 01:10:58 +01:00

MkDocs upgrade: refactor path handling

This commit is contained in:
Oleh Prypin 2022-09-18 23:18:11 +02:00 committed by Martin Donath
parent 02bcffa6a8
commit c383892aae
6 changed files with 12 additions and 14 deletions

View File

@ -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"]
)

View File

@ -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

View File

@ -121,11 +121,9 @@ class TagsPlugin(BasePlugin[TagsPluginConfig]):
content = [f"## <span class=\"{classes}\">{tag}</span>", ""]
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

View File

@ -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"]
)

View File

@ -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

View File

@ -121,11 +121,9 @@ class TagsPlugin(BasePlugin[TagsPluginConfig]):
content = [f"## <span class=\"{classes}\">{tag}</span>", ""]
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