mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
refactor: update resource id naming
This commit is contained in:
@ -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))
|
||||
|
Reference in New Issue
Block a user