diff --git a/src/pages/index.js b/src/pages/index.js index f73fecf60..d473b88f3 100644 --- a/src/pages/index.js +++ b/src/pages/index.js @@ -1,5 +1,6 @@ import React from "react"; import Layout from "@theme/Layout"; +import Head from "@docusaurus/Head"; import useDocusaurusContext from "@docusaurus/useDocusaurusContext"; import {Community, KeployCloud, Resources, QuickStart} from "../components"; import {Products} from "../components/Product"; @@ -7,8 +8,74 @@ import {Products} from "../components/Product"; export default function Home() { const context = useDocusaurusContext(); const {siteConfig = {}} = context; + const toAbsoluteUrl = (baseUrl, url) => { + if (!url) { + return null; + } + if (url.startsWith("http://") || url.startsWith("https://")) { + return url; + } + const trimmedBase = baseUrl?.replace(/\/$/, "") ?? ""; + const normalizedPath = url.startsWith("/") ? url : `/${url}`; + return `${trimmedBase}${normalizedPath}`; + }; + const docsUrl = toAbsoluteUrl(siteConfig.url, siteConfig.baseUrl); + const breadcrumbSchema = + docsUrl && siteConfig.url + ? { + "@context": "https://schema.org", + "@type": "BreadcrumbList", + itemListElement: [ + { + "@type": "ListItem", + position: 1, + name: "Home", + item: siteConfig.url, + }, + { + "@type": "ListItem", + position: 2, + name: "Docs", + item: docsUrl, + }, + ], + } + : null; + const articleSchema = + docsUrl && siteConfig.title + ? { + "@context": "https://schema.org", + "@type": "Article", + headline: siteConfig.title, + description: siteConfig.tagline, + mainEntityOfPage: { + "@type": "WebPage", + "@id": docsUrl, + }, + publisher: { + "@type": "Organization", + name: "Keploy", + logo: { + "@type": "ImageObject", + url: "https://keploy.io/docs/img/favicon.png", + }, + }, + } + : null; return (