File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -152,6 +152,25 @@ module.exports = function (eleventyConfig) {
152
152
} ) ;
153
153
} ) ;
154
154
155
+ // Pin article option (add 'pinned' tag in the article)
156
+ eleventyConfig . addCollection ( 'blog' , ( collection ) => {
157
+ return collection . getFilteredByGlob ( 'src/posts/**/*.md' )
158
+ . sort ( ( a , b ) => {
159
+
160
+ // Sort pinned posts first, then by date
161
+ if ( a . data . pinned && ! b . data . pinned ) {
162
+ return - 1 ; // a before b
163
+ }
164
+ else if ( ! a . data . pinned && b . data . pinned ) {
165
+ return 1 ; // b before a
166
+ }
167
+ else {
168
+ // If both are pinned or neither, sort by date
169
+ return ( b . data . date - a . data . date ) ; // Latest first
170
+ }
171
+ } ) ;
172
+ } ) ;
173
+
155
174
// Add talks.json
156
175
eleventyConfig . addPassthroughCopy ( { 'src/data/talks.json' : 'assets/talks.json' } ) ;
157
176
You can’t perform that action at this time.
0 commit comments