-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
feat: add dynamic metadata for search results #842
base: main
Are you sure you want to change the base?
feat: add dynamic metadata for search results #842
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
4a2c649
to
e22c518
Compare
e22c518
to
5ff089f
Compare
Just noting for future reference, some test values:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 This is looking great, thank you so much! Really excited to finally fix this darn accessibility/title bug.
Left a few comments and I think only about half of them are actually blockers. LMK what you think! 🙌
|
||
import { metadata as defaultMetadata } from "./layout"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Non-Actionable] It would be nice if this had an image... but that's definitely out of scope for this PR 😄. Probably a lot more work. I don't even know what that image would look like.
Opinion: someone should file a feature request issue after this suggesting adding image(s) to the metadata. If you want to, awesome - but I can if you don't have time. 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great suggestion! I went ahead and created a PR 😄
}; | ||
let result: Error | EstimatedPackage[] | undefined; | ||
export async function generateMetadata({ searchParams }: HomeProps) { | ||
const { options, result } = await fetchData(searchParams); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Question] Now there are two calls to the Tidelift API per page load 😬. That's probably not ideal? But I don't do enough Next.js app layout code to know the right pattern for this. Do you know if there's a good way to deduplicate? Surely something in Next.js handles this well.
export async function generateMetadata({ searchParams }: HomeProps) { | ||
const { options, result } = await fetchData(searchParams); | ||
const username = options.username || ""; | ||
const packageCount = Array.isArray(result) ? result.length : 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Non-Actionable] Noting from QA: there's no way in the tidelift-me-up package to know that the reason for no packages is that the user didn't exist. Tracked here: JoshuaKGoldberg/tidelift-me-up#17. So, explicitly saying I don't think we need to block the PR on giving a specific description for that. IF you really want to get that in first I'm ok waiting, but otherwise by default I'd just suggest we go with a followup issue. What do you think?
Could not find {username} on npm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with not blocking this PR and instead creating a follow up issue to address this bug. I went ahead and created an issue so this can be fixed when the tidelift-me-up package is updated.
PR Checklist
status: accepting prs
Overview
This PR introduces dynamic metadata generation for the home/search page. It's metadata is now dynamically generated based on the
searchParams
in the URL:This includes when a valid user has 0 packages eligible for funding based on search parameters. The metadata will look like the following:
When no
searchParams
are provided, the default metadata is used, which is defined inlayout.tsx
:Also, something to note is that the API-related logic that was in
page.tsx
has been extracted into a separate file to improve code readability and maintainability.