mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Add ARTICLE_RESTRICT_TO_TAGS setting
This commit is contained in:
parent
3656df50a5
commit
b49a0500e0
2 changed files with 13 additions and 0 deletions
|
|
@ -179,6 +179,12 @@ Basic settings
|
|||
A list of directories to exclude when looking for articles in addition to
|
||||
``PAGE_PATHS``.
|
||||
|
||||
.. data:: ARTICLE_RESTRICT_TO_TAGS = []
|
||||
|
||||
All articles that do not have all tags in this list will be excluded from
|
||||
the output. This is useful, for example, for generating multiple versions
|
||||
of a site with overlapping content--e.g. a professional and a personal one.
|
||||
|
||||
.. data:: OUTPUT_SOURCES = False
|
||||
|
||||
Set to True if you want to copy the articles and pages in their original
|
||||
|
|
|
|||
|
|
@ -564,6 +564,9 @@ class ArticlesGenerator(CachingGenerator):
|
|||
def generate_context(self):
|
||||
"""Add the articles into the shared context"""
|
||||
|
||||
restrict_all_articles_to_tags = set(
|
||||
self.settings.get("ARTICLES_RESTRICT_TO_TAGS", []))
|
||||
|
||||
all_articles = []
|
||||
all_drafts = []
|
||||
for f in self.get_files(
|
||||
|
|
@ -592,6 +595,10 @@ class ArticlesGenerator(CachingGenerator):
|
|||
|
||||
self.cache_data(f, article)
|
||||
|
||||
if not restrict_all_articles_to_tags <= set(
|
||||
getattr(article, 'tags', [])):
|
||||
continue
|
||||
|
||||
if article.status == "published":
|
||||
all_articles.append(article)
|
||||
elif article.status == "draft":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue