silverwolf-x's picture
download
raw
1.35 kB
import Link from "next/link";
import { print } from "graphql/language/printer";
import styles from "./Navigation.module.css";
import { MenuItem, RootQueryToMenuItemConnection } from "@/gql/graphql";
import { fetchGraphQL } from "@/utils/fetchGraphQL";
import gql from "graphql-tag";
async function getData() {
const menuQuery = gql`
query MenuQuery {
menuItems(where: { location: PRIMARY_MENU }) {
nodes {
uri
target
label
}
}
}
`;
const { menuItems } = await fetchGraphQL<{
menuItems: RootQueryToMenuItemConnection;
}>(print(menuQuery));
if (menuItems === null) {
throw new Error("Failed to fetch data");
}
return menuItems;
}
export default async function Navigation() {
const menuItems = await getData();
return (
<nav
className={styles.navigation}
role="navigation"
itemScope
itemType="http://schema.org/SiteNavigationElement"
>
{menuItems.nodes.map((item: MenuItem, index: number) => {
if (!item.uri) return null;
return (
<Link
itemProp="url"
href={item.uri}
key={index}
target={item.target || "_self"}
>
<span itemProp="name">{item.label}</span>
</Link>
);
})}
</nav>
);
}

Xet Storage Details

Size:
1.35 kB
·
Xet hash:
bf4389d004d2616615c55325b700f2c570de596002bbc32a58ee7536498079f9

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.