Files
PixivFE/pages/index.go
T
2024-01-25 12:28:15 +07:00

35 lines
750 B
Go

package pages
import (
session "codeberg.org/vnpower/pixivfe/v2/core/config"
core "codeberg.org/vnpower/pixivfe/v2/core/webapi"
"github.com/gofiber/fiber/v2"
)
func IndexPage(c *fiber.Ctx) error {
// If token is set, do the landing request...
if token := session.CheckToken(c); token != "" {
mode := c.Query("mode", "all")
works, err := core.GetLanding(c, mode)
if err != nil {
return err
}
return c.Render("pages/index", fiber.Map{
"Title": "Landing", "Data": works,
})
}
// ...otherwise, default to today's illustration ranking
works, err := core.GetRanking(c, "daily", "illust", "", "1")
if err != nil {
return err
}
return c.Render("pages/index", fiber.Map{
"Title": "Landing", "NoTokenData": works,
})
}