Styled the post list and added updating of posts

This commit is contained in:
Leon Mika 2026-02-22 10:09:34 +11:00
parent e77cac2fd5
commit aef3bb6a1e
31 changed files with 1230 additions and 118 deletions

View file

@ -19,6 +19,7 @@ type PublishTarget struct {
ID int64
SiteID int64
TargetType string
Enabled int64
BaseUrl string
TargetRef string
TargetKey string

View file

@ -47,6 +47,26 @@ func (q *Queries) InsertPost(ctx context.Context, arg InsertPostParams) (int64,
return id, err
}
const selectPost = `-- name: SelectPost :one
SELECT id, site_id, guid, title, body, slug, created_at, published_at FROM posts WHERE id = ? LIMIT 1
`
func (q *Queries) SelectPost(ctx context.Context, id int64) (Post, error) {
row := q.db.QueryRowContext(ctx, selectPost, id)
var i Post
err := row.Scan(
&i.ID,
&i.SiteID,
&i.Guid,
&i.Title,
&i.Body,
&i.Slug,
&i.CreatedAt,
&i.PublishedAt,
)
return i, err
}
const selectPostByGUID = `-- name: SelectPostByGUID :one
SELECT id, site_id, guid, title, body, slug, created_at, published_at FROM posts WHERE guid = ? LIMIT 1
`

View file

@ -13,16 +13,18 @@ const insertPublishTarget = `-- name: InsertPublishTarget :one
INSERT INTO publish_targets (
site_id,
target_type,
enabled,
base_url,
target_ref,
target_key
) VALUES (?, ?, ?, ?, ?)
) VALUES (?, ?, ?, ?, ?, ?)
RETURNING id
`
type InsertPublishTargetParams struct {
SiteID int64
TargetType string
Enabled int64
BaseUrl string
TargetRef string
TargetKey string
@ -32,6 +34,7 @@ func (q *Queries) InsertPublishTarget(ctx context.Context, arg InsertPublishTarg
row := q.db.QueryRowContext(ctx, insertPublishTarget,
arg.SiteID,
arg.TargetType,
arg.Enabled,
arg.BaseUrl,
arg.TargetRef,
arg.TargetKey,
@ -42,7 +45,7 @@ func (q *Queries) InsertPublishTarget(ctx context.Context, arg InsertPublishTarg
}
const selectPublishTargetsOfSite = `-- name: SelectPublishTargetsOfSite :many
SELECT id, site_id, target_type, base_url, target_ref, target_key FROM publish_targets WHERE site_id = ?
SELECT id, site_id, target_type, enabled, base_url, target_ref, target_key FROM publish_targets WHERE site_id = ?
`
func (q *Queries) SelectPublishTargetsOfSite(ctx context.Context, siteID int64) ([]PublishTarget, error) {
@ -58,6 +61,7 @@ func (q *Queries) SelectPublishTargetsOfSite(ctx context.Context, siteID int64)
&i.ID,
&i.SiteID,
&i.TargetType,
&i.Enabled,
&i.BaseUrl,
&i.TargetRef,
&i.TargetKey,