Skip to content

Commit 18d6ce6

Browse files
committed
Use a template method for title
Set title in the base class, using the `title` method that must be implemented in all subclasses.
1 parent 35acd26 commit 18d6ce6

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

_plugins/news.rb

+5-3
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,17 @@ def initialize(site, base, subdir, lang, posts)
2525
data["lang"] = lang
2626
data["posts"] = posts.reverse
2727
data["layout"] = layout
28+
data["title"] = title
2829
end
2930

3031
def layout
3132
raise NotImplementedError
3233
end
3334

35+
def title
36+
raise NotImplementedError
37+
end
38+
3439
def locales
3540
site.data["locales"][lang]["news"] ||
3641
site.data["locales"]["en"]["news"]
@@ -64,7 +69,6 @@ def initialize(site, base, lang, year, month, posts)
6469
subdir = File.join(year.to_s, "%.2d" % month)
6570
super(site, base, subdir, lang, posts)
6671

67-
data["title"] = title
6872
data["year"] = year
6973
end
7074

@@ -87,7 +91,6 @@ def initialize(site, base, lang, year, posts)
8791
subdir = year.to_s
8892
super(site, base, subdir, lang, posts)
8993

90-
data["title"] = title
9194
data["year"] = year
9295

9396
months = posts.map {|post| post.date.month }.uniq
@@ -118,7 +121,6 @@ def initialize(site, base, lang, posts)
118121
subdir = nil
119122
super(site, base, subdir, lang, posts)
120123

121-
data["title"] = title
122124
data["posts"] = posts.last(MAX_POSTS).reverse
123125

124126
years = posts.map {|post| post.date.year }.uniq.reverse

0 commit comments

Comments
 (0)