1
0
mirror of https://github.com/squidfunk/mkdocs-material.git synced 2024-11-13 18:40:54 +01:00

Added missing tags setting in tags plugin

This commit is contained in:
squidfunk 2023-09-10 15:56:53 +02:00
parent 2a131caad6
commit e3d5fd2eb3
No known key found for this signature in database
GPG Key ID: 5ED40BC4F9C436DF
4 changed files with 34 additions and 0 deletions

View File

@ -34,6 +34,7 @@ class TagsConfig(Config):
enabled = Type(bool, default = True) enabled = Type(bool, default = True)
# Settings for tags # Settings for tags
tags = Type(bool, default = True)
tags_file = Optional(Type(str)) tags_file = Optional(Type(str))
tags_extra_files = Type(dict, default = {}) tags_extra_files = Type(dict, default = {})
tags_slugify = Type((type(slugify), partial), default = slugify) tags_slugify = Type((type(slugify), partial), default = slugify)

View File

@ -44,6 +44,10 @@ class TagsPlugin(BasePlugin[TagsConfig]):
if not self.config.enabled: if not self.config.enabled:
return return
# Skip if tags should not be built
if not self.config.tags:
return
# Initialize tags # Initialize tags
self.tags = defaultdict(list) self.tags = defaultdict(list)
self.tags_file = None self.tags_file = None
@ -66,6 +70,10 @@ class TagsPlugin(BasePlugin[TagsConfig]):
if not self.config.enabled: if not self.config.enabled:
return return
# Skip if tags should not be built
if not self.config.tags:
return
# Resolve tags index page # Resolve tags index page
file = self.config.tags_file file = self.config.tags_file
if file: if file:
@ -76,6 +84,10 @@ class TagsPlugin(BasePlugin[TagsConfig]):
if not self.config.enabled: if not self.config.enabled:
return return
# Skip if tags should not be built
if not self.config.tags:
return
# Skip, if page is excluded # Skip, if page is excluded
if page.file.inclusion.is_excluded(): if page.file.inclusion.is_excluded():
return return
@ -93,6 +105,10 @@ class TagsPlugin(BasePlugin[TagsConfig]):
if not self.config.enabled: if not self.config.enabled:
return return
# Skip if tags should not be built
if not self.config.tags:
return
# Provide tags for page # Provide tags for page
if "tags" in page.meta: if "tags" in page.meta:
context["tags"] = [ context["tags"] = [

View File

@ -34,6 +34,7 @@ class TagsConfig(Config):
enabled = Type(bool, default = True) enabled = Type(bool, default = True)
# Settings for tags # Settings for tags
tags = Type(bool, default = True)
tags_file = Optional(Type(str)) tags_file = Optional(Type(str))
tags_extra_files = Type(dict, default = {}) tags_extra_files = Type(dict, default = {})
tags_slugify = Type((type(slugify), partial), default = slugify) tags_slugify = Type((type(slugify), partial), default = slugify)

View File

@ -44,6 +44,10 @@ class TagsPlugin(BasePlugin[TagsConfig]):
if not self.config.enabled: if not self.config.enabled:
return return
# Skip if tags should not be built
if not self.config.tags:
return
# Initialize tags # Initialize tags
self.tags = defaultdict(list) self.tags = defaultdict(list)
self.tags_file = None self.tags_file = None
@ -66,6 +70,10 @@ class TagsPlugin(BasePlugin[TagsConfig]):
if not self.config.enabled: if not self.config.enabled:
return return
# Skip if tags should not be built
if not self.config.tags:
return
# Resolve tags index page # Resolve tags index page
file = self.config.tags_file file = self.config.tags_file
if file: if file:
@ -76,6 +84,10 @@ class TagsPlugin(BasePlugin[TagsConfig]):
if not self.config.enabled: if not self.config.enabled:
return return
# Skip if tags should not be built
if not self.config.tags:
return
# Skip, if page is excluded # Skip, if page is excluded
if page.file.inclusion.is_excluded(): if page.file.inclusion.is_excluded():
return return
@ -93,6 +105,10 @@ class TagsPlugin(BasePlugin[TagsConfig]):
if not self.config.enabled: if not self.config.enabled:
return return
# Skip if tags should not be built
if not self.config.tags:
return
# Provide tags for page # Provide tags for page
if "tags" in page.meta: if "tags" in page.meta:
context["tags"] = [ context["tags"] = [