feat: SEO backend output (2/4)
This commit is contained in:
1 parent
0eb46b0d74
commit
eb9876fde3
32 files changed
+3859
-65
No files matched your search
@@ -103,6 +103,9 @@ func (m *mockArticleRepo) FindPage(filters article.Filters) (article.PageResult,
|
||||
sort.Slice(matching, func(i, j int) bool { return articleSortsBefore(matching[i], matching[j], filters.Sort) })
|
||||
start := min((filters.Page-1)*filters.Size, len(matching))
|
||||
end := min(start+filters.Size, len(matching))
|
||||
if filters.Unpaged {
|
||||
start, end = 0, len(matching)
|
||||
}
|
||||
items := make([]article.Article, 0)
|
||||
for _, a := range matching[start:end] {
|
||||
items = append(items, m.withAuthors(a))
|
||||
@@ -143,6 +146,8 @@ func articleSortsBefore(left, right article.Article, order article.Sort) bool {
|
||||
}
|
||||
case article.SortByCreatedAt:
|
||||
comparison = left.CreatedAt.Compare(right.CreatedAt)
|
||||
case article.SortByID:
|
||||
comparison = int(left.ID) - int(right.ID)
|
||||
default:
|
||||
comparison = left.UpdatedAt.Compare(right.UpdatedAt)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user