Globals > Create Global
interface GlobalSchema {
slug: string;
name: string;
fields: SuncelField[];
}
// pages/_app.ts file
import "../styles/globals.css";
import type { AppProps } from "next/app";
import { SuncelContext } from "@suncel/nextjs";
import { myGlobal } from "@/suncel/globals/myGlobal";
function MyApp({ Component, pageProps }: AppProps) {
return (
<SuncelContext globals={[myGlobal]}>
<Component {...pageProps} />
</SuncelContext>
);
}
export default MyApp;
import { GlobalSchema } from "@suncel/nextjs";
export const NavigationListSchema: GlobalSchema = {
slug: "navigation_list",
name: "Navigation List",
fields: [
{
type: "repeatable",
slug: "links",
name: "Link",
pluralName: "links",
fields: [
{
type: "text",
name: "Link label",
slug: "label",
defaultValue: "label",
},
{
type: "link",
name: "Link",
slug: "link",
},
],
},
],
};
import { getGlobal } from "@suncel/nextjs/api";
//Fetch the global
const { data } = await getGlobal('global_id', { language:'en'} )
// Result of the data.content
{
navigation_menu: [
{
label: "Home",
link: {
linkType: "custom",
href: "/",
},
},
{
label: "Pricing",
link: {
linkType: "custom",
href: "/pricing",
},
},
{
label: "Contact",
link: {
linkType: "custom",
href: "/contact",
},
links: [],
},
],
};