Fixed deprecation warning in privacy plugin

This commit is contained in:
squidfunk 2024-04-29 08:01:57 +07:00
parent cff4a75d15
commit ff49d74024
No known key found for this signature in database
GPG Key ID: 5ED40BC4F9C436DF
2 changed files with 8 additions and 4 deletions

View File

@ -363,8 +363,10 @@ class PrivacyPlugin(BasePlugin[PrivacyConfig]):
else:
self._fetch(file, config)
# Register external asset as file
self.assets.append(file)
# Register external asset as file - it might have already been
# registered, and since MkDocs 1.6, trigger a deprecation warning
if not self.assets.get_file_from_path(file.src_uri):
self.assets.append(file)
# If the URL of the external asset includes a hash fragment, add it to
# the returned file, e.g. for dark/light images - see https://t.ly/7b16Y

View File

@ -363,8 +363,10 @@ class PrivacyPlugin(BasePlugin[PrivacyConfig]):
else:
self._fetch(file, config)
# Register external asset as file
self.assets.append(file)
# Register external asset as file - it might have already been
# registered, and since MkDocs 1.6, trigger a deprecation warning
if not self.assets.get_file_from_path(file.src_uri):
self.assets.append(file)
# If the URL of the external asset includes a hash fragment, add it to
# the returned file, e.g. for dark/light images - see https://t.ly/7b16Y