Skip to content

Commit

Permalink
Try to enable dynamic page titles alongside SSR
Browse files Browse the repository at this point in the history
  • Loading branch information
AbhiramTadepalli committed Nov 20, 2024
1 parent e26529b commit 9557009
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/pages/dashboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,12 @@ function createColorMap(courses: SearchQuery[]): { [key: string]: string } {
export async function getServerSideProps(
context: NextPageContext,
): Promise<{ props: { pageTitle: string } }> {
const searchTerms22 = context.query.searchTerms;
const searchTerms = context.query.searchTerms;
let pageTitle = '';
if (searchTerms22 === undefined) pageTitle = '';
else if (typeof searchTerms22 === 'string') pageTitle = searchTerms22;
if (searchTerms === undefined) pageTitle = '';
else if (typeof searchTerms === 'string') pageTitle = searchTerms;
else
searchTerms22.map((term) => {
searchTerms.map((term) => {
pageTitle += term + ', ';
});
pageTitle = pageTitle.slice(0, -2) + (pageTitle.length > 0 ? ' - ' : '');
Expand Down Expand Up @@ -817,6 +817,15 @@ export const Dashboard: NextPage<{ pageTitle: string }> = ({
);
}

pageTitle = '';
courses.map((term) => {
pageTitle += searchQueryLabel(term) + ', ';
});
professors.map((term) => {
pageTitle += searchQueryLabel(term) + ', ';
});
pageTitle = pageTitle.slice(0, -2) + (pageTitle.length > 0 ? ' - ' : '');

/* Final page */

return (
Expand Down

0 comments on commit 9557009

Please sign in to comment.