mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
Fixed draft blog posts appearing in tags index
This commit is contained in:
parent
04f1b33571
commit
15c024cbbf
@ -34,9 +34,9 @@ from lxml.html import fragment_fromstring, tostring
|
||||
from mkdocs import utils
|
||||
from mkdocs.utils.meta import get_data
|
||||
from mkdocs.commands.build import _populate_page
|
||||
from mkdocs.contrib.search import SearchIndex
|
||||
from mkdocs.contrib.search.search_index import SearchIndex
|
||||
from mkdocs.plugins import BasePlugin
|
||||
from mkdocs.structure.files import File, Files
|
||||
from mkdocs.structure.files import File, Files, InclusionLevel
|
||||
from mkdocs.structure.nav import Link, Section
|
||||
from mkdocs.structure.pages import Page
|
||||
from tempfile import gettempdir
|
||||
@ -234,6 +234,10 @@ class BlogPlugin(BasePlugin[BlogConfig]):
|
||||
# Add post metadata
|
||||
self.post_meta_map[file.src_uri] = meta
|
||||
|
||||
# Mark page as excluded, so it's not picked up by other plugins
|
||||
if not self.config.draft and self._is_draft(file.src_uri):
|
||||
file.inclusion = InclusionLevel.EXCLUDED
|
||||
|
||||
# Sort post metadata by date (descending)
|
||||
self.post_meta_map = dict(sorted(
|
||||
self.post_meta_map.items(),
|
||||
|
@ -76,6 +76,10 @@ class TagsPlugin(BasePlugin[TagsConfig]):
|
||||
if not self.config.enabled:
|
||||
return
|
||||
|
||||
# Skip, if page is excluded
|
||||
if page.file.inclusion.is_excluded():
|
||||
return
|
||||
|
||||
# Render tags index page
|
||||
if page.file == self.tags_file:
|
||||
return self._render_tag_index(markdown)
|
||||
|
@ -34,9 +34,9 @@ from lxml.html import fragment_fromstring, tostring
|
||||
from mkdocs import utils
|
||||
from mkdocs.utils.meta import get_data
|
||||
from mkdocs.commands.build import _populate_page
|
||||
from mkdocs.contrib.search import SearchIndex
|
||||
from mkdocs.contrib.search.search_index import SearchIndex
|
||||
from mkdocs.plugins import BasePlugin
|
||||
from mkdocs.structure.files import File, Files
|
||||
from mkdocs.structure.files import File, Files, InclusionLevel
|
||||
from mkdocs.structure.nav import Link, Section
|
||||
from mkdocs.structure.pages import Page
|
||||
from tempfile import gettempdir
|
||||
@ -234,6 +234,10 @@ class BlogPlugin(BasePlugin[BlogConfig]):
|
||||
# Add post metadata
|
||||
self.post_meta_map[file.src_uri] = meta
|
||||
|
||||
# Mark page as excluded, so it's not picked up by other plugins
|
||||
if not self.config.draft and self._is_draft(file.src_uri):
|
||||
file.inclusion = InclusionLevel.EXCLUDED
|
||||
|
||||
# Sort post metadata by date (descending)
|
||||
self.post_meta_map = dict(sorted(
|
||||
self.post_meta_map.items(),
|
||||
|
@ -76,6 +76,10 @@ class TagsPlugin(BasePlugin[TagsConfig]):
|
||||
if not self.config.enabled:
|
||||
return
|
||||
|
||||
# Skip, if page is excluded
|
||||
if page.file.inclusion.is_excluded():
|
||||
return
|
||||
|
||||
# Render tags index page
|
||||
if page.file == self.tags_file:
|
||||
return self._render_tag_index(markdown)
|
||||
|
Loading…
Reference in New Issue
Block a user