Skip to content

Commit 2842d44

Browse files
committed
Fix to sort articles on published dates
1 parent 4b80879 commit 2842d44

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

generate/component/article/helper-sort.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,9 @@ export function helperSort(data) {
2020
*/
2121
function score(d) {
2222
const matter = d.data.matter || {}
23-
return matter.index || Number.POSITIVE_INFINITY
23+
const published =
24+
typeof matter.published === 'string'
25+
? new Date(matter.published)
26+
: matter.published || undefined
27+
return matter.index || published?.getTime() || Number.POSITIVE_INFINITY
2428
}

0 commit comments

Comments
 (0)