Skip to content

Commit

Permalink
Fix SEO
Browse files Browse the repository at this point in the history
  • Loading branch information
micorix committed Mar 25, 2023
1 parent 39798e7 commit cd952f4
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 10 deletions.
13 changes: 12 additions & 1 deletion src/Seo.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { DefaultSeo as DefaultNextSeo, DefaultSeoProps } from 'next-seo';
import { DefaultSeo as DefaultNextSeo, DefaultSeoProps, NextSeo, NextSeoProps } from 'next-seo';
import { publicRuntimeConfig } from './runtimeConfig';
import { AppearanceConfig } from './config/types';
import { FC } from 'react';

const { APP_ENVIRONMENT } = publicRuntimeConfig;

Expand All @@ -13,4 +15,13 @@ export const defaultSeoConfig: DefaultSeoProps = {
},
};

interface ProjectSpecificSeoProps extends NextSeoProps {
appearanceConfig: AppearanceConfig;
}

export const ProjectSpecificSeo: FC<ProjectSpecificSeoProps> = ({ appearanceConfig, ...props }) => {
const titleTemplate = `%s | po8klasie ${appearanceConfig.appName}`;
return <NextSeo titleTemplate={titleTemplate} {...props} />;
};

export const DefaultSeo = () => <DefaultNextSeo {...defaultSeoConfig} />;
2 changes: 1 addition & 1 deletion src/config/gdynia/appearance.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AppearanceConfig } from '../types';

const appearanceConfig: AppearanceConfig = {
appName: 'gdynia',
appName: 'Gdynia',
};

export default appearanceConfig;
2 changes: 1 addition & 1 deletion src/config/krakow/appearance.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AppearanceConfig } from '../types';

const appearanceConfig: AppearanceConfig = {
appName: 'kraków',
appName: 'Kraków',
};

export default appearanceConfig;
2 changes: 1 addition & 1 deletion src/config/warszawa/appearance.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AppearanceConfig } from '../types';

const appearanceConfig: AppearanceConfig = {
appName: 'warszawa',
appName: 'Warszawa',
};

export default appearanceConfig;
5 changes: 3 additions & 2 deletions src/pages/[projectID]/calculator.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { FC } from 'react';
import { NextSeo } from 'next-seo';
import { AiOutlineWarning } from '@react-icons/all-files/ai/AiOutlineWarning';
import AppLayout from '../../components/app/AppLayout';
import Calculator from '../../components/calculator/Calculator';
Expand All @@ -8,11 +7,13 @@ import { GetServerSidePropsContext, GetServerSidePropsResult } from 'next';
import { ProjectConfig } from '../../config/types';
import { DehydratedState } from '@tanstack/react-query';
import { getProjectConfigProps } from '../../config/nextHelpers';
import { ProjectSpecificSeo } from '../../Seo';

