[✨] Document head based on content or props #273
Replies: 14 comments
-
Yes, that would be nice. Care to take a stab at it and send a PR. The code is here: https://github.com/BuilderIO/qwik/blob/main/packages/qwik-city/runtime/src/head.ts#L52 |
Beta Was this translation helpful? Give feedback.
-
Hello, please can I be assigned this issue? I will love to fix this. Cheers. |
Beta Was this translation helpful? Give feedback.
-
Hi @mhevery is this issue still open, i would like to work on it. |
Beta Was this translation helpful? Give feedback.
-
Sure, please go ahead. |
Beta Was this translation helpful? Give feedback.
-
@theCephas arrived first 😅 you can do pair programming to solve this race condition |
Beta Was this translation helpful? Give feedback.
-
Hi, is this issue fixed already or can I be assigned to it?? |
Beta Was this translation helpful? Give feedback.
-
I don't believe so. Perhaps all of the interested parties could collaborate on a solution. I am here to answer questions. |
Beta Was this translation helpful? Give feedback.
-
Hey @theCephas and @Blossomeze if it's okay with you, let's collaborate on this. |
Beta Was this translation helpful? Give feedback.
-
I don't mind. Although, I started working on it already. How do we collaborate to fix it? @Luwa-Tech |
Beta Was this translation helpful? Give feedback.
-
If you want you can use our discord server |
Beta Was this translation helpful? Give feedback.
-
useDocumentHead Function:import { useEffect } from 'react'; const useDocumentHead = (title: string) => {
}, [title]); export default useDocumentHead; |
Beta Was this translation helpful? Give feedback.
-
head Function in layout.tsx:import React from 'react'; const Layout = ({ content }) => { // Use the useDocumentHead hook to set or retrieve the title return ( {/* Your layout components and content here */} ); }; export default Layout; |
Beta Was this translation helpful? Give feedback.
-
We moved this issue to |
Beta Was this translation helpful? Give feedback.
-
Note:
In this case, I think it's best that the .md files get preprocessed by a vite plugin, that checks if there's a title set and if not, uses the first heading and adds it to the frontmatter. I'd also accept a PR that does this for the router during the mdx processing. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Is your feature request related to a problem?
It would be appreciated to be able to change the title of a page based on the props a component receives or the content (
useContent
).My need
I'm using the MDX feature and I would like the title to be the first
h1
if it hasn't been set in the frontmatter. I.e.,Describe the solution you'd like
Dynamic Head could give you the content of a Markdown page. E.g.,
Describe alternatives you've considered
I considered setting the title myself after the document loads.
Additional context
No response
Beta Was this translation helpful? Give feedback.
All reactions