SSR
All checks were successful
deploy to production / deploy (push) Successful in 1m7s

This commit is contained in:
2023-12-06 20:11:49 +00:00
parent 82f2bf9233
commit d3b36a6716
24 changed files with 166 additions and 119 deletions

View File

@@ -6,13 +6,10 @@ module.exports = {
// / 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 }],
$or: [{ path }],
},
selector: { _id: 1 },
})

View File

@@ -71,6 +71,7 @@ const { obj2str, log } = require("../lib/utils")
html = "<!-- NO SSR RENDERING -->"
} else if (pNotfound) {
status = 404
console.log("IS 404")
html = "404 NOT FOUND"
} else {
// try rendering, if error output plain html
@@ -137,6 +138,7 @@ const { obj2str, log } = require("../lib/utils")
// @ts-ignore
if (context.is404) {
status = 404
console.log("IS 404")
} else {
cacheIt = true
}
@@ -154,7 +156,7 @@ const { obj2str, log } = require("../lib/utils")
tpl = tpl.replace("<!--HTML-->", html)
tpl = tpl.replace("<!--SSR.ERROR-->", error ? "<!--" + error + "-->" : "")
tpl = tpl.replace("<!--SSR.COMMENT-->", comment ? "<!--" + comment + "-->" : "")
console.log("CACHE", cacheIt, noCache)
// save cache if adviced
if (cacheIt && !noCache) {
context.db.create("ssr", {