const CalculatorPage: FC = ({ PROJECT }) => {
return (
<AppLayout projectAppearance={PROJECT.appearance}>
<NextSeo
<ProjectSpecificSeo
appearanceConfig={PROJECT.appearance}
title="Kalkulator punktów"
description="Oblicz swoje punkty rekrutacyjne z kalkulatorem punktów wyszukiwarki szkół średnich po8klasie"
/>
Expand Down
7 changes: 7 additions & 0 deletions src/pages/[projectID]/compare.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,16 @@ import { getProjectConfigProps } from '../../config/nextHelpers';
import withProjectConfig from '../../config/withProjectConfig';
import AppLayout from '../../components/app/AppLayout';
import ComparisonPage from '../../components/app/ComparisonPage/ComparisonPage';
import { ProjectSpecificSeo } from '../../Seo';
import React from 'react';

const ProjectComparisonPage = ({ PROJECT }) => (
<AppLayout projectAppearance={PROJECT.appearance} className="min-h-[100vh]">
<ProjectSpecificSeo
appearanceConfig={PROJECT.appearance}
title="Porównywarka szkół"
description="Porównaj szkoły z porównywarką wyszukiwarki szkół średnich po8klasie"
/>
<ComparisonPage />
</AppLayout>
);
Expand Down
3 changes: 3 additions & 0 deletions src/pages/[projectID]/favorites.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ import { getProjectConfigProps } from '../../config/nextHelpers';
import withProjectConfig from '../../config/withProjectConfig';
import AppLayout from '../../components/app/AppLayout';
import FavoritesPage from '../../components/app/FavoritesPage/FavoritesPage';
import { ProjectSpecificSeo } from '../../Seo';
import React from 'react';

const ProjectFavoritesPage = ({ PROJECT }) => (
<AppLayout projectAppearance={PROJECT.appearance} className="min-h-[100vh]">
<ProjectSpecificSeo appearanceConfig={PROJECT.appearance} title="Ulubione szkoły" />
<FavoritesPage />
</AppLayout>
);
Expand Down
3 changes: 3 additions & 0 deletions src/pages/[projectID]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ import { getProjectConfigProps } from '../../config/nextHelpers';
import withProjectConfig from '../../config/withProjectConfig';
import AppLayout from '../../components/app/AppLayout';
import ProjectDashboardPage from '../../components/app/ProjectDashboardPage/ProjectDashboardPage';
import { ProjectSpecificSeo } from '../../Seo';
import React from 'react';

const ProjectIndexPage = ({ PROJECT }) => (
<AppLayout projectAppearance={PROJECT.appearance} className="h-full">
<ProjectSpecificSeo appearanceConfig={PROJECT.appearance} title="Dashboard" />
<ProjectDashboardPage />
</AppLayout>
);
Expand Down
11 changes: 9 additions & 2 deletions src/pages/[projectID]/map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,17 @@ import { getProjectConfigProps } from '../../config/nextHelpers';
import withProjectConfig from '../../config/withProjectConfig';
import { SelectedSchoolProvider } from '../../hooks/useSelectedSchool';
import MapSearchPageInternals from '../../components/app/MapSearchPage/MapSearchPage';
import { ProjectSpecificSeo } from '../../Seo';
import React from 'react';

const MapSearchPage = () => {
const MapSearchPage = ({ PROJECT }) => {
return (
<AppLayout wideNavbar noFooter className="h-full">
<AppLayout projectAppearance={PROJECT.appearance} wideNavbar noFooter className="h-full">
<ProjectSpecificSeo
appearanceConfig={PROJECT.appearance}
title="Mapa szkół"
description="Wyszukaj szkoły średnie z po8klasie"
/>
<div className="w-full h-full">
<SelectedSchoolProvider>
<MapSearchPageInternals />
Expand Down
4 changes: 2 additions & 2 deletions src/pages/[projectID]/school/[schoolID].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import SchoolHero from '../../../components/app/SchoolPage/SchoolHero';
import SchoolPageContent from '../../../components/app/SchoolPage/SchoolPageContent';
import { ISchoolData } from '../../../types';
import { ProjectConfig } from '../../../config/types';
import { NextSeo } from 'next-seo';
import useSingleSchoolData, { createSingleSchoolDataQueryKey } from '../../../api/singleSchool';
import { useRouter } from 'next/router';
import { dehydrate, DehydratedState, QueryClient } from '@tanstack/react-query';
import { queryClientOptions } from '../../../api/queryClient';
import { ProjectSpecificSeo } from '../../../Seo';

interface SchoolPageProps extends ProjectConfigConsumerProps<'appearance' | 'schoolInfo'> {
school: ISchoolData;
Expand All @@ -24,7 +24,7 @@ const SchoolPage: FC<SchoolPageProps> = ({ PROJECT: { appearance, schoolInfo } }

return (
<AppLayout projectAppearance={appearance}>
<NextSeo title={appearance.appName} />
<ProjectSpecificSeo appearanceConfig={appearance} title={(school as ISchoolData).name} />
<SchoolHero school={school as ISchoolData} />
<SchoolPageContent schoolInfoConfig={schoolInfo} school={school as ISchoolData} />
</AppLayout>
Expand Down

0 comments on commit cd952f4

Please sign in to comment.