1
0
mirror of https://github.com/squidfunk/mkdocs-material.git synced 2024-09-24 03:18:21 +02: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)
# Settings for tags
tags = Type(bool, default = True)
tags_file = Optional(Type(str))
tags_extra_files = Type(dict, default = {})
tags_slugify = Type((type(slugify), partial), default = slugify)

View File

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

View File

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

View File

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