refactor: update resource id naming

This commit is contained in:
Steven
2024-03-20 20:39:16 +08:00
parent a3a4e37cb0
commit 7cc8b951a3
48 changed files with 704 additions and 693 deletions

View File

@ -53,11 +53,11 @@ func (s *FrontendService) Serve(ctx context.Context, e *echo.Echo) {
func (s *FrontendService) registerRoutes(e *echo.Echo) {
rawIndexHTML := getRawIndexHTML()
e.GET("/m/:name", func(c echo.Context) error {
e.GET("/m/:uid", func(c echo.Context) error {
ctx := c.Request().Context()
resourceName := c.Param("name")
uid := c.Param("uid")
memo, err := s.Store.GetMemo(ctx, &store.FindMemo{
ResourceName: &resourceName,
UID: &uid,
})
if err != nil {
return c.HTML(http.StatusOK, rawIndexHTML)
@ -108,7 +108,7 @@ Sitemap: %s/sitemap.xml`, instanceURL, instanceURL)
return err
}
for _, memo := range memoList {
urlsets = append(urlsets, fmt.Sprintf(`<url><loc>%s</loc></url>`, fmt.Sprintf("%s/m/%s", instanceURL, memo.ResourceName)))
urlsets = append(urlsets, fmt.Sprintf(`<url><loc>%s</loc></url>`, fmt.Sprintf("%s/m/%s", instanceURL, memo.UID)))
}
sitemap := fmt.Sprintf(`<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">%s</urlset>`, strings.Join(urlsets, "\n"))
return c.XMLBlob(http.StatusOK, []byte(sitemap))