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

added dynamic meta export to events_$eventId and groups_.$groupId components #163

Merged
merged 8 commits into from
Jun 25, 2024

Conversation

CamilingJS
Copy link
Contributor

@CamilingJS CamilingJS commented May 30, 2024

Issue: #

Summary (1-2 sentences)

Added dynamic meta export to the events_$eventId and groups_.$groupId components. Using the data object, I display the event name as the title and the event description in the meta description.

Details (reason and description of the changes)

Enhances the SEO for this page.

Challenges (what problems did I face?) (optional)

Had TS compliance issues. Ended up inferring the type of data in the MetaFunction per suggestion below.

Copy link

vercel bot commented May 30, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
plan-it-social-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 19, 2024 8:53am

@@ -102,3 +102,12 @@ export function ErrorBoundary() {
const { eventId } = useParams();
return <div className="error-container">There was an error loading event by the id {eventId}.</div>;
}

export const meta: MetaFunction = ({ data }) => {
const eventFullName = data.event.name;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check out this section in the Remix docs: https://remix.run/docs/en/main/route/meta#data.

You can use the loader function to infer the type of data!

shami-dev
shami-dev previously approved these changes Jun 19, 2024
Copy link
Contributor

@shami-dev shami-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Bravo!
Left just non-blocking comments.

@@ -126,3 +126,12 @@ export function ErrorBoundary() {
const { eventId } = useParams();
return <div className="error-container">There was an error loading event by the id {eventId}.</div>;
}

export const meta: MetaFunction<typeof loader> = ({ data }) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: Can we move Metafunction to the top? 🙂 I feel it should be there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!


export const meta: MetaFunction<typeof loader> = ({ data }) => {
const eventFullName = data.event.name;
const regex = /^[^:]+/;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a blocker: Why do we need regex? If it's necessary, should we place a tiny comment on what it does?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there's a title in the format 'Tech Talks: Exploring the Latest Web Development Trends', it will only take the text before the colon.

const eventName = eventFullName.match(regex);
const eventDescription = data.event.description;

return [{ title: `${eventName} | Social Plan-It` }, { name: 'description', content: `${eventDescription}` }];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great boost of SEO!
Another NIT: Should we shorten the title if it's lengthy?

@CamilingJS CamilingJS changed the title added dynamic meta export to events_$eventId component added dynamic meta export to events_$eventId and groups_.$groupId components Jun 19, 2024
Copy link
Contributor

@shami-dev shami-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super!

export async function loader({ params }: LoaderFunctionArgs) {
export const meta: MetaFunction<typeof loader> = ({ data }) => {
const eventFullName = data.event.name;
const regex = /^[^:]+/;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: is there a reason we cleaning up only : , or should we go further and only allow a-z A-Z 0-9

Copy link
Contributor

@eiffelwong1 eiffelwong1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@andrelandgraf andrelandgraf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding the meta tags!

const eventName = eventFullName.match(regex);
const eventDescription = data.event.description;

return [{ title: `${eventName} | Social Plan-It` }, { name: 'description', content: `${eventDescription}` }];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return [{ title: `${eventName} | Social Plan-It` }, { name: 'description', content: `${eventDescription}` }];
return [{ title: `${eventName} | Social Plan-It` }, { name: 'description', content: eventDescription }];

export const meta: MetaFunction<typeof loader> = ({ data }) => {
const group = data.group;

return [{ title: `${group.name} | Social Plan-It` }, { name: 'description', content: `${group.description}` }];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return [{ title: `${group.name} | Social Plan-It` }, { name: 'description', content: `${group.description}` }];
return [{ title: `${group.name} | Social Plan-It` }, { name: 'description', content: group.description }];

@CamilingJS CamilingJS merged commit 1bd23f6 into main Jun 25, 2024
4 checks passed
@CamilingJS CamilingJS deleted the dynamic-meta-export branch June 25, 2024 01:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants