wm-fontis-tibi-2023/api/hooks/config.js

28 lines
801 B
JavaScript
Raw Normal View History

2023-07-13 13:12:19 +02:00
module.exports = {
ssrValidatePath: function (path) {
// 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 de home
if (path == "/") return 1
// all other sites are in db
path = path?.replace(/^\//, "")
// filter for path or alternativePaths
const resp = context.db.find("content", {
filter: {
$or: [{ path }, { "alternativePaths.path": path }],
},
selector: { _id: 1 },
})
if (resp && resp.length) {
return 1
}
// not found
return -1
},
ssrAllowedAPIEndpoints: ["content", "medialib"],
}