# Amplience [Amplience](https://amplience.com/) is an API-first headless content management platform. commercetools Frontend comes with an out-of-the-box Amplience extension to integrate Amplience in your commercetools Frontend project. With the extension you can deliver content from Amplience, such as images, videos, and other media assets, to your commercetools Frontend website. For demonstration purposes, in this document you will learn how to render on your commercetools Frontend website one or multiple blog posts that you created on Amplience. **Prerequisites** - An [Amplience account](https://amplience.com/login/) - An Amplience Content Hub to store your content and media assets. To create a Content Hub, log in to your Amplience account and request [Amplience support](https://support.amplience.com/support/home) to create it. If the `content-amplience` extension is not available in your commercetools Frontend project at this path `packages/PROJECT_NAME/backend`, before proceeding with the following configurations, you must: 1. Copy the `content-amplience` extension from [the scaffold repository](https://github.com/FrontasticGmbH/scaffold-b2c/tree/main/backend/content-amplience) to your project. 2. [Register the extension in your project](/frontend-development/extensions.md#define-extensions). ## Get started To start using the Amplience extension, follow these steps: 1. [Add the following project configuration field to the project schema](/frontend-development/api-hub-configuration.md#add-project-configuration-fields-to-the-project-schema) from the Studio. ```json title="Add Amplience project configuration field" { "name": "Amplience Extension", "fields": [ { "label": "Amplience Hub Name", "field": "EXTENSION_AMPLIENCE_HUB_NAME", "type": "encrypted", "translatable": false, "required": true } ] } ``` 2. [Set the value for the **Amplience Hub Name** configuration field](/frontend-development/api-hub-configuration.md#enter-project-configuration-values-in-project-settings) from the Studio. The value must match the name of the Amplience Content Hub you created as a prerequisite. ## Deliver content with the Amplience extension To deliver any type of media content with the Amplience extension you must follow these steps: 1. [Create content on Amplience](/frontend-development/amplience.md#create-content-on-amplience) (create the content type schema, content type, and content items). 2. [Upload the data source schemas to the Studio](/frontend-development/amplience.md#upload-data-source-schemas). 3. [Create the dedicated Frontend components](/frontend-development/amplience.md#create-frontend-components). 4. [Add data sources to the dedicated page folder and configure data source filters](/frontend-development/amplience.md#add-data-sources-and-configure-data-source-filters) in the Studio. 5. [Add the Frontend components to a dedicated page version](/frontend-development/amplience.md#add-frontend-components-to-the-page-version) in the Studio. In this document, we present an example of how to render one or multiple blog posts. ### Create content on Amplience To use the Amplience extension, you need to create on Amplience the content that you want to deliver on your website. In this example, we create three blog content items. To create the blog content items, follow these steps: 1. [Create a content type schema](https://amplience.com/developers/docs/dev-tools/guides-tutorials/schema-editor/) using the following schema for the blog content. ```json title="Blog content type schema" { "$schema": "http://json-schema.org/draft-07/schema#", "$id": "https://schema-cofe.com/blog", "title": "Blog", "description": "Blog", "allOf": [ { "$ref": "http://bigcontent.io/cms/schema/v1/core#/definitions/content" } ] "type": "object", "properties": { "title": { "title": "Title", "description": "The blog's title", "allOf": [ { "$ref": "http://bigcontent.io/cms/schema/v1/localization#/definitions/localized-string" } ] }, "banner": { "title": "Banner", "allOf": [ { "$ref": "http://bigcontent.io/cms/schema/v1/core#/definitions/image-link" } ] }, "summary": { "title": "Summary", "description": "Short summary on what the blog is about.", "type": "string", "format": "markdown" } }, "propertyOrder": [] } ``` 2. Use the **Blog** content type schema you created to [register a content type](https://amplience.com/developers/docs/dev-tools/guides-tutorials/content-types/#registering-content-types). 3. [Create three blog content items](https://amplience.com/developers/docs/user-guides/produce-content/create/) by selecting the **Blog** content type you created and adding content of your choice such as text, images, videos, or other media assets. In this example, we call the content items **Blog 1**, **Blog 2**, and **Blog 3**. You have now created three blog content items on Amplience. ### Upload data source schemas The Amplience extension comes with the following out-of-the-box [data sources](/frontend-development/development-concepts.md#data-sources): - `amplience/content` to fetch a single content item from Amplience. - `amplience/content-list` to fetch multiple content items from Amplience with filters and configurations. To fetch content from Amplience, you must [upload to the Studio](/frontend-studio/using-data-sources-in-the-studio.md) the following data source schemas. ```json title="Schema of the Amplience Content data source" { "name": "Amplience Content", "customDataSourceType": "amplience/content", "category": "Content", "icon": "source", "schema": [ { "name": "Content Selection", "fields": [ { "label": "Content ID", "field": "contentId", "type": "text", "translatable": false } ] } ] } ``` ```json title="Schema of the Amplienece Content List data source" { "name": "Amplience Content List", "customDataSourceType": "amplience/content-list", "category": "Content", "icon": "bookmark", "schema": [ { "name": "Configuration", "fields": [ { "label": "Content Type", "field": "contentType", "type": "text", "translatable": false }, { "label": "Limit", "field": "limit", "type": "number", "default": 12 } ] }, { "name": "Advanced", "fields": [ { "label": "Filters", "field": "filters", "type": "text", "translatable": false }, { "type": "description", "text": "In the format of white space separated key-value pairs. For example, sorting1=val1 sorting2=val2" }, { "label": "Sorting", "field": "sort", "type": "text", "translatable": false }, { "type": "description", "text": "In the format of white space separated key-value pairs. For example, filter1=val1 filter2=val2" }, { "label": "Resolve hierarchy tree", "field": "resolveHierarchyTree", "type": "boolean", "default": false } ] } ] } ``` ### Create Frontend components The Amplience extension comes with the following out-of-the-box [data sources](/frontend-development/development-concepts.md#data-sources) for Amplience: - `amplience/content` to fetch a single content item from Amplience. - `amplience/content-list` to fetch multiple content items from Amplience with filters and configurations. To render on your website the data coming from these data sources, you must create [Frontend components](/frontend-development/development-concepts.md#components) that are linked to the mentioned data sources. In this example, we create the Frontend components to display a single or multiple blog content items. To create the components, follow these steps: 1. Create the Frontend component schemas by [uploading the following schemas to the Studio](/frontend-development/creating-a-frontend-component.md#create-a-frontend-component-schema). ```json title="Blog component schema linked to the amplience/content data source" { "tasticType": "commercetools/ui/content/blog", "name": "commercetools UI Amplience Blog", "icon": "bookmark", "category": "Content", "schema": [ { "name": "Content", "fields": [ { "label": "Amplience Content", "field": "data", "type": "dataSource", "dataSourceType": "amplience/content", "required": true } ] } ] } ``` ```json title="Blog List component schema linked to the amplience/content-list data source" { "tasticType": "commercetools/ui/content/blog-list", "name": "commercetools UI Amplience Blog List", "icon": "bookmark", "category": "Content", "schema": [ { "name": "Content", "fields": [ { "label": "Amplience Content", "field": "data", "type": "dataSource", "dataSourceType": "amplience/content-list", "required": true } ] } ] } ``` 2. In your commercetools Frontend project under `components/commercetools-ui/content/blog`, add the following `index.tsx` file for the `Blog` React component. ```tsx title="index file of the Blog React component" const Blog = ({ title, summary, banner }) => { return (
{summary}