-
-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to change the html tag? #82
Comments
How about this? // /pages/+Html.jsx
export function Html({ head, body }) {
return <>
<!DOCTYPE html>
<html className={whateverYouWant}>
<head>
{head}
</head>
<body>
{body}
</body>
</html>
</>
} Let me know if that works for you, I'll then implement and pre-release it. I'll stable release it after the Edit: we decided against this in order to enable Vike extensions to add |
I like it, but the Html could be a config like the Head. |
Thinking longer, I think the Head still useful. But I'm still in favor of using the Html as a config property. |
It is a config just like Head is. I think there is room for improvement but I can't think of a better solution. The new setting I'm inclined to first focus on unblocking users and then, later, polishing the DX. Ideas welcome. @geovannimp Let me know if you want to be unblocked sooner rather than later, I'm happy to prioritize a pre-release. @AurelienLourot WDYT? |
This sounds good to me. Let's try to avoid hard breaking changes along the way if they are not really necessary 🙏 |
@brillout I won't be releasing the product I'm working on any time soon, so you can prioritize as you want. But thank you for offering. |
👍 I'll implement this once I fixed Dani's blockers.
Ok 👍 |
I think there is room of improvement
|
Just in case someone have the same problem with tailwind, I fixed my problem adding this script to my Head component. <script
dangerouslySetInnerHTML={{
__html: `
(function() {
const systemTheme = window.matchMedia('(prefers-color-scheme: dark)')
.matches
? 'dark'
: 'light';
document.documentElement.classList.add(systemTheme);
})();
`,
}}
/> |
https://vike.dev/htmlAttributes Let us know if anything doesn't work for your use case. We look forward to gathering feedback on the new improvements to head tag management.
Done. |
Hi @brillout
Got error message like this :
And |
@fortezhuo Minimal reproduction welcome. |
Hi @brillout - thanks for your work on this handy feature! I'm just discovering this thread and encountering the same issue - whenever I try to set
I've also tried setting it via a separate If relevant, I'm on My
|
Here the minimal reproduction using batijs
|
That’s expected: follow the link. Let me know if you find in unclear. |
I just created file named
And here the +config.ts
And typescript not happy with these scripts, also in browser, html does not have "dark" class name
PR on the vike-demo repo welcome for make all setup more clear |
Ah, I think I understand. If the return value of I still think there might be a bug in the implementation - when I define a static object in I'm not nearly as familiar with this codebase, so I could be wrong, but I suspect the bug has something to do with this I've verified by tweaking this function locally, and it seems to work: export { getHeadSetting };
import { isCallable } from '../utils/isCallable.js';
function getHeadSetting(headSetting, pageContext) {
// Set by useConfig()
{
const val = pageContext._configFromHook?.[headSetting];
if (val !== undefined)
return val;
}
// Set by +configName.js
const val = pageContext.config[headSetting];
// Handle arrays of pre-merged configs
if (Array.isArray(val)) {
return val.map(v =>
isCallable(v) ? v(pageContext) : v
)
} else {
return isCallable(val) ? val(pageContext) : val;
}
} |
Good catch, fix pre-released as
👍 Done. And I'll do this when I'm done with the current priorities.
I didn't decide yet whether I want to add Let me know if there is anything else. |
Use |
I'm using tailwind and my page always blink switching from light theme to dark theme on client render. I would like to add the dark class by default to the html tag, but I can not find how to change it on server side.
The text was updated successfully, but these errors were encountered: