From 04f177cbd43238bd4ea345d35ef973a8b7590f0c Mon Sep 17 00:00:00 2001 From: godot42 <79260851+godotc@users.noreply.github.com> Date: Thu, 25 Apr 2024 10:33:32 +0800 Subject: [PATCH] Improved resilience of tags plugin (#7098) --- src/plugins/tags/plugin.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/plugins/tags/plugin.py b/src/plugins/tags/plugin.py index 6b2b529b6..084b59cb4 100644 --- a/src/plugins/tags/plugin.py +++ b/src/plugins/tags/plugin.py @@ -97,8 +97,10 @@ class TagsPlugin(BasePlugin[TagsConfig]): return self._render_tag_index(markdown) # Add page to tags index - for tag in page.meta.get("tags", []): - self.tags[tag].append(page) + tags = page.meta.get("tags", []) + if tags: + for tag in tags: + self.tags[tag].append(page) # Inject tags into page (after search and before minification) def on_page_context(self, context, page, config, nav): @@ -110,7 +112,8 @@ class TagsPlugin(BasePlugin[TagsConfig]): return # Provide tags for page - if "tags" in page.meta: + context["tags"] =[] + if "tags" in page.meta and page.meta["tags"]: context["tags"] = [ self._render_tag(tag) for tag in page.meta["tags"]