summaryrefslogtreecommitdiffci
path: root/internal
diff refs
from: back
to: back
| flip
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-rw-r--r--internal/router/handlers/api-v1-blog-search.go10
-rw-r--r--internal/router/handlers/lang-blog-title.go8
2 files changed, 11 insertions, 7 deletions
diff --git a/internal/router/handlers/api-v1-blog-search.go b/internal/router/handlers/api-v1-blog-search.go
index b59f09a..c48b40a 100644
--- a/internal/router/handlers/api-v1-blog-search.go
+++ b/internal/router/handlers/api-v1-blog-search.go
@@ -8,6 +8,7 @@ import (
"net/url"
"regexp"
"slices"
+ "strings"
"time"
"github.com/SayaAndy/saya-today-web/internal/blog"
@@ -52,7 +53,12 @@ func (r *BlogSearchHandler) Render(c *fiber.Ctx, supplements *router.Supplements
sort := c.Query("sort")
tz := c.Query("tz")
medley := c.Query("medley")
- highlight := c.Query("highlight")
+ referer := c.Get("Referer")
+ refererParts := strings.Split(referer, "/")
+ refererPage := ""
+ if len(refererParts) >= 1 {
+ refererPage = refererParts[len(refererParts)-1]
+ }
hideTags := c.QueryBool("hideTags", false)
hidePublishedTime := c.QueryBool("hidePublishedTime", false)
@@ -105,7 +111,7 @@ func (r *BlogSearchHandler) Render(c *fiber.Ctx, supplements *router.Supplements
"Viewed": supplements.ClientCache.GetViewStatus(c.IP(), page.FileName),
"Medley": page.Metadata.Medley,
"MedleyPart": page.Metadata.MedleyPart,
- "ToHighlight": page.FileName == highlight,
+ "ToHighlight": page.FileName == refererPage,
})
break
}
diff --git a/internal/router/handlers/lang-blog-title.go b/internal/router/handlers/lang-blog-title.go
index eac317a..f7cd019 100644
--- a/internal/router/handlers/lang-blog-title.go
+++ b/internal/router/handlers/lang-blog-title.go
@@ -102,11 +102,10 @@ func (r *BlogPageHandler) RenderBody(c *fiber.Ctx, supplements *router.Supplemen
if err != nil {
return fiber.StatusBadRequest, fmt.Errorf("failed to get path from referer: %w", err)
}
- title := pathParts[2]
- metadata, parsedMarkdown, err := readBlogPost(supplements.MarkdownRenderer, supplements.BlogClient, lang+"/"+title)
+ metadata, parsedMarkdown, err := readBlogPost(supplements.MarkdownRenderer, supplements.BlogClient, lang+"/"+pathParts[2])
if err != nil {
- return fiber.StatusNotFound, fmt.Errorf("failed to find '%s' post: %w", title, err)
+ return fiber.StatusNotFound, fmt.Errorf("failed to find '%s' post: %w", pathParts[2], err)
}
geolocationParts := strings.Split(metadata.Geolocation, " ")
@@ -123,7 +122,6 @@ func (r *BlogPageHandler) RenderBody(c *fiber.Ctx, supplements *router.Supplemen
templateMap["MapLocationY"] = y
templateMap["MapLocationAreaMeters"] = areaError
templateMap["Title"] = metadata.Title
- templateMap["Codename"] = title
templateMap["ParsedMarkdown"] = template.HTML(parsedMarkdown)
templateMap["PublishedDate"] = metadata.PublishedTime.Format("2006-01-02 15:04:05 -07:00")
templateMap["ActionDate"] = metadata.ActionDate
@@ -131,7 +129,7 @@ func (r *BlogPageHandler) RenderBody(c *fiber.Ctx, supplements *router.Supplemen
templateMap["Thumbnail"] = metadata.Thumbnail
templateMap["Medley"] = metadata.Medley
- go supplements.ClientCache.View(c.IP(), title)
+ go supplements.ClientCache.View(c.IP(), pathParts[2])
return fiber.StatusOK, nil
}