|
1 | 1 | import React from "react"; |
2 | 2 | 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"; |
4 | 11 |
|
5 | 12 | 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 | + }; |
6 | 63 | return ( |
7 | 64 | <Helmet> |
8 | 65 | <title>{seo.title}</title> |
9 | 66 | <meta name="description" content={seo.description} /> |
10 | 67 | <meta property="og:title" content={seo?.og?.title} /> |
11 | 68 | <meta property="og:type" content={seo?.og?.type} /> |
12 | 69 | <meta property="og:url" content={seo?.og?.url} /> |
| 70 | + <script type="application/ld+json">{JSON.stringify(data)}</script> |
13 | 71 | </Helmet> |
14 | 72 | ); |
15 | 73 | } |
|
0 commit comments