From 4759c7aaaf4681011bfa772ae0ad28f3b1f51a3a Mon Sep 17 00:00:00 2001 From: squidfunk Date: Mon, 21 Aug 2023 18:23:00 +0200 Subject: [PATCH] Fixed error when using git-revision-date-localized-plugin with blog --- material/plugins/blog/plugin.py | 12 +++++++++++- src/plugins/blog/plugin.py | 12 +++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/material/plugins/blog/plugin.py b/material/plugins/blog/plugin.py index 56fa5efd2..2d156390f 100644 --- a/material/plugins/blog/plugin.py +++ b/material/plugins/blog/plugin.py @@ -770,13 +770,23 @@ class BlogPlugin(BasePlugin[BlogConfig]): # either inside the temporary directory or the docs directory def _path_to_file(self, path: str, config: MkDocsConfig, *, temp = True): assert path.endswith(".md") - return File( + file = File( path, config.docs_dir if not temp else self.temp_dir, config.site_dir, config.use_directory_urls ) + # Hack: mark file as generated, so other plugins don't think it's part + # of the file system. This is more or less a new quasi-standard that + # still needs to be adopted by MkDocs, and was introduced by the + # git-revision-date-localized-plugin - see https://bit.ly/3ZUmdBx + if temp: + file.generated_by = "material/blog" + + # Return file + return file + # Write the content to the file located at the given path def _save_to_file(self, path: str, content: str): os.makedirs(os.path.dirname(path), exist_ok = True) diff --git a/src/plugins/blog/plugin.py b/src/plugins/blog/plugin.py index 56fa5efd2..2d156390f 100644 --- a/src/plugins/blog/plugin.py +++ b/src/plugins/blog/plugin.py @@ -770,13 +770,23 @@ class BlogPlugin(BasePlugin[BlogConfig]): # either inside the temporary directory or the docs directory def _path_to_file(self, path: str, config: MkDocsConfig, *, temp = True): assert path.endswith(".md") - return File( + file = File( path, config.docs_dir if not temp else self.temp_dir, config.site_dir, config.use_directory_urls ) + # Hack: mark file as generated, so other plugins don't think it's part + # of the file system. This is more or less a new quasi-standard that + # still needs to be adopted by MkDocs, and was introduced by the + # git-revision-date-localized-plugin - see https://bit.ly/3ZUmdBx + if temp: + file.generated_by = "material/blog" + + # Return file + return file + # Write the content to the file located at the given path def _save_to_file(self, path: str, content: str): os.makedirs(os.path.dirname(path), exist_ok = True)