Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/optimizely-cms-sdk/src/infer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export type InferredBase = {
_metadata: InferredContentMetadata;
__typename: string;
__context?: { edit: boolean; preview_token: string };
composition?: ExperienceComponentNode;
};

/** Only include keys where indexingType is not 'disabled' */
Expand Down
7 changes: 5 additions & 2 deletions packages/optimizely-cms-sdk/src/react/server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ export function OptimizelyGridSection({
<OptimizelyComponent
opti={{
...node.component,
composition: node,
__tag: tag,
}}
key={node.key}
Expand Down Expand Up @@ -307,17 +308,19 @@ export function OptimizelyGridSection({
export function getPreviewUtils(opti: OptimizelyComponentProps['opti']) {
return {
/** Get the HTML data attributes required for a property */
pa(property: string | { key: string }) {
pa(property?: string | { key: string }) {
if (opti.__context?.edit) {
if (typeof property === 'string') {
return {
'data-epi-property-name': property,
};
} else {
} else if (property) {
return {
'data-epi-block-id': property.key,
};
}

return {};
} else {
return {};
}
Expand Down