NextJS app router metadata problem
Unanswered
Brewer's Blackbird posted this in #help-forum
Brewer's BlackbirdOP
Hello everyone again!
Once again I ask for help with the new App Router approach and more precisely the declared function generateMetadata. Backend dev sends me metadata data in this format:
As you can see, this is very different from what is returned as a Metadata object in nextJS. Here you indicate the tag that should be there, attributes, content, etc.
I deeply respect the desire to do everything in one consistent format, including metadata. However, this is not very useful when I need to further customize the metadata tags.
We really don’t want to remake this structure to match the one that should be returned in generateMetadata.
But with this approach,I have to anticipate and to map through all the data coming from the backend and adjust it to the desired structure.
Previously, in the Page Router approach, I simply rendered these tags inside the component
But is this no longer possible in the App Router approach?
Thank you!
Once again I ask for help with the new App Router approach and more precisely the declared function generateMetadata. Backend dev sends me metadata data in this format:
"metaTags": {
"title": {
"#tag": "meta",
"#attributes": {
"name": "title",
"content": "Title main text"
}
},
"canonical_url": {
"#tag": "link",
"#attributes": {
"rel": "canonical",
"href": "test.com/href"
}
}
},As you can see, this is very different from what is returned as a Metadata object in nextJS. Here you indicate the tag that should be there, attributes, content, etc.
I deeply respect the desire to do everything in one consistent format, including metadata. However, this is not very useful when I need to further customize the metadata tags.
We really don’t want to remake this structure to match the one that should be returned in generateMetadata.
But with this approach,I have to anticipate and to map through all the data coming from the backend and adjust it to the desired structure.
Previously, in the Page Router approach, I simply rendered these tags inside the component
<Head></Head>But is this no longer possible in the App Router approach?
Thank you!
1 Reply
Brewer's BlackbirdOP
Yes, I see that I can do this. But this is still highly undesirable, am I right?
Well, we have no other choice.
Well, we have no other choice.