Added RSS and JSON feeds

This commit is contained in:
Leon Mika 2026-03-05 22:04:24 +11:00
parent 65e5ce2733
commit 21f181f83d
13 changed files with 192 additions and 31 deletions

View file

@ -123,21 +123,28 @@ func (q *Queries) SelectPostByGUID(ctx context.Context, guid string) (Post, erro
const selectPostsOfSite = `-- name: SelectPostsOfSite :many
SELECT id, site_id, state, guid, title, body, slug, created_at, updated_at, published_at, deleted_at
FROM posts
WHERE site_id = ? AND (
WHERE site_id = ?1 AND (
CASE CAST (?2 AS TEXT)
WHEN 'deleted' THEN deleted_at > 0
ELSE deleted_at = 0
END
) ORDER BY created_at DESC LIMIT 10
) ORDER BY created_at DESC LIMIT ?4 OFFSET ?3
`
type SelectPostsOfSiteParams struct {
SiteID int64
PostFilter string
Offset int64
Limit int64
}
func (q *Queries) SelectPostsOfSite(ctx context.Context, arg SelectPostsOfSiteParams) ([]Post, error) {
rows, err := q.db.QueryContext(ctx, selectPostsOfSite, arg.SiteID, arg.PostFilter)
rows, err := q.db.QueryContext(ctx, selectPostsOfSite,
arg.SiteID,
arg.PostFilter,
arg.Offset,
arg.Limit,
)
if err != nil {
return nil, err
}