Kontent.ai

Add the Kontent integration

Adding the Kontent by Kentico integration to your Uniform project adds new parameter types that you can add to your Uniform Canvas components.

Before you start

You must the following available to complete this setup:

  • Kontent account with administrator access.
  • Uniform account with administrator access. If you don't already have one, you can request an account at https://uniform.dev/try.
  1. In Uniform, open your project.

  2. Navigate to the Integrations tab.

  3. Scroll to the section Browse Integrations.

  4. Click Kontent by Kentico.

    add-integration-to-project
  5. Click Add to project.

    {% screenshot src="/images/integrations/content/kontent/kontent-in-uniform/add-uniform-integration/no-linked-sources.png" scale="75 /%}

  6. Click the red (+) button.

    source-configuration-empty
  7. Enter the required values and click Save.

    linked-source

Next steps

Explore the new parameter types that are available when you configure components using Uniform Canvas.

After you install the Kontent.ai integration, the following parameter types are available. You can use these to incorporate content from Kontent.ai into your components and compositions.

Parameter typeDescription
Kontent itemSelect a single item from Kontent.

This parameter type allows a Uniform user to select a single Kontent item.

To allow a user to select an item from Kontent, you must add a parameter to a component. The parameter is used to store the identifier to the selected item when the user selects an item.

  1. In Uniform, navigate to your component.

  2. Add a new parameter using the parameter type Kontent Item.

  3. The following values can be specified:

    NameDescription
    Select Linked SourceSpecifies which Kontent project is the source for the item that can be selected.
    Allowed Content TypesSpecifies which content types will be available to select from when the parameter value is edited. You can select multiple content types in order to allow the user to select from a larger set of items.
    RequiredIndicates whether the value is required when the component is used.
    parameter-config
    Kontent Item parameter with a single content type selected.

When you use a component with a Kontent parameter, by default no item will be selected. You are prompted to select an item.

  1. Click Select.

    edit-value-default
  2. Click the item you want to select.

    edit-value-filters

    About this step

    A couple of filters are available. The dropdown allows you to filter by content type. The text box allows you to filter by entry title.

  3. Click Accept to save your selection.

    edit-value-selected
  4. You will see details about the item you selected, including the title and some metadata.

    edit-value-saved

    About this step

    After your selection is saved, you are presented with the following options:

    • If you want to edit the selected item in Kontent, click Edit.
    • If you want to deselect the item, click Unlink.

When an item is selected, Uniform only stores the identifier for the item. Your front-end application must retrieve the details for the item. Uniform provides an enhancer to simplify this process.

tip

Using the enhancer provided by Uniform saves you from having to write logic to interact directly with Kontent.

The following is an example of what Uniform stores for the parameter.

There are two identifiers in this value:

  1. The item that was selected.
  2. The source key for the linked content source.

Uniform provides an enhancer so you don't need to write the API calls to Kontent to retrieve data for items.

tip

For more information about the enhancer, see the package documentation.

  1. In Kontent, get the following values:

    • Project ID
    • Delivery API key (optional)
  2. Add the following npm packages to your front-end application:

  3. In a text editor, open the file where you retrieve the composition definition from Uniform.

    About this step

    You are looking for the code calls the async function getComposition. The code below assumes the object returned is set in a variable composition.

  4. Add the following import statements:

  5. Add the following code:

    About this step

    We recommend you moving the Kontent credentials to environment variables rather than hard-coding them in the front-end app.

  6. Add the following code:

  7. Add the following code:

    About this step

    This registers the enhancer to be used for any occurrence of the Kontent Item parameter.

Next steps

Now, the parameter value in the composition is mutated to include the field values for the selected Kontent item (instead of just being identifiers).