Only server-side render non-auth systems

pull/674/head
Zef Hemel 2024-01-28 19:24:59 +01:00
parent e2aa869660
commit dbabba7326
1 changed files with 14 additions and 11 deletions

View File

@ -113,8 +113,9 @@ export class HttpServer {
// Replaces some template variables in index.html in a rather ad-hoc manner, but YOLO // Replaces some template variables in index.html in a rather ad-hoc manner, but YOLO
async renderHtmlPage(spaceServer: SpaceServer, pageName: string) { async renderHtmlPage(spaceServer: SpaceServer, pageName: string) {
console.log("Server side rendering", pageName);
let html = ""; let html = "";
if (!spaceServer.auth) {
// Only attempt server-side rendering when this site is not protected by auth
try { try {
const { data } = await spaceServer.spacePrimitives.readFile( const { data } = await spaceServer.spacePrimitives.readFile(
`${pageName}.md`, `${pageName}.md`,
@ -127,6 +128,8 @@ export class HttpServer {
console.error("Error server-side rendering page", e); console.error("Error server-side rendering page", e);
} }
} }
}
// TODO: Replace this with a proper template engine
return this.clientAssetBundle.readTextFileSync(".client/index.html") return this.clientAssetBundle.readTextFileSync(".client/index.html")
.replace( .replace(
"{{SPACE_PATH}}", "{{SPACE_PATH}}",