Skip to content

Commit 95dfa69

Browse files
authored
Merge pull request #289 from CivicDataLab/284-seo-setup
Add JSON-LD schema
2 parents 4e8ac1f + ba1d27e commit 95dfa69

File tree

14 files changed

+577
-338
lines changed

14 files changed

+577
-338
lines changed

app/[locale]/(user)/about-us/page.tsx

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import Image from 'next/image';
22
import { Text } from 'opub-ui';
33

4-
import { generatePageMetadata } from '@/lib/utils';
4+
import { generateJsonLd, generatePageMetadata } from '@/lib/utils';
55
import BreadCrumbs from '@/components/BreadCrumbs';
6+
import JsonLd from '@/components/JsonLd';
67
import Team from './components/Team';
78

89
export const generateMetadata = () =>
@@ -34,8 +35,30 @@ export const generateMetadata = () =>
3435
});
3536

3637
const About = () => {
38+
const jsonLd = generateJsonLd({
39+
'@context': 'https://schema.org',
40+
'@type': 'AboutPage',
41+
name: 'About CivicDataSpace',
42+
url: `${process.env.NEXT_PUBLIC_PLATFORM_URL}/about`,
43+
description:
44+
'Learn more about CivicDataSpace – an open-source platform enabling data collaboratives and civic innovation for the public good.',
45+
about: {
46+
'@type': 'WebApplication',
47+
name: 'CivicDataSpace',
48+
url: `${process.env.NEXT_PUBLIC_PLATFORM_URL}/about`,
49+
description:
50+
'CivicDataSpace is an open-source platform that enables inclusive, interoperable, and AI-ready data collaboratives to drive public good.',
51+
},
52+
publisher: {
53+
'@type': 'Organization',
54+
name: 'CivicDataLab',
55+
url: `${process.env.NEXT_PUBLIC_PLATFORM_URL}/about`,
56+
},
57+
});
58+
3759
return (
3860
<main>
61+
<JsonLd json={jsonLd} />
3962
<BreadCrumbs
4063
data={[
4164
{ href: '/', label: 'Home' },

app/[locale]/(user)/datasets/[datasetIdentifier]/DatasetDetailsPage.tsx

Lines changed: 53 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import { useQuery } from '@tanstack/react-query';
66
import { Spinner } from 'opub-ui';
77

88
import { GraphQL } from '@/lib/api';
9+
import { generateJsonLd } from '@/lib/utils';
910
import BreadCrumbs from '@/components/BreadCrumbs';
11+
import JsonLd from '@/components/JsonLd';
1012
import Details from './components/Details';
1113
import Metadata from './components/Metadata';
1214
import PrimaryData from './components/PrimaryData';
@@ -74,49 +76,60 @@ export default function DatasetDetailsPage({
7476
}) {
7577
const Datasetdetails: { data: any; isLoading: any } = useQuery(
7678
[`details_${datasetId}`],
77-
() =>
78-
GraphQL(
79-
datasetQuery,
80-
{},
81-
{ datasetId: datasetId }
82-
)
79+
() => GraphQL(datasetQuery, {}, { datasetId: datasetId })
8380
);
8481

82+
const jsonLd = generateJsonLd({
83+
'@context': 'https://schema.org',
84+
'@type': 'Dataset',
85+
name: Datasetdetails?.data?.getDataset?.title,
86+
url: `${process.env.NEXT_PUBLIC_PLATFORM_URL}/datasets/${datasetId}`,
87+
description: Datasetdetails?.data?.getDataset?.description,
88+
publisher: {
89+
'@type': 'Organization',
90+
name: 'CivicDataSpace',
91+
url: `${process.env.NEXT_PUBLIC_PLATFORM_URL}/datasets`,
92+
},
93+
});
94+
8595
return (
86-
<main className=" bg-surfaceDefault">
87-
<BreadCrumbs
88-
data={[
89-
{ href: '/', label: 'Home' },
90-
{ href: '/datasets', label: 'Dataset Listing' },
91-
{ href: '#', label: 'Dataset Details' },
92-
]}
93-
/>
94-
<div className="flex">
95-
<div className="w-full gap-10 border-r-2 border-solid border-greyExtralight p-6 lg:w-3/4 lg:p-10">
96-
{Datasetdetails.isLoading ? (
97-
<div className=" mt-8 flex justify-center">
98-
<Spinner />
99-
</div>
100-
) : (
101-
<PrimaryData
102-
data={Datasetdetails?.data?.getDataset}
103-
isLoading={Datasetdetails.isLoading}
104-
/>
105-
)}
106-
<Details />
107-
<Resources />
108-
<SimilarDatasets />
109-
</div>
110-
<div className=" hidden w-1/4 gap-10 px-7 py-10 lg:block">
111-
{Datasetdetails.isLoading ? (
112-
<div className=" mt-8 flex justify-center">
113-
<Spinner />
114-
</div>
115-
) : (
116-
<Metadata data={Datasetdetails?.data?.getDataset} />
117-
)}
96+
<>
97+
<JsonLd json={jsonLd} />
98+
<main className=" bg-surfaceDefault">
99+
<BreadCrumbs
100+
data={[
101+
{ href: '/', label: 'Home' },
102+
{ href: '/datasets', label: 'Dataset Listing' },
103+
{ href: '#', label: 'Dataset Details' },
104+
]}
105+
/>
106+
<div className="flex">
107+
<div className="w-full gap-10 border-r-2 border-solid border-greyExtralight p-6 lg:w-3/4 lg:p-10">
108+
{Datasetdetails.isLoading ? (
109+
<div className=" mt-8 flex justify-center">
110+
<Spinner />
111+
</div>
112+
) : (
113+
<PrimaryData
114+
data={Datasetdetails?.data?.getDataset}
115+
isLoading={Datasetdetails.isLoading}
116+
/>
117+
)}
118+
<Details />
119+
<Resources />
120+
<SimilarDatasets />
121+
</div>
122+
<div className=" hidden w-1/4 gap-10 px-7 py-10 lg:block">
123+
{Datasetdetails.isLoading ? (
124+
<div className=" mt-8 flex justify-center">
125+
<Spinner />
126+
</div>
127+
) : (
128+
<Metadata data={Datasetdetails?.data?.getDataset} />
129+
)}
130+
</div>
118131
</div>
119-
</div>
120-
</main>
132+
</main>
133+
</>
121134
);
122135
}

app/[locale]/(user)/datasets/[datasetIdentifier]/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export async function generateMetadata({
4040
locale: 'en_US',
4141
url: `${process.env.NEXT_PUBLIC_PLATFORM_URL}/datasets/${params.datasetIdentifier}`,
4242
title: dataset?.title,
43-
description: dataset?.description,
43+
description: dataset?.description,
4444
siteName: 'CivicDataSpace',
4545
image: `${process.env.NEXT_PUBLIC_PLATFORM_URL}/og.png`,
4646
},

app/[locale]/(user)/datasets/page.tsx

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22

3-
import { generatePageMetadata } from '@/lib/utils';
3+
import { generateJsonLd, generatePageMetadata } from '@/lib/utils';
4+
import JsonLd from '@/components/JsonLd';
45
import ListingComponent from '../components/ListingComponent';
56

67
export const generateMetadata = () =>
@@ -34,13 +35,30 @@ const DatasetsListing = () => {
3435
{ href: '#', label: 'Dataset Listing' },
3536
];
3637

38+
const jsonLd = generateJsonLd({
39+
'@context': 'https://schema.org',
40+
'@type': 'CollectionPage',
41+
name: 'Browse Open Datasets | CivicDataSpace',
42+
url: `${process.env.NEXT_PUBLIC_PLATFORM_URL}/datasets`,
43+
description:
44+
'Explore a wide range of public datasets for research, policy, and civic innovation.',
45+
publisher: {
46+
'@type': 'Organization',
47+
name: 'CivicDataSpace',
48+
url: `${process.env.NEXT_PUBLIC_PLATFORM_URL}/datasets`,
49+
},
50+
});
51+
3752
return (
38-
<ListingComponent
39-
type="dataset"
40-
breadcrumbData={breadcrumbData}
41-
redirectionURL={`/datasets`}
42-
placeholder="Start typing to search for any Dataset"
43-
/>
53+
<>
54+
<JsonLd json={jsonLd} />
55+
<ListingComponent
56+
type="dataset"
57+
breadcrumbData={breadcrumbData}
58+
redirectionURL={`/datasets`}
59+
placeholder="Start typing to search for any Dataset"
60+
/>
61+
</>
4462
);
4563
};
4664

app/[locale]/(user)/page.tsx

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { generatePageMetadata } from '@/lib/utils';
1+
import { generateJsonLd, generatePageMetadata } from '@/lib/utils';
2+
import JsonLd from '@/components/JsonLd';
23
import { Content } from './components/Content';
34
import Datasets from './components/Datasets';
45
import Sectors from './components/Sectors';
@@ -17,7 +18,7 @@ export const generateMetadata = () =>
1718
'AI-ready data',
1819
'CivicTech',
1920
'CivicDataLab',
20-
],
21+
],
2122
openGraph: {
2223
type: 'website',
2324
locale: 'en_US',
@@ -31,12 +32,38 @@ export const generateMetadata = () =>
3132
});
3233

3334
export default async function Home() {
35+
const jsonLd = generateJsonLd({
36+
'@context': 'https://schema.org',
37+
'@type': 'WebSite',
38+
name: 'CivicDataSpace',
39+
url: `${process.env.NEXT_PUBLIC_PLATFORM_URL}`,
40+
description:
41+
'CivicDataSpace is an open-source platform that enables AI-ready data collaboratives and empowers public good through inclusive civic datasets and use cases.',
42+
publisher: {
43+
'@type': 'Organization',
44+
name: 'CivicDataLab',
45+
url: `${process.env.NEXT_PUBLIC_PLATFORM_URL}/about`,
46+
logo: {
47+
'@type': 'ImageObject',
48+
url: `${process.env.NEXT_PUBLIC_PLATFORM_URL}/cdl_logo.png`,
49+
},
50+
},
51+
potentialAction: {
52+
'@type': 'SearchAction',
53+
target: `${process.env.NEXT_PUBLIC_PLATFORM_URL}/datasets?query={search_term_string}`,
54+
'query-input': 'required name=search_term_string',
55+
},
56+
});
57+
3458
return (
35-
<div className="bg-surfaceDefault">
36-
<Content />
37-
<UseCases />
38-
<Sectors />
39-
<Datasets />
40-
</div>
59+
<>
60+
<JsonLd json={jsonLd} />
61+
<div className="bg-surfaceDefault">
62+
<Content />
63+
<UseCases />
64+
<Sectors />
65+
<Datasets />
66+
</div>
67+
</>
4168
);
4269
}

0 commit comments

Comments
 (0)