🔧 fix: comment out unused SSR path validation logic and update collection check

This commit is contained in:
2025-10-30 09:32:06 +00:00
parent 66225b731a
commit 4893d925c5

View File

@@ -35,39 +35,41 @@ module.exports = {
// validate if path ssr rendering is ok, -1 = NOTFOUND, 0 = NO SSR, 1 = SSR
// pe. use context.readCollection("product", {filter: {path: path}}) ... to validate dynamic urls
// / is fixed url
if (path == "/cart") return 1
// // / is fixed url
// if (path == "/cart") return 1
// path starts with /products/ is product
if (path?.startsWith("/products/")) {
const slug = path?.replace(/^\/products\//, "")
const resp = context.db.find("product", {
filter: {
$and: [{ slug: slug }, publishedFilter],
},
// // path starts with /products/ is product
// if (path?.startsWith("/products/")) {
// const slug = path?.replace(/^\/products\//, "")
// const resp = context.db.find("product", {
// filter: {
// $and: [{ slug: slug }, publishedFilter],
// },
selector: { _id: 1 },
})
if (resp && resp.length) {
return 1
}
}
// selector: { _id: 1 },
// })
// if (resp && resp.length) {
// return 1
// }
// }
// // all other sites are in db
//path = path?.replace(/^\//, "")
const resp = context.db.find("content", {
filter: {
$and: [{ $or: [{ path }, { "alternativePaths.path": path }] }, publishedFilter],
},
// // // all other sites are in db
// //path = path?.replace(/^\//, "")
// const resp = context.db.find("content", {
// filter: {
// $and: [{ $or: [{ path }, { "alternativePaths.path": path }] }, publishedFilter],
// },
selector: { _id: 1 },
})
if (resp && resp.length) {
return 1
}
// selector: { _id: 1 },
// })
// if (resp && resp.length) {
// return 1
// }
// not found
return -1
},
ssrPublishCheckCollections: ["content", "product"],
ssrPublishCheckCollections: [
/*"content", "product"*/
],
}