Skip to content

Commit 0070200

Browse files
committed
Fix fallback option for git_page_authors
1 parent f8aa9d2 commit 0070200

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

mkdocs_git_authors_plugin/plugin.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,16 +149,17 @@ def on_page_content(self, html, page, config, files, **kwargs):
149149
)
150150

151151
# Replace {{ git_page_authors }}
152-
page_obj = self.repo().page(page.file.abs_src_path)
153-
page_authors = util.page_authors_summary(page_obj, self.config)
152+
if self._fallback:
153+
page_authors = ""
154+
else:
155+
page_obj = self.repo().page(page.file.abs_src_path)
156+
page_authors = util.page_authors_summary(page_obj, self.config)
154157

155158
list_pattern = re.compile(
156159
r"\{\{\s*git_page_authors\s*\}\}", flags=re.IGNORECASE
157160
)
158161
if list_pattern.search(html):
159-
html = list_pattern.sub(
160-
"" if self._fallback else page_authors, html
161-
)
162+
html = list_pattern.sub(page_authors, html)
162163

163164
return html
164165

tests/test_basic.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ def test_fallback(tmp_path):
249249
result = build_docs_setup(
250250
str(testproject_path / "website/mkdocs.yml"), str(testproject_path / "site")
251251
)
252+
# import pdb; pdb.set_trace()
252253
assert result.exit_code == 0, (
253254
"'mkdocs build' command failed. Error: %s" % result.stdout
254255
)

0 commit comments

Comments
 (0)