Skip to content

Commit ba90cb1

Browse files
committed
Added missing enabled setting for tags plugin
1 parent c0cdb3c commit ba90cb1

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

Diff for: material/plugins/tags/plugin.py

+19-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
# IN THE SOFTWARE.
2020

2121
import logging
22-
import os
2322
import sys
2423

2524
from collections import defaultdict
@@ -36,6 +35,9 @@
3635

3736
# Tags plugin configuration scheme
3837
class TagsPluginConfig(Config):
38+
enabled = opt.Type(bool, default = True)
39+
40+
# Options for tags
3941
tags_file = opt.Optional(opt.Type(str))
4042

4143
# -----------------------------------------------------------------------------
@@ -46,6 +48,10 @@ class TagsPlugin(BasePlugin[TagsPluginConfig]):
4648

4749
# Initialize plugin
4850
def on_config(self, config):
51+
if not self.config.enabled:
52+
return
53+
54+
# Initialize tags
4955
self.tags = defaultdict(list)
5056
self.tags_file = None
5157

@@ -64,12 +70,20 @@ def on_config(self, config):
6470

6571
# Hack: 2nd pass for tags index page(s)
6672
def on_nav(self, nav, config, files):
73+
if not self.config.enabled:
74+
return
75+
76+
# Resolve tags index page
6777
file = self.config.tags_file
6878
if file:
6979
self.tags_file = self._get_tags_file(files, file)
7080

7181
# Build and render tags index page
7282
def on_page_markdown(self, markdown, page, config, files):
83+
if not self.config.enabled:
84+
return
85+
86+
# Render tags index page
7387
if page.file == self.tags_file:
7488
return self._render_tag_index(markdown)
7589

@@ -79,6 +93,10 @@ def on_page_markdown(self, markdown, page, config, files):
7993

8094
# Inject tags into page (after search and before minification)
8195
def on_page_context(self, context, page, config, nav):
96+
if not self.config.enabled:
97+
return
98+
99+
# Provide tags for page
82100
if "tags" in page.meta:
83101
context["tags"] = [
84102
self._render_tag(tag)

Diff for: src/plugins/tags/plugin.py

+19-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
# IN THE SOFTWARE.
2020

2121
import logging
22-
import os
2322
import sys
2423

2524
from collections import defaultdict
@@ -36,6 +35,9 @@
3635

3736
# Tags plugin configuration scheme
3837
class TagsPluginConfig(Config):
38+
enabled = opt.Type(bool, default = True)
39+
40+
# Options for tags
3941
tags_file = opt.Optional(opt.Type(str))
4042

4143
# -----------------------------------------------------------------------------
@@ -46,6 +48,10 @@ class TagsPlugin(BasePlugin[TagsPluginConfig]):
4648

4749
# Initialize plugin
4850
def on_config(self, config):
51+
if not self.config.enabled:
52+
return
53+
54+
# Initialize tags
4955
self.tags = defaultdict(list)
5056
self.tags_file = None
5157

@@ -64,12 +70,20 @@ def on_config(self, config):
6470

6571
# Hack: 2nd pass for tags index page(s)
6672
def on_nav(self, nav, config, files):
73+
if not self.config.enabled:
74+
return
75+
76+
# Resolve tags index page
6777
file = self.config.tags_file
6878
if file:
6979
self.tags_file = self._get_tags_file(files, file)
7080

7181
# Build and render tags index page
7282
def on_page_markdown(self, markdown, page, config, files):
83+
if not self.config.enabled:
84+
return
85+
86+
# Render tags index page
7387
if page.file == self.tags_file:
7488
return self._render_tag_index(markdown)
7589

@@ -79,6 +93,10 @@ def on_page_markdown(self, markdown, page, config, files):
7993

8094
# Inject tags into page (after search and before minification)
8195
def on_page_context(self, context, page, config, nav):
96+
if not self.config.enabled:
97+
return
98+
99+
# Provide tags for page
82100
if "tags" in page.meta:
83101
context["tags"] = [
84102
self._render_tag(tag)

0 commit comments

Comments
 (0)