Skip to content
Permalink
master
Go to file
 
 
Cannot retrieve contributors at this time
51 lines (49 sloc) 1.23 KB
type Params = {
meta: string;
body: string;
style: string;
preloadedState: string;
graphql: string;
nonce: string;
scripts: string;
};
const escape = (str: string) => {
return str
.replace(/&/g, '&')
.replace(/"/g, '"')
.replace(/'/g, ''')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;');
};
export const renderFullPage = ({
meta,
body,
style,
scripts,
preloadedState,
graphql,
nonce,
}: Params) => {
return `<!DOCTYPE html>
<html lang="en">
<head>
<meta charSet="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="Description" content="introducing SPA and SSR">
<meta property="csp-nonce" content="${nonce}">
${meta}
<link rel="manifest" href="/manifest.webmanifest">
<link href="https://fonts.googleapis.com/css?family=Muli&display=swap" rel="stylesheet"></link>
${style}
</head>
<body>
${body}
<script nonce="${nonce}" id="initial-data" type="text/plain" data-json="${escape(
preloadedState
)}"></script>
<script nonce="${nonce}">window.__APOLLO_STATE__=${graphql}</script>
${scripts}
</body>
</html>
`.trim();
};
You can’t perform that action at this time.