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

feat: add dynamic route titles in FAST-Router #6325

Open
KingOfTac opened this issue Aug 26, 2022 · 3 comments
Open

feat: add dynamic route titles in FAST-Router #6325

KingOfTac opened this issue Aug 26, 2022 · 3 comments
Assignees
Labels
area:fast-router Pertains to fast-router feature A new feature status:planned Work is planned

Comments

@KingOfTac
Copy link
Collaborator

🙋 Feature Request

A nice feature I think would be the ability to interpolate route parameters into the title.

🤔 Expected Behavior

The ability to do something like this:

{ path: 'products/{productName}', title: '{productName}' }

😯 Current Behavior

The above code would produce "{productName}" as the page title.

💁 Possible Solution

Since this is all happening in the route mapping, I think all that is required is to check if the childTitle contains a match for the route parameter and interpolate the value. Much like it already does for the path.

🔦 Context

A common pattern for things like products and blog posts is to set the page title to the title of the product or post in addition to some other text.

💻 Examples

Newegg product listing
image

Post on Medium
image

@KingOfTac KingOfTac added status:triage New Issue - needs triage area:fast-router Pertains to fast-router labels Aug 26, 2022
@KingOfTac KingOfTac self-assigned this Aug 26, 2022
@KingOfTac KingOfTac removed the status:triage New Issue - needs triage label Aug 26, 2022
@KingOfTac
Copy link
Collaborator Author

I self-assigned this; however, I'd like to get other people's thoughts on the feature before starting on anything.

@KingOfTac KingOfTac removed their assignment Nov 6, 2022
@cedx
Copy link

cedx commented Jul 22, 2024

Yes, we definitely need it. I'm currently using a dedicated component just to update the title... not very optimized (as a result, the document title is updated twice).

@KingOfTac
Copy link
Collaborator Author

Yes, we definitely need it. I'm currently using a dedicated component just to update the title... not very optimized (as a result, the document title is updated twice).

I created a method to do this recently in another project that involves hooking into the router's internals and creating a custom title builder. Unfortunately, it's hard to do right now because the types needed are all internal, but the router could be updated to export the interfaces and types.

I can submit a PR for review by the team sometime this week.

@KingOfTac KingOfTac self-assigned this Jul 22, 2024
@KingOfTac KingOfTac added feature A new feature status:planned Work is planned labels Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:fast-router Pertains to fast-router feature A new feature status:planned Work is planned
Projects
None yet
Development

No branches or pull requests

2 participants