Comments (6)
Hey @SquirrelCoder, thanks for the issue.
I've looked at the repo and it looks like an issue with your setup. You are creating a new head instance after the tags have been rendered in _default.page.server.ts.
const appHtml = await renderToString(app);
const head = createHead(); // this is going to reset all collected head data
const { headTags, htmlAttrs, bodyAttrs, bodyTags } = await renderHeadToString(head);
If you need the head instance you should either create it exclusively in this file or you can return it from createApp
.
const { app, head } = createApp(Page, pageProps, pageContext);
const appHtml = await renderToString(app);
const { headTags, htmlAttrs, bodyAttrs, bodyTags } = await renderHeadToString(head);
Let me know if any of that isn't clear.
from head.
FYI the next vite-plugin-ssr version will warn the user when this happens.
from head.
oh shoot, I'm sorry, yeah that makes total sense. Thanks a lot.
from head.
@anatoliidaostreet That's not a problem with vueuse. I have asked the same question here: vikejs/vike#865.
You have to use it like this:
const documentHtml = escapeInject`<!DOCTYPE html>
<html>
<head>
${ dangerouslySkipEscape(headTags) }
</head>
<body>
<div id="app">${ stringApp }</div>
</body>
</html>`;
or completely wrap your string in dangerouslySkipEscape
. Like the following:
const documentHtml = dangerouslySkipEscape(`<!DOCTYPE html>
<html>
<head>
${ headTags }
</head>
<body>
<div id="app">${ stringApp }</div>
</body>
</html>`);
from head.
Hey @harlan-zw
I do how you propose, but i am getting sting of metadata in the body tag
const { app, head } = createApp(pageContext);
const pageHtml = pageContext.Page ? await renderToString(app) : '';
const { headTags, htmlAttrs, bodyTags } = await renderSSRHead(head);
Did I miss something?
I use
vue3, vite-plugin-ssr with ssr and spa mode together
from head.
Amazing, thanks @brillout
from head.
Related Issues (20)
- default meta description is not getting replaced HOT 1
- How to get type of script from useHead()? HOT 5
- Options API Dynamic Title HOT 3
- Issues when transpiling typeScript into javaScript HOT 6
- useHead script `children` vulnerable to XSS HOT 4
- the requested module does not provide an export named 'default' HOT 1
- website link HOT 1
- useHead does not working with vue router HOT 3
- change icon not work HOT 3
- Dependency not met HOT 2
- Noscript still seems to not be working HOT 1
- How to add "custom-element" tag to script HOT 3
- Deduping from initial head not working HOT 4
- Optional chaining are not compiled to ES5 HOT 2
- Why do tags stay despite route change? HOT 9
- Issue with useServerHead or useHead with Vue 2.7 + Vite + Vue Router HOT 3
- Vue 2.5 support HOT 1
- The installation guide link is pointing to a broken link HOT 2
- Google is lowering my indexed pages every day
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from head.