Skip to content

Commit 03eb422

Browse files
committed
Improving friendly archive names.
1 parent 339171d commit 03eb422

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

nikola/plugins/task/archive.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,20 @@ def get_classification_friendly_name(self, classification, lang, only_last_compo
9797
elif len(classification) == 1:
9898
return classification[0]
9999
elif len(classification) == 2:
100-
return nikola.utils.LocaleBorg().get_month_name(int(classification[1]), lang)
100+
month = nikola.utils.LocaleBorg().get_month_name(int(classification[1]), lang)
101+
if only_last_component:
102+
return month
103+
else:
104+
year = classification[0]
105+
return self.site.MESSAGES[lang].get('{month} {year}', '{month} {year}').format(year=year, month=month)
101106
else:
102-
# Fallback
103-
return '/'.join(classification)
107+
day = int(classification[2])
108+
if only_last_component:
109+
return str(day)
110+
else:
111+
year = classification[0]
112+
month = nikola.utils.LocaleBorg().get_month_name(int(classification[1]), lang)
113+
return self.site.MESSAGES[lang].get('{month} {day}, {year}', '{month} {day}, {year}').format(year=year, month=month, day=day)
104114

105115
def get_path(self, classification, lang, dest_type='page'):
106116
"""A path handler for the given classification."""

0 commit comments

Comments
 (0)