@@ -76,15 +76,22 @@ def initialize(site,base,lang,year,posts)
76
76
@dir = File . join ( @dir , @year . to_s )
77
77
78
78
title = locales [ 'yearly_archive_title' ]
79
+ month_link_text = locales [ 'monthly_archive_link' ]
79
80
80
81
data [ 'title' ] = title . gsub ( '%Y' , @year . to_s )
82
+ data [ 'year' ] = @year
81
83
82
84
months = posts . map { |post | post . date . month } . uniq
83
85
84
- data [ 'year' ] = year
86
+ # hash with url => link_text (including year) elements
85
87
data [ 'months' ] = Hash [
86
88
months . map { |month | "%.2d" % month } . zip (
87
- months . map { |month | month_names [ month ] }
89
+ months . map { |month | month_link_text . gsub ( /%Y|%m|%B/ , {
90
+ '%Y' => @year . to_s ,
91
+ '%m' => "%.2d" % month ,
92
+ '%B' => month_names [ month ]
93
+ } )
94
+ }
88
95
)
89
96
]
90
97
end
@@ -101,10 +108,19 @@ def initialize(site,base,lang,posts)
101
108
super ( site , base , LAYOUT , lang , posts )
102
109
103
110
title = locales [ 'recent_news' ]
111
+ year_link_text = locales [ 'yearly_archive_link' ]
104
112
105
113
data [ 'title' ] = title
106
- data [ 'years' ] = posts . map { |post | post . date . year } . uniq . reverse
107
114
data [ 'posts' ] = posts . last ( MAX_POSTS ) . reverse
115
+
116
+ years = posts . map { |post | post . date . year } . uniq . reverse
117
+
118
+ # hash with url => link_text elements
119
+ data [ 'years' ] = Hash [
120
+ years . map { |year | year . to_s } . zip (
121
+ years . map { |year | year_link_text . gsub ( /%Y/ , '%Y' => year . to_s ) }
122
+ )
123
+ ]
108
124
end
109
125
110
126
end
0 commit comments