Hello there,
Is there a data attribute in BuilderComponent, or Content in Gen2 SDK?
Builder content link
The page link is Vercel preview link with Gen2 SDK:
- Page URL: Page Link
- Builder URL: Builder Link
Builder public api key
- 1d8ecee591ac4358befb8fe998100548
What are you trying to accomplish
We are trying to move from Gen1 to Gen2 SDK to resolve our cache hit/miss and over cache write issues on Vercel, and encounter the data passing down the is undefined.
Screenshots or video link
Code stack you are integrating Builder with
NextJs, Gen2 SDEK
Reproducible code example
import { notFound } from 'next/navigation';
import PbContent from 'components/Builder';
import { getAllDetailPageModelSlugs, getAllDetails, getPostData } from 'utils/builder/builderSdkFunctions';
import type { Metadata } from 'next';
import renderMetadata from '@/utils/builder/renderMetaData';
type Params = {
params: {
slug?: string[];
};
searchParams: Record<string, string>;
};
export const generateMetadata = async ({ params }: Params): Promise<Metadata> => {
const slug = params?.slug && Array.isArray(params?.slug) ? `/glossary/${params.slug.join('/')}` : '/glossary/';
const seoData = await getPostData(slug, 'glossary-detail', 'data.seo');
return renderMetadata(slug, seoData?.data?.seo);
};
export const generateStaticParams = async () => {
const allPages = await getAllDetailPageModelSlugs('glossary-detail');
const paths = allPages?.map(({ data }) => {
const slugWithoutIntialPathSeperator = data?.url?.toString().substring(1);
return {
slug: slugWithoutIntialPathSeperator === '' ? [] : slugWithoutIntialPathSeperator.split('/'),
};
});
return paths;
};
const GlossaryDetailPage = async ({ params, searchParams }: Params) => {
const slug = params?.slug && Array.isArray(params?.slug) ? `/glossary/${params.slug.join('/')}` : '/glossary/';
const pageDataPromise = getPostData(slug, 'glossary-detail');
const allGlossaryPromise = getAllDetails('glossary-detail', { sort: { name: 1 } });
const [pageData, allGlossary] = await Promise.all([pageDataPromise, allGlossaryPromise]);
const isEditing = searchParams?.['__builder_editing__'] === 'true';
if (!pageData && slug !== '/glossary/' && !isEditing) {
return notFound();
}
const allGlossaryData = allGlossary?.filter(glossary => glossary.data.url !== '/glossary');
console.log('All Glossary Detail:', allGlossaryData);
return <PbContent model="glossary-detail" content={pageData} data={allGlossaryData} />;
};
export default GlossaryDetailPage