mirror of
https://codeberg.org/VnPower/PixivFE
synced 2024-12-06 19:16:23 +01:00
36 lines
706 B
Go
36 lines
706 B
Go
package pages
|
|
|
|
import (
|
|
"errors"
|
|
"strconv"
|
|
|
|
core "codeberg.org/vnpower/pixivfe/v2/core/webapi"
|
|
"github.com/gofiber/fiber/v2"
|
|
)
|
|
|
|
func ArtworkPage(c *fiber.Ctx) error {
|
|
id := c.Params("id")
|
|
if _, err := strconv.Atoi(id); err != nil {
|
|
return errors.New("Invalid ID.")
|
|
}
|
|
|
|
illust, err := core.GetArtworkByID(c, id)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
metaDescription := ""
|
|
for _, i := range illust.Tags {
|
|
metaDescription += "#" + i.Name + ", "
|
|
}
|
|
|
|
// Optimize this
|
|
return c.Render("pages/artwork", fiber.Map{
|
|
"Illust": illust,
|
|
"Title": illust.Title,
|
|
"PageType": "artwork",
|
|
"MetaDescription": metaDescription,
|
|
"MetaImage": illust.Images[0].Original,
|
|
})
|
|
}
|