Add CSS support
This commit is contained in:
parent
4e881d6487
commit
e95c8ad4e6
|
@ -41,7 +41,7 @@ function makeEventEntryFromEventJson(roomId, eventJson) {
|
||||||
return eventEntry;
|
return eventEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function asdf() {
|
async function mountHydrogen() {
|
||||||
const app = document.querySelector('#app');
|
const app = document.querySelector('#app');
|
||||||
|
|
||||||
const config = {};
|
const config = {};
|
||||||
|
@ -117,7 +117,6 @@ async function asdf() {
|
||||||
|
|
||||||
//console.log('view.mount()', view.mount());
|
//console.log('view.mount()', view.mount());
|
||||||
app.appendChild(view.mount());
|
app.appendChild(view.mount());
|
||||||
//app.insertAdjacentHTML('beforeend', view.mount());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
asdf();
|
mountHydrogen();
|
||||||
|
|
|
@ -15,9 +15,6 @@ async function renderToString() {
|
||||||
const dom = parseHTML(`
|
const dom = parseHTML(`
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
|
||||||
<title>Hello SSR</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
<body>
|
||||||
<div id="app" class="hydrogen">App container</div>
|
<div id="app" class="hydrogen">App container</div>
|
||||||
</body>
|
</body>
|
||||||
|
@ -57,16 +54,35 @@ async function renderToString() {
|
||||||
// (waiting on the promise returned from `hydrogen-render-script.js`)
|
// (waiting on the promise returned from `hydrogen-render-script.js`)
|
||||||
await vmResult;
|
await vmResult;
|
||||||
|
|
||||||
const documentString = dom.document.toString();
|
const documentString = dom.document.querySelector('#app').toString();
|
||||||
console.log('documentString', documentString);
|
//console.log('documentString', documentString);
|
||||||
return documentString;
|
return documentString;
|
||||||
}
|
}
|
||||||
|
|
||||||
app.get('/', async function (req, res) {
|
app.get('/style.css', async function (req, res) {
|
||||||
const htmlOutput = await renderToString();
|
const htmlOutput = await renderToString();
|
||||||
|
|
||||||
|
res.set('Content-Type', 'text/css');
|
||||||
|
res.sendFile(require.resolve('hydrogen-view-sdk/style.css'));
|
||||||
|
});
|
||||||
|
|
||||||
|
app.get('/', async function (req, res) {
|
||||||
|
const hydrogenHtmlOutput = await renderToString();
|
||||||
|
|
||||||
|
const pageHtml = `
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<link href="style.css" rel="stylesheet">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
${hydrogenHtmlOutput}
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
`;
|
||||||
|
|
||||||
res.set('Content-Type', 'text/html');
|
res.set('Content-Type', 'text/html');
|
||||||
res.send(htmlOutput);
|
res.send(pageHtml);
|
||||||
});
|
});
|
||||||
|
|
||||||
app.listen(3050);
|
app.listen(3050);
|
||||||
|
|
Loading…
Reference in New Issue