add latest blog post to admin dashboard view
This commit is contained in:
parent
21912d4ec2
commit
fec3325503
5 changed files with 93 additions and 7 deletions
|
|
@ -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) " +
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue