@theguild/components
Version:
168 lines (167 loc) • 4.87 kB
JavaScript
import { jsx, jsxs } from "react/jsx-runtime";
import { Layout } from "nextra-theme-docs";
import { Head } from "nextra/components";
import { getPageMap } from "nextra/page-map";
import { Anchor } from "../components";
import { HiveFooter } from "../components/hive-footer";
import { HiveNavigation } from "../components/hive-navigation";
import { siteOrigin, siteUrl } from "../constants";
import { PRODUCTS } from "../products";
const companyItem = {
type: "menu",
title: "Company",
items: {
about: { title: "About", href: `${siteOrigin}/about-us` },
blog: { title: "Blog", href: `${siteOrigin}/blog` },
contact: { title: "Contact", href: `${siteOrigin}/#get-in-touch` }
}
};
const productsItems = {
type: "menu",
title: "Products",
items: Object.fromEntries(
Object.values(PRODUCTS).map((product) => [
product.name,
{
title: /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-2", title: product.title, children: [
/* @__PURE__ */ jsx(product.logo, { className: "size-7 shrink-0" }),
product.name
] }),
href: product.href
}
])
)
};
const GuildLayout = async ({
children,
websiteName,
description,
htmlProps,
headProps,
logo,
layoutProps,
navbarProps
}) => {
const [meta, ...pageMap] = await getPageMap();
const pageMapWithCompanyMenu = [
{
data: {
// Add for every website except The Guild Blog
...siteOrigin && { company: companyItem },
products: productsItems,
// @ts-expect-error -- fixme
...meta.data
}
},
// Add for every website except The Guild Blog
...siteOrigin ? [{ name: "company", route: "#", ...companyItem }] : [],
{ name: "products", route: "#", ...productsItems },
...pageMap
];
return /* @__PURE__ */ jsxs(
"html",
{
lang: "en",
dir: "ltr",
suppressHydrationWarning: true,
...htmlProps,
children: [
/* @__PURE__ */ jsx(Head, { ...headProps }),
/* @__PURE__ */ jsx("body", { children: /* @__PURE__ */ jsx(
Layout,
{
footer: /* @__PURE__ */ jsx(
HiveFooter,
{
logo: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
logo,
/* @__PURE__ */ jsx("span", { className: "text-2xl/[1.2] font-medium tracking-[-0.16px]", children: websiteName })
] }),
description
}
),
navbar: /* @__PURE__ */ jsx(
HiveNavigation,
{
className: "max-w-[90rem]",
productName: websiteName,
navLinks: [],
...navbarProps,
logo: /* @__PURE__ */ jsxs(
Anchor,
{
href: "/",
className: "hive-focus -m-2 flex shrink-0 items-center gap-3 rounded-md p-2",
children: [
logo,
/* @__PURE__ */ jsx("span", { className: "text-2xl font-medium tracking-[-0.16px]", children: websiteName })
]
}
)
}
),
editLink: "Edit this page on GitHub",
...layoutProps,
pageMap: pageMapWithCompanyMenu,
feedback: {
labels: "kind/docs",
...layoutProps.feedback
},
sidebar: {
defaultMenuCollapseLevel: 1,
...layoutProps.sidebar
},
children
}
) })
]
}
);
};
function getDefaultMetadata({
websiteName,
description = `${websiteName} Documentation`,
productName,
...additionalMetadata
}) {
return {
description,
title: {
// Use `absolute` title if `metadata.title` was not provided in the page
absolute: websiteName,
template: `%s | ${websiteName}`
},
twitter: {
card: "summary_large_image",
site: "https://the-guild.dev",
creator: "@TheGuildDev"
},
applicationName: websiteName,
appleWebApp: {
title: websiteName
},
robots: {
index: true,
follow: true
},
alternates: {
// https://github.com/vercel/next.js/discussions/50189#discussioncomment-10826632
canonical: "./"
},
metadataBase: new URL(siteUrl),
...additionalMetadata,
openGraph: {
siteName: websiteName,
type: "website",
images: `https://og-image.the-guild.dev/?product=${productName}`,
// https://github.com/vercel/next.js/discussions/50189#discussioncomment-10826632
url: "./",
locale: "en_US",
...additionalMetadata.openGraph
}
};
}
export {
GuildLayout,
getDefaultMetadata
};