Added meta tags

This commit is contained in:
VnPower
2024-01-27 19:23:25 +07:00
parent 6f0fdca73b
commit 6ff72d2247
4 changed files with 69 additions and 3 deletions
+11
View File
@@ -75,6 +75,11 @@ func main() {
server.Use(cache.New(
cache.Config{
Next: func(c *fiber.Ctx) bool {
resp_code := c.Response().StatusCode()
if resp_code < 200 || resp_code >= 300 {
return true
}
// Disable cache for settings page
return strings.Contains(c.Path(), "/settings") || c.Path() == "/"
},
@@ -103,6 +108,12 @@ func main() {
return c.Next()
})
server.Use(func(c *fiber.Ctx) error {
var baseURL string
c.Bind(fiber.Map{"FullURL": baseURL + c.OriginalURL(), "BaseURL": baseURL})
return c.Next()
})
server.Static("/favicon.ico", "./views/assets/favicon.ico")
server.Static("css/", "./views/css")
server.Static("assets/", "./views/assets")
+5 -3
View File
@@ -21,8 +21,10 @@ func ArtworkPage(c *fiber.Ctx) error {
// Optimize this
return c.Render("pages/artwork", fiber.Map{
"Illust": illust,
"Title": illust.Title,
"PageType": "artwork",
"Illust": illust,
"Title": illust.Title,
"PageType": "artwork",
"MetaDescription": illust.Description,
"MetaImage": illust.Images[0].Original,
})
}
+34
View File
@@ -0,0 +1,34 @@
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,
// })
// }
+19
View File
@@ -10,6 +10,25 @@
<meta http-equiv="Content-Security-Policy" content="script-src 'self'" />
<meta name="referrer" content="no-referrer, same-origin" />
<link href="/css/style.css" rel="stylesheet" />
{{ if BaseURL }}
<meta property="og:title" content="{{ title }}" />
<meta property="og:url" content="https://{{ FullURL }}" />
<meta property="og:site_name" content="PixivFE" />
<meta property="og:type" content="article" />
<meta content="summary_large_image" name="twitter:card" />
{{ if isset(MetaDescription) }}
<meta
property="og:description"
content="{{MetaDescription}}"
/>
{{ end }}
{{ if isset(MetaImage) }}
<meta property="og:image" content="{{ MetaImage }}" />
{{ end }}
{{ end }}
</head>
<body>