Started working on the frontend

- Added the new post frontend
- Hooked up publishing of posts to the site publisher
- Added an site exporter as a publishing target
This commit is contained in:
Leon Mika 2026-02-21 10:22:10 +11:00
parent a59008b3e8
commit e77cac2fd5
40 changed files with 1427 additions and 84 deletions

View file

@ -47,6 +47,26 @@ func (q *Queries) InsertPost(ctx context.Context, arg InsertPostParams) (int64,
return id, err
}
const selectPostByGUID = `-- name: SelectPostByGUID :one
SELECT id, site_id, guid, title, body, slug, created_at, published_at FROM posts WHERE guid = ? LIMIT 1
`
func (q *Queries) SelectPostByGUID(ctx context.Context, guid string) (Post, error) {
row := q.db.QueryRowContext(ctx, selectPostByGUID, guid)
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 selectPostsOfSite = `-- name: SelectPostsOfSite :many
SELECT id, site_id, guid, title, body, slug, created_at, published_at FROM posts WHERE site_id = ? ORDER BY created_at DESC LIMIT 10
`
@ -82,3 +102,31 @@ func (q *Queries) SelectPostsOfSite(ctx context.Context, siteID int64) ([]Post,
}
return items, nil
}
const updatePost = `-- name: UpdatePost :exec
UPDATE posts SET
title = ?,
body = ?,
slug = ?,
published_at = ?
WHERE id = ?
`
type UpdatePostParams struct {
Title string
Body string
Slug string
PublishedAt int64
ID int64
}
func (q *Queries) UpdatePost(ctx context.Context, arg UpdatePostParams) error {
_, err := q.db.ExecContext(ctx, updatePost,
arg.Title,
arg.Body,
arg.Slug,
arg.PublishedAt,
arg.ID,
)
return err
}