forked from cms/tibi-svelte-starter
yarn upgrade
This commit is contained in:
@@ -1,17 +1,73 @@
|
||||
module.exports = {
|
||||
projectName: "__PROJECT_NAME__",
|
||||
operatorEmail: "__OPERATOR_EMAIL_",
|
||||
const apiSsrBaseURL =
|
||||
"http://localhost:" + context.config.server().api.port + "/api/v1/_/" + context.api().namespace + "/"
|
||||
|
||||
apiBase: "http://localhost:8080/api/v1/_/__NAMESPACE__/",
|
||||
frontendBase: "http://localhost:5501/",
|
||||
|
||||
publicToken: "__PUBLIC_TOKEN__",
|
||||
ssrToken: "__SSR_TOKEN__",
|
||||
|
||||
ssrValidatePath: function(path) {
|
||||
// TODO 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
|
||||
|
||||
return path.match(/^\/(home|service)\/?$/)
|
||||
}
|
||||
const now = { $date: new Date().toISOString() }
|
||||
const publishedFilter = {
|
||||
active: true,
|
||||
$or: [
|
||||
{ publication: { $exists: false } },
|
||||
{ publication: null },
|
||||
{
|
||||
$and: [
|
||||
{
|
||||
$or: [
|
||||
{ "publication.from": { $exists: false } },
|
||||
{ "publication.from": null },
|
||||
{ "publication.from": { $lte: now } },
|
||||
],
|
||||
},
|
||||
{
|
||||
$or: [
|
||||
{ "publication.to": { $exists: false } },
|
||||
{ "publication.to": null },
|
||||
{ "publication.to": { $gte: now } },
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
apiSsrBaseURL,
|
||||
publishedFilter,
|
||||
ssrValidatePath: function (/** @type {string} */ 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 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],
|
||||
},
|
||||
|
||||
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],
|
||||
},
|
||||
|
||||
selector: { _id: 1 },
|
||||
})
|
||||
if (resp && resp.length) {
|
||||
return 1
|
||||
}
|
||||
|
||||
// not found
|
||||
return -1
|
||||
},
|
||||
ssrPublishCheckCollections: ["content", "product"],
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user