Skip to content

Commit

Permalink
refactor: PageMetatags
Browse files Browse the repository at this point in the history
  • Loading branch information
bigint committed Jun 25, 2024
1 parent 5920c31 commit 90a6115
Showing 1 changed file with 31 additions and 45 deletions.
76 changes: 31 additions & 45 deletions apps/web/src/components/Shared/PageMetatags.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,54 +8,40 @@ import MetaTags from '../Common/MetaTags';
const PageMetatags: FC = () => {
const { pathname } = useRouter();

const getOg = () => {
switch (pathname) {
case '/signup': {
return {
description: `Signup on ${APP_NAME} to create, share and discover content.`,
title: `Signup • ${APP_NAME}`
};
}
case '/explore': {
return {
description: `Explore top commented, collected and latest publications in the ${APP_NAME}.`,
title: `Explore • ${APP_NAME}`
};
}
case '/privacy': {
return {
description: `Privacy Policy of ${APP_NAME}.`,
title: `Privacy Policy • ${APP_NAME}`
};
}
case '/rules': {
return {
description: `Rules of ${APP_NAME}.`,
title: `Rules • ${APP_NAME}`
};
}
case '/terms': {
return {
description: `Terms & Conditions of ${APP_NAME}.`,
title: `Terms & Conditions • ${APP_NAME}`
};
}
case '/thanks': {
return {
description: `Thanks to all the people and projects that have supported ${APP_NAME}.`,
title: `Thanks • ${APP_NAME}`
};
}
default: {
return {
description: DESCRIPTION,
title: APP_NAME
};
}
const ogData: Record<string, { description: string; title: string }> = {
'/explore': {
description: `Explore top commented, collected and latest publications in the ${APP_NAME}.`,
title: `Explore • ${APP_NAME}`
},
'/privacy': {
description: `Privacy Policy of ${APP_NAME}.`,
title: `Privacy Policy • ${APP_NAME}`
},
'/rules': {
description: `Rules of ${APP_NAME}.`,
title: `Rules • ${APP_NAME}`
},
'/signup': {
description: `Signup on ${APP_NAME} to create, share and discover content.`,
title: `Signup • ${APP_NAME}`
},
'/terms': {
description: `Terms & Conditions of ${APP_NAME}.`,
title: `Terms & Conditions • ${APP_NAME}`
},
'/thanks': {
description: `Thanks to all the people and projects that have supported ${APP_NAME}.`,
title: `Thanks • ${APP_NAME}`
},
default: {
description: DESCRIPTION,
title: APP_NAME
}
};

return <MetaTags description={getOg().description} title={getOg().title} />;
const { description, title } = ogData[pathname] || ogData.default;

return <MetaTags description={description} title={title} />;
};

export default PageMetatags;

0 comments on commit 90a6115

Please sign in to comment.