mirror of
https://github.com/wgh136/nysoure.git
synced 2025-09-27 04:17:23 +00:00
SEO for collection page.
This commit is contained in:
@@ -33,6 +33,11 @@ export default function CollectionPage() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (app.getPreFetchData()?.collection?.id === idInt) {
|
||||||
|
setCollection(app.getPreFetchData().collection);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
network.getCollection(idInt).then((res) => {
|
network.getCollection(idInt).then((res) => {
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
setCollection(res.data!);
|
setCollection(res.data!);
|
||||||
@@ -43,7 +48,7 @@ export default function CollectionPage() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, [resourcesKey]);
|
}, [id]);
|
||||||
|
|
||||||
const toBeDeletedRID = useRef<number | null>(null);
|
const toBeDeletedRID = useRef<number | null>(null);
|
||||||
|
|
||||||
|
@@ -133,6 +133,28 @@ func serveIndexHtml(c fiber.Ctx) error {
|
|||||||
preFetchData = url.PathEscape(string(preFetchDataJson))
|
preFetchData = url.PathEscape(string(preFetchDataJson))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if strings.HasPrefix(path, "/collections/") {
|
||||||
|
collectionIDStr := strings.TrimPrefix(path, "/collections/")
|
||||||
|
collectionID, err := strconv.Atoi(collectionIDStr)
|
||||||
|
if err == nil {
|
||||||
|
coll, err := service.GetCollectionByID(uint(collectionID))
|
||||||
|
if err == nil {
|
||||||
|
title = "Collection: " + coll.Title
|
||||||
|
description = utils.ArticleToDescription(coll.Article, 256)
|
||||||
|
if len(coll.Images) > 0 {
|
||||||
|
preview = fmt.Sprintf("%s/api/image/%d", serverBaseURL, coll.Images[0].ID)
|
||||||
|
} else {
|
||||||
|
preview = fmt.Sprintf("%s/api/avatar/%d", serverBaseURL, coll.User.ID)
|
||||||
|
}
|
||||||
|
if len(coll.Images) > 0 {
|
||||||
|
preview = fmt.Sprintf("%s/api/image/%d", serverBaseURL, coll.Images[0].ID)
|
||||||
|
}
|
||||||
|
preFetchDataJson, _ := json.Marshal(map[string]interface{}{
|
||||||
|
"collection": coll,
|
||||||
|
})
|
||||||
|
preFetchData = url.PathEscape(string(preFetchDataJson))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
content = strings.ReplaceAll(content, "{{SiteName}}", siteName)
|
content = strings.ReplaceAll(content, "{{SiteName}}", siteName)
|
||||||
|
Reference in New Issue
Block a user