Seo.js
1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import { cleanImage } from "@/layout/imageHandling";
import Head from "next/head";
import React from "react";
const Seo = (props) => {
  const imgUrl = cleanImage(props?.seo?.metaImage?.data?.attributes?.url);
  const schema = props?.seo?.schema;
  // console.log("seo", props);
  return (
  <Head>
      <title>
        {props?.seo?.metaTitle == null ? props?.seo?.metaTitle : props?.seo?.metaTitle}
      </title>
      <meta
        name="keywords"
        content={props?.seo?.keywords == null ? "" : props?.seo?.keywords}
      />
      <meta
        name="description"
        content={
          props?.seo?.metaDescription == null ? "" : props?.seo?.metaDescription
        }
      />
      <link
        rel="canonical"
        href={props?.seo?.canonicalURL == null ? "" : props?.seo?.canonicalURL}
      />
      <meta
        name="robots"
        content={props?.seo?.metaRobots == null ? "" : props?.seo?.metaRobots}
      />
      <meta
        property="og:title"
        content={props?.seo?.metaTitle == null ? "" : props?.seo?.metaTitle}
      />
      <meta
        property="og:description"
        content={
          props?.seo?.metaDescription == null ? "" : props?.seo?.metaDescription
        }
      />
      <meta
        property="og:url"
        content={
          props?.seo?.canonicalURL == null ? "" : props?.seo?.canonicalURL
        }
      />
      <meta property="og:image" content={imgUrl == null ? "" : imgUrl} />
      {/* <script type="application/ld+json">{JSON.stringify(props?.seo?.structuredData) == null ? "" : JSON.stringify(props?.seo?.structuredData)}</script> */}
      {schema &&
        schema.map((item, index) => {
          // console.log("item", item);
          return (
            <script key={"websiteJSON" + index} type="application/ld+json" dangerouslySetInnerHTML={{ __html: (JSON.stringify(item?.jsonSchema, null, 2) ? JSON.stringify(item?.jsonSchema, null, 2) : "") }}></script>
          );
        })}
    </Head>
  );
};
export default Seo;