forked from cms/tibi-svelte-starter
🔧 fix: comment out unused SSR path validation logic and update collection check
This commit is contained in:
@@ -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"*/
|
||||
],
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user