Skip to content

Commit

Permalink
Inserting navigation archive names.
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfontein committed Dec 26, 2016
1 parent 372932b commit 8ee8349
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion nikola/plugins/task/archive.py
Expand Up @@ -174,9 +174,12 @@ def provide_context_and_uptodate(self, classification, lang, node=None):
if hierarchy:
# Up level link makes sense only if this is not the top-level
# page (hierarchy is empty)
context["up_archive"] = self.site.link('archive', '/'.join(hierarchy[:-1]), lang)
parent = '/'.join(hierarchy[:-1])
context["up_archive"] = self.site.link('archive', parent, lang)
context["up_archive_name"] = self.get_classification_friendly_name(parent, lang)
else:
context["up_archive"] = None
context["up_archive_name"] = None

nodelevel = len(hierarchy)
flat_samelevel = self.archive_navigation[lang][nodelevel]
Expand All @@ -186,7 +189,9 @@ def provide_context_and_uptodate(self, classification, lang, node=None):
previdx, nextidx = idx - 1, idx + 1
# If the previous index is -1, or the next index is 1, the previous/next archive does not exist.
context["previous_archive"] = self.site.link('archive', flat_samelevel[previdx], lang) if previdx != -1 else None
context["previous_archive_name"] = self.get_classification_friendly_name(flat_samelevel[previdx], lang) if previdx != -1 else None
context["next_archive"] = self.site.link('archive', flat_samelevel[nextidx], lang) if nextidx != len(flat_samelevel) else None
context["next_archive_name"] = self.get_classification_friendly_name(flat_samelevel[nextidx], lang) if nextidx != len(flat_samelevel) else None
context["archive_nodelevel"] = nodelevel
context["has_archive_navigation"] = bool(context["previous_archive"] or context["up_archive"] or context["next_archive"])
else:
Expand Down

0 comments on commit 8ee8349

Please sign in to comment.