Added a site setting section

This commit is contained in:
Leon Mika 2026-03-09 21:47:02 +11:00
parent 499c0d8568
commit 0bd91de234
17 changed files with 856 additions and 36 deletions

View file

@ -32,13 +32,20 @@ func (s *Service) UpdatePost(ctx context.Context, params CreatePostParams) (*mod
post.Title = params.Title
post.Body = params.Body
post.UpdatedAt = now
post.Slug = post.BestSlug()
oldState := post.State
switch strings.ToLower(params.Action) {
case "publish":
post.State = models.StatePublished
post.PublishedAt = now
// Set the published at with the site timezone, and reset the slug, so that the date
// is in the site timezone.
renderTZ, err := time.LoadLocation(site.Timezone)
if err != nil {
renderTZ = time.UTC
}
post.PublishedAt = now.In(renderTZ)
post.Slug = post.BestSlug()
case "save draft":
post.State = models.StateDraft
post.PublishedAt = time.Time{}