Fix isoData not working

This commit is contained in:
abias 2023-06-09 08:47:13 -04:00
parent a1393131f0
commit 1cb23bd8f3
4 changed files with 5 additions and 8 deletions

View file

@ -7,7 +7,7 @@ import "bootstrap/js/dist/collapse";
import "bootstrap/js/dist/dropdown";
import { HistoryService } from "../shared/services/HistoryService";
const site = window.isoData.site_res;
const site = JSON.parse(window.isoData).site_res;
initializeSite(site);
const wrapper = (

View file

@ -26,7 +26,6 @@ import {
favIconUrl,
initializeSite,
isAuthPath,
md,
} from "../shared/utils";
const server = express();
@ -354,10 +353,8 @@ async function createSsrHtml(root: string, isoData: IsoDataOptionalSite) {
<!DOCTYPE html>
<html ${helmet.htmlAttributes.toString()} lang="en">
<head>
<script>window.isoData = ${md.utils.escapeHtml(
JSON.stringify(isoData)
)}</script>
<script>window.lemmyConfig = ${serialize(config)}</script>
<script>window.isoData = JSON.stringify(${JSON.stringify(isoData)});</script>
<script>window.lemmyConfig = ${serialize(config)};</script>
<!-- A remote debugging utility for mobile -->
${erudaStr}

View file

@ -22,7 +22,7 @@ export interface ILemmyConfig {
declare global {
interface Window {
isoData: IsoData;
isoData: string;
lemmyConfig?: ILemmyConfig;
}
}

View file

@ -1164,7 +1164,7 @@ export function isBrowser() {
export function setIsoData(context: any): IsoData {
// If its the browser, you need to deserialize the data from the window
if (isBrowser()) {
return window.isoData;
return JSON.parse(window.isoData);
} else return context.router.staticContext;
}