Skip to content

Commit 04f177c

Browse files
authored
Improved resilience of tags plugin (#7098)
1 parent bde889f commit 04f177c

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/plugins/tags/plugin.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,10 @@ def on_page_markdown(self, markdown, page, config, files):
9797
return self._render_tag_index(markdown)
9898

9999
# Add page to tags index
100-
for tag in page.meta.get("tags", []):
101-
self.tags[tag].append(page)
100+
tags = page.meta.get("tags", [])
101+
if tags:
102+
for tag in tags:
103+
self.tags[tag].append(page)
102104

103105
# Inject tags into page (after search and before minification)
104106
def on_page_context(self, context, page, config, nav):
@@ -110,7 +112,8 @@ def on_page_context(self, context, page, config, nav):
110112
return
111113

112114
# Provide tags for page
113-
if "tags" in page.meta:
115+
context["tags"] =[]
116+
if "tags" in page.meta and page.meta["tags"]:
114117
context["tags"] = [
115118
self._render_tag(tag)
116119
for tag in page.meta["tags"]

0 commit comments

Comments
 (0)