Skip to content

Commit b41051d

Browse files
committed
fix missing tags not exposed in jinja2 environment
1 parent 78b9e1c commit b41051d

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

mkdocs_git_authors_plugin/plugin.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def on_page_content(self, html, page, config, files, **kwargs):
104104

105105
def on_page_markdown(self, markdown, page, config, files):
106106
"""
107-
Replace jinja tag {{ git_authors_summary }} in markdown.
107+
Replace jinja tags in markdown.
108108
109109
The page_markdown event is called after the page's markdown is loaded
110110
from file and can be used to alter the Markdown source text.
@@ -168,6 +168,9 @@ def on_page_context(self, context, page, config, nav, **kwargs):
168168
path = page.file.abs_src_path
169169
page_obj = self.repo().page(path)
170170
authors = page_obj.get_authors()
171+
172+
page_authors = util.page_authors_summary(page_obj, self.config)
173+
site_authors = util.site_authors_summary(self.repo().get_authors(), self.config)
171174

172175
# NOTE: last_datetime is currently given as a
173176
# string in the format
@@ -176,14 +179,17 @@ def on_page_context(self, context, page, config, nav, **kwargs):
176179
# datetime.datetime object with tzinfo instead.
177180
# Should this be formatted differently?
178181
context["git_info"] = {
179-
"page_authors": util.page_authors_summary(page_obj, self.config),
180-
"site_authors": util.site_authors_summary(
181-
self.repo().get_authors(), self.config
182-
),
182+
"page_authors": util.page_authors(authors, path),
183+
"site_authors": util.page_authors(self.repo().get_authors(), path),
183184
}
184185

186+
# Make available the same markdown tags in jinja context
187+
context["git_page_authors"] = page_authors
188+
context["git_site_authors"] = site_authors
189+
185190
# For backward compatibility, deprecate in 1.2
186191
context["git_authors"] = util.page_authors(authors, path)
192+
context["git_authors_summary"] = page_authors
187193

188194
return context
189195

mkdocs_git_authors_plugin/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def site_authors_summary(authors, config: dict):
114114

115115
def page_authors(authors, path):
116116
"""List of dicts with info on page authors
117-
117+
# TODO: rename to something more representative like 'authors_to_dict()'
118118
Args:
119119
authors (list): list with Author classes
120120
path (str): path to page

0 commit comments

Comments
 (0)