@@ -54,7 +54,7 @@ class PostList(Directive):
54
54
Post List
55
55
=========
56
56
:Directive Arguments: None.
57
- :Directive Options: lang, start, stop, reverse, sort, tags, template, id
57
+ :Directive Options: lang, start, stop, reverse, sort, tags, categories, slugs, all, template, id
58
58
:Directive Content: None.
59
59
60
60
Provides a reStructuredText directive to create a list of posts.
@@ -87,6 +87,10 @@ class PostList(Directive):
87
87
Filter posts to show only posts having at least one of the ``tags``.
88
88
Defaults to None.
89
89
90
+ ``categories`` : string [, string...]
91
+ Filter posts to show only posts having one of the ``categories``.
92
+ Defaults to None.
93
+
90
94
``slugs`` : string [, string...]
91
95
Filter posts to show only posts having at least one of the ``slugs``.
92
96
Defaults to None.
@@ -113,6 +117,7 @@ class PostList(Directive):
113
117
'reverse' : directives .flag ,
114
118
'sort' : directives .unchanged ,
115
119
'tags' : directives .unchanged ,
120
+ 'categories' : directives .unchanged ,
116
121
'slugs' : directives .unchanged ,
117
122
'all' : directives .flag ,
118
123
'lang' : directives .unchanged ,
@@ -126,6 +131,8 @@ def run(self):
126
131
reverse = self .options .get ('reverse' , False )
127
132
tags = self .options .get ('tags' )
128
133
tags = [t .strip ().lower () for t in tags .split (',' )] if tags else []
134
+ categories = self .options .get ('categories' )
135
+ categories = [c .strip ().lower () for c in categories .split (',' )] if categories else []
129
136
slugs = self .options .get ('slugs' )
130
137
slugs = [s .strip () for s in slugs .split (',' )] if slugs else []
131
138
show_all = self .options .get ('all' , False )
@@ -145,6 +152,9 @@ def run(self):
145
152
else :
146
153
timeline = [p for p in self .site .timeline if p .use_in_feeds ]
147
154
155
+ if categories :
156
+ timeline = [p for p in timeline if p .meta ('category' , lang = lang ).lower () in categories ]
157
+
148
158
for post in timeline :
149
159
if tags :
150
160
cont = True
0 commit comments