Skip to content

Commit 1a6a95d

Browse files
cdigruttolaCarmine Di Gruttola
andauthored
add json schemaorg in SEO (#292)
* add json schemaorg * fix on url and name --------- Co-authored-by: Carmine Di Gruttola <[email protected]>
1 parent 22664b3 commit 1a6a95d

File tree

2 files changed

+65
-1
lines changed

2 files changed

+65
-1
lines changed

src/components/seoHeader/SeoHeader.js

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,73 @@
11
import React from "react";
22
import { Helmet } from "react-helmet";
3-
import { seo } from "../../portfolio.js";
3+
import {
4+
greeting,
5+
seo,
6+
socialMediaLinks,
7+
experience,
8+
contactPageData,
9+
certifications,
10+
} from "../../portfolio.js";
411

512
function SeoHeader() {
13+
let sameAs = [];
14+
socialMediaLinks
15+
.filter(
16+
(media) =>
17+
!(media.link.startsWith("tel") || media.link.startsWith("mailto"))
18+
)
19+
.forEach((media) => {
20+
sameAs.push(media.link);
21+
});
22+
23+
let mail = socialMediaLinks
24+
.find((media) => media.link.startsWith("mailto"))
25+
.link.substring("mailto:".length);
26+
let job = experience.sections
27+
?.find((section) => section.work)
28+
?.experiences?.at(0);
29+
30+
let credentials = [];
31+
certifications.certifications.forEach((certification) => {
32+
credentials.push({
33+
"@context": "https://schema.org",
34+
"@type": "EducationalOccupationalCredential",
35+
url: certification.certificate_link,
36+
name: certification.title,
37+
description: certification.subtitle,
38+
});
39+
});
40+
const data = {
41+
"@context": "https://schema.org/",
42+
"@type": "Person",
43+
name: greeting.title,
44+
url: seo?.og?.url,
45+
email: mail,
46+
telephone: contactPageData.phoneSection?.subtitle,
47+
sameAs: sameAs,
48+
jobTitle: job.title,
49+
worksFor: {
50+
"@type": "Organization",
51+
name: job.company,
52+
},
53+
address: {
54+
"@type": "PostalAddress",
55+
addressLocality: contactPageData.addressSection?.locality,
56+
addressRegion: contactPageData.addressSection?.region,
57+
addressCountry: contactPageData.addressSection?.country,
58+
postalCode: contactPageData.addressSection?.postalCode,
59+
streetAddress: contactPageData.addressSection?.streetAddress,
60+
},
61+
hasCredential: credentials,
62+
};
663
return (
764
<Helmet>
865
<title>{seo.title}</title>
966
<meta name="description" content={seo.description} />
1067
<meta property="og:title" content={seo?.og?.title} />
1168
<meta property="og:type" content={seo?.og?.type} />
1269
<meta property="og:url" content={seo?.og?.url} />
70+
<script type="application/ld+json">{JSON.stringify(data)}</script>
1371
</Helmet>
1472
);
1573
}

src/portfolio.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,7 @@ const experience = {
531531
sections: [
532532
{
533533
title: "Work",
534+
work: true,
534535
experiences: [
535536
{
536537
title: "Associate AI Engineer",
@@ -749,6 +750,11 @@ const contactPageData = {
749750
title: "Address",
750751
subtitle:
751752
"Ambavadi vas, Kanodar, T.A.-Palanpur, Dist.-Banaskantha, Gujarat - 385520",
753+
locality: "Kanodar",
754+
country: "IN",
755+
region: "Gujarat",
756+
postalCode: "385520",
757+
streetAddress: "Ambavadi vas",
752758
avatar_image_path: "address_image.svg",
753759
location_map_link: "https://goo.gl/maps/MpMqtRZytFchMkZ76",
754760
},

0 commit comments

Comments
 (0)