Contentful Personalization & Analytics
    Preparing search index...
    • Type guard for EntryReplacementComponent.

      Parameters

      • component:
            | {
                baseline: { hidden?: boolean; id: string };
                type?: "EntryReplacement";
                variants: { hidden?: boolean; id: string }[];
            }
            | {
                baseline: {
                    value: string
                    | number
                    | boolean
                    | Record<string, JSONType>
                    | null;
                };
                key: string;
                type: "InlineVariable";
                valueType: "Boolean"
                | "Number"
                | "Object"
                | "String";
                variants: {
                    value: string | number | boolean | Record<string, JSONType> | null;
                }[];
            }

        Personalization component to test.

        • {
              baseline: { hidden?: boolean; id: string };
              type?: "EntryReplacement";
              variants: { hidden?: boolean; id: string }[];
          }
          • baseline: { hidden?: boolean; id: string }

            Baseline variant used when no targeting or allocation selects another variant.

            • Optionalhidden?: boolean

              On a baseline: true excludes the whole component from allocation.

              On a variant: can be true (author chose "Use empty variant") or false (unfilled placeholder). Both states share id: "". Do not use this field to detect an empty variant — use id === "" instead. The Experience API strips this field before runtime; it is only present in Contentful CDA nt_config.

            • id: string

              Unique identifier for the variant. Empty string ("") for an empty variant — both the deliberate "Use empty variant" choice and an unfilled placeholder slot.

          • Optionaltype?: "EntryReplacement"

            Discriminator for the component type.

            Can be omitted, in which case the component is treated as an EntryReplacement.

          • variants: { hidden?: boolean; id: string }[]

            Additional variants that can be served.

        • {
              baseline: {
                  value: string | number | boolean | Record<string, JSONType> | null;
              };
              key: string;
              type: "InlineVariable";
              valueType: "Boolean"
              | "Number"
              | "Object"
              | "String";
              variants: {
                  value: string | number | boolean | Record<string, JSONType> | null;
              }[];
          }
          • baseline: { value: string | number | boolean | Record<string, JSONType> | null }

            Baseline value used when no targeting or allocation selects another variant.

            • value: string | number | boolean | Record<string, JSONType> | null

              Variant value for the inline variable.

          • key: string

            Key under which this variable is exposed to the template.

          • type: "InlineVariable"

            Discriminator for the inline variable component.

          • valueType: "Boolean" | "Number" | "Object" | "String"

            Describes the runtime type of the values for this variable.

          • variants: { value: string | number | boolean | Record<string, JSONType> | null }[]

            Additional variable variants for experimentation or personalization.

      Returns component is {
          baseline: { hidden?: boolean; id: string };
          type?: "EntryReplacement";
          variants: { hidden?: boolean; id: string }[];
      }

      true if the component is an EntryReplacement component, otherwise false.

      if (isEntryReplacementComponent(component)) {
      console.log(component.baseline.id);
      }