-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Dynamic Page Meta #4580
Comments
currently you should be able to pass for some of the meta attributes though, it doesn't really make sense to use dynamic values because many of the robots reading those meta tags will not run the whole javascript bundle to correctly resolve them and they most-likely will not have the correct value after server side rendering to html. |
Thanks @masenf - That makes sense. When I build a NextJS app manually, I can leverage SSR to populate that data before it reaches the browser. Also, I'm happy to make some code contributions! Just getting familiar with project now 🎉 |
Would you mind sharing a little example of how to achieve that? i’m not sure I understood. Thanks |
Also, for reference, when using the Pages routing mode, we could use the export default function Page({ data }) {
// Render data...
}
// This gets called on every request
export async function getServerSideProps() {
// Fetch data from external API, Redis, Database, etc...
const res = await fetch(`https://.../data`)
const data = await res.json()
// Pass data to the page via props
return { props: { data } }
} I see references to A related concern might be for |
I've verified the class PageComponent(rx.Component):
def _get_custom_code(self):
log.debug(f"Adding custom code: {self}")
return """
export async function getServerSideProps() {
const data = {
value: "xyz"
}
return { props: { data } }
}
"""
page_component = PageComponent.create Also one more caveat - since reflex is exporting as a static site, the
As a (not good) workaround I can create a Just thinking outloud.... |
Interesting find @jdbranham |
I'm currently at a road block trying to figure this out too. |
I don't think that right now Reflex can provide a solution for this, but there may be a workaround (not tested it yet). You could use nginx to replace the content of the meta tags using a LUA script. Here's the building blocks of the solution: https://stackoverflow.com/questions/13706658/variable-capture-in-nginx-location-matching Not an ideal solution but it should work for now. |
I'd like to dynamically provide the page metadata values.
Specifically I have dynamic page routes like
/page/[slug]
Since the page meta only allows
str
values, it prevents accurate meta data when the page is dynamic.Improves page previews in social feeds and better SEO
Using the state would be great -
The text was updated successfully, but these errors were encountered: