artwork.go 803 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package pages
  2. import (
  3. "fmt"
  4. "strconv"
  5. core "codeberg.org/vnpower/pixivfe/v2/core/webapi"
  6. "github.com/gofiber/fiber/v2"
  7. )
  8. func ArtworkPage(c *fiber.Ctx) error {
  9. id := c.Params("id")
  10. if _, err := strconv.Atoi(id); err != nil {
  11. return fmt.Errorf("Invalid ID: %s", id)
  12. }
  13. illust, err := core.GetArtworkByID(c, id, true)
  14. if err != nil {
  15. return err
  16. }
  17. metaDescription := ""
  18. for _, i := range illust.Tags {
  19. metaDescription += "#" + i.Name + ", "
  20. }
  21. // todo: passing ArtWorkData{} here will not work. maybe lowercase?
  22. return c.Render("artwork", fiber.Map{
  23. "Illust": illust,
  24. "Title": illust.Title,
  25. "MetaDescription": metaDescription,
  26. "MetaImage": illust.Images[0].Original,
  27. "MetaAuthor": illust.UserName,
  28. "MetaAuthorID": illust.UserID,
  29. })
  30. }