diff --git a/material/plugins/blog/plugin.py b/material/plugins/blog/plugin.py index 369d725cd..542bc4b2f 100644 --- a/material/plugins/blog/plugin.py +++ b/material/plugins/blog/plugin.py @@ -411,16 +411,18 @@ class BlogPlugin(BasePlugin[BlogConfig]): path = self.config.authors_file.format(blog = self.config.blog_dir) path = os.path.normpath(path) - # If the authors file does not exist, return an empty dictionary + # Resolve path relative to docs directory docs = os.path.relpath(config.docs_dir) file = os.path.join(docs, path) + + # If the authors file does not exist, return here + config: Authors = Authors() if not os.path.isfile(file): - authors: dict[str, Author] = {} - return authors + return config.authors # Open file and parse as YAML with open(file, encoding = "utf-8") as f: - config: Authors = Authors(os.path.abspath(file)) + config.config_file_path = os.path.abspath(file) try: config.load_dict(yaml.load(f, SafeLoader) or {}) diff --git a/material/plugins/blog/structure/__init__.py b/material/plugins/blog/structure/__init__.py index 71f8724dd..ae202c3e2 100644 --- a/material/plugins/blog/structure/__init__.py +++ b/material/plugins/blog/structure/__init__.py @@ -52,7 +52,7 @@ class Post(Page): def __init__(self, file: File, config: MkDocsConfig): super().__init__(None, file, config) - # Resolve path relative to docs directory for error reporting + # Resolve path relative to docs directory docs = os.path.relpath(config.docs_dir) path = os.path.relpath(file.abs_src_path, docs) diff --git a/src/plugins/blog/plugin.py b/src/plugins/blog/plugin.py index 369d725cd..542bc4b2f 100644 --- a/src/plugins/blog/plugin.py +++ b/src/plugins/blog/plugin.py @@ -411,16 +411,18 @@ class BlogPlugin(BasePlugin[BlogConfig]): path = self.config.authors_file.format(blog = self.config.blog_dir) path = os.path.normpath(path) - # If the authors file does not exist, return an empty dictionary + # Resolve path relative to docs directory docs = os.path.relpath(config.docs_dir) file = os.path.join(docs, path) + + # If the authors file does not exist, return here + config: Authors = Authors() if not os.path.isfile(file): - authors: dict[str, Author] = {} - return authors + return config.authors # Open file and parse as YAML with open(file, encoding = "utf-8") as f: - config: Authors = Authors(os.path.abspath(file)) + config.config_file_path = os.path.abspath(file) try: config.load_dict(yaml.load(f, SafeLoader) or {}) diff --git a/src/plugins/blog/structure/__init__.py b/src/plugins/blog/structure/__init__.py index 71f8724dd..ae202c3e2 100644 --- a/src/plugins/blog/structure/__init__.py +++ b/src/plugins/blog/structure/__init__.py @@ -52,7 +52,7 @@ class Post(Page): def __init__(self, file: File, config: MkDocsConfig): super().__init__(None, file, config) - # Resolve path relative to docs directory for error reporting + # Resolve path relative to docs directory docs = os.path.relpath(config.docs_dir) path = os.path.relpath(file.abs_src_path, docs)