This commit is contained in:
Andreas Klöckner 2018-04-13 17:20:28 +00:00 committed by GitHub
commit 39c062007c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View file

@ -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

View file

@ -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":