Concepts

Global data

Global data concepts for Built.js themes and plugins.

Global data is accessible in every template (Next.js component) in your site and can be configured for a theme. You can define the "schema" of this data in the public/data/schemas/global file of your theme, like this:

public/data/schemas/global.json
{
  "global": {
    "fields": {
      "name": {
        "default": "Corporate Tailwind",
        "type": "string"
      },
      "logo": {
        "type": "image"
      }
    }
  }
}

Once you have your fields defined, you can set values in public/data/global.json:

public/data/global.json
{
  "global": {
    "name": "Blog Basic",
    "logo": {
      "url": "https://res.cloudinary.com/dn7feeelf/image/upload/v1725870579/builtjs_bert2m.svg",
      "path": "/images/builtjs.svg",
      "width": 45,
      "height": 45
    }
  }
}

You can then access this data in any template in your theme, like this:

components/templates/headers/header1.tsx
import Image from "next/image";
import { urlForImage } from "@/builtjs-utils";
import { PortableText } from "@portabletext/react";
 
export default function ProfileArticle1({ content }: any) {
  if (!content) return <></>;
  let { entry: author = null } = { ...content };
 
  let profile = author ? author.profile : null;
  return (
    <article id="profile-article1" className="template">
      {author && (
        <div className="relative max-w-4xl pb-20 mx-auto">
          <header>
            <span className={`preheading blank left`}>{profile?.position}</span>
            <div className="flex items-center">
              <h1 className="mb-10 heading-xxl">{author.fullName}</h1>
            </div>
          </header>
          {profile.profileImage && (
            <div className="relative mb-20">
              <div className="h-96">
                <Image
                  className="object-cover"
                  src={urlForImage(profile?.profileImage)}
                  fill
                  style={{ objectFit: "cover" }}
                  alt={author.fullName}
                />
              </div>
            </div>
          )}
          <PortableText value={profile?.bio} />
        </div>
      )}
    </article>
  );
}

On this page

No Headings