Skip to content

Commit 3a811b8

Browse files
committedApr 24, 2017
Avoid empty subarchive pages. Fix archive navigation.
1 parent 75ba0bc commit 3a811b8

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed
 

‎nikola/plugins/task/archive.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def provide_context_and_uptodate(self, classification, lang, node=None):
219219
kw.update(context)
220220
return context, kw
221221

222-
def postprocess_posts_per_classification(self, posts_per_section_per_language, flat_hierarchy_per_lang=None, hierarchy_lookup_per_lang=None):
222+
def postprocess_posts_per_classification(self, posts_per_archive_per_language, flat_hierarchy_per_lang=None, hierarchy_lookup_per_lang=None):
223223
"""Rearrange, modify or otherwise use the list of posts per classification and per language."""
224224
# Build a lookup table for archive navigation, if we’ll need one.
225225
if self.site.config['CREATE_ARCHIVE_NAVIGATION']:
@@ -229,14 +229,17 @@ def postprocess_posts_per_classification(self, posts_per_section_per_language, f
229229
for lang, flat_hierarchy in flat_hierarchy_per_lang.items():
230230
self.archive_navigation[lang] = defaultdict(list)
231231
for node in flat_hierarchy:
232+
if not self.site.config["SHOW_UNTRANSLATED_POSTS"]:
233+
if not [x for x in posts_per_archive_per_language[lang][node.classification_name] if x.is_translation_available(lang)]:
234+
continue
232235
self.archive_navigation[lang][len(node.classification_path)].append(node.classification_name)
233236

234237
# We need to sort it. Natsort means it’s year 10000 compatible!
235238
for k, v in self.archive_navigation[lang].items():
236239
self.archive_navigation[lang][k] = natsort.natsorted(v, alg=natsort.ns.F | natsort.ns.IC)
237240

238-
return super(Archive, self).postprocess_posts_per_classification(posts_per_section_per_language, flat_hierarchy_per_lang, hierarchy_lookup_per_lang)
241+
return super(Archive, self).postprocess_posts_per_classification(posts_per_archive_per_language, flat_hierarchy_per_lang, hierarchy_lookup_per_lang)
239242

240243
def should_generate_classification_page(self, classification, post_list, lang):
241244
"""Only generates list of posts for classification if this function returns True."""
242-
return len(classification.split('/')) < 3 or len(post_list) > 0
245+
return classification = '' or len(post_list) > 0

0 commit comments

Comments
 (0)
Please sign in to comment.