Skip to content
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

[Feature?]: Set Page Metadata by Exporting metadata Variable #1605

Open
2 tasks done
raflymln opened this issue Aug 19, 2024 · 3 comments
Open
2 tasks done

[Feature?]: Set Page Metadata by Exporting metadata Variable #1605

raflymln opened this issue Aug 19, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@raflymln
Copy link

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Summary 💡

I think it'd be great if solid implement the metadata handling that nextjs use, instead of we using solid-meta, it'd be much easier if we can just export metadata variable from a file and let that assigned as a metadata for that page.

Seeing that SolidJS is compiling it's DOM using compiler, i think this is possible to create on client too, while on nextjs it's only available on server.

While i think that the dynamic metadata will only be supported on server, i think having static metadata on client will be a great improvement to solidjs developer experience.

Examples 🌈

https://nextjs.org/docs/app/building-your-application/optimizing/metadata

export const metadata: Metadata = {
  title: '...',
  description: '...',
}

Motivation 🔦

  1. It'd be much easier to organize the code, since i myself always put the metadata variable export on the top of the file (after imports)
  2. If parent inheritance is supported, it'd be much easier to maintain a templated page title, for example {page name} | Site Name.
  3. Cleaner and improved DX
  4. Less imports, i don't need to import bunch of components for metadata like Title, Link, Meta

I believe that this isn't going to be priority for solidjs team, but i hope this will be considered by the team as a way to improve dx. Thanks!

@raflymln raflymln added the enhancement New feature or request label Aug 19, 2024
@ryansolid
Copy link
Member

Thing I wonder about this always is how does async data fit into this. Like if the title is based on say a user you need to load. I'm unclear what the desired timing is etc..

@Brendonovich
Copy link
Contributor

The Next solution to async data is to allow exporting either a metadata constant or a generateMetadata function that can be async that blocks HTML streaming

@raflymln
Copy link
Author

Well async is there if you implement the generateMetadata function, and because of that, I hope at least the static metadata will be implemented for now

As for generateMetadata, it's basically only supported on server, basically it'd be executed first before streaming the HTML to the client, so if you got a long duration function in the generateMetadata function, the page will be loaded longer, kind like PHP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants