add latest blog post to admin dashboard view

This commit is contained in:
ari melody 2025-11-07 18:16:14 +00:00
parent 21912d4ec2
commit fec3325503
Signed by: ari
GPG key ID: CF99829C92678188
5 changed files with 93 additions and 7 deletions

View file

@ -44,6 +44,18 @@ func GetBlogPosts(db *sqlx.DB, onlyVisible bool, limit int, offset int) ([]*mode
return blogs, nil
}
func GetBlogPostCount(db *sqlx.DB, onlyVisible bool) (int, error) {
query := "SELECT count(*) FROM blogpost"
if onlyVisible {
query += " WHERE visible=true"
}
var count int
err := db.Get(&count, query)
return count, err
}
func CreateBlogPost(db *sqlx.DB, post *model.BlogPost) error {
_, err := db.Exec(
"INSERT INTO blogpost (id,title,description,visible,author,markdown,html,bluesky_actor,bluesky_post) " +