Site showcasing how to resolve Rich Text element and it's inline images, inline content items, and content components.
# In the root folder of this repo
npm install # install all required packages
npm run build # build the latest version of the local packages
# open the /example/navigation folder
cd examples/navigation
npm run develop # runs `gatsby develop` command
Now you could browse the site on http://localhost:8000 and see GraphiQL explorer on http://localhost:8000/___graphql.
This section explains how the content is modeled. You could follow to next section "Import the content to your on Kontent.ai project" and explore the models by your own as well as the sample data based on it. Or you could create models manually to familiarize yourself with the Kontent.ai user interface.
Once you create the content models, you could create content items based on these and the site would be capable to handle the content and render it.
First of of all it is required to create two content types:
Person
- which will represent a person on our website and mainlyBio
rich text element used for resolution showcaseRepository
- this content type represents a github repository information - used as an inline linked item from Person'sBio
elementWebsite
- this content type represents a website information - used as an inline linked item from PersonBio
element
This content type - Person
- represents people with their Bio
. They could link any Website
or Repository
(see the next section) to their bio and these components needs to be resolved. It has following structure:
- Name - Text element
- Bio - Rich text element - configures to allow to link only
Repository
andWebsite
content types - Slug - URL slug element - generated from name
In case you want to link external URL to different domain, it is possible to extend the content type by Text element called i.e. External URL.
Repository
and Website
content types has following structure. They are pretty similar, they are used to showcase the resolution of inline linked items in the rich text element (Bio
element of the person).
Repository
- Name - Text element
- Summary - Text element
- URL - Text element
- Slug - URL slug element - generated from name
Website
- Name - Text element
- Summary - Text element
- URL - Text element
- Slug - URL slug element - generated from name
- Source repository - Linked items element - configures to allow only
Repository
content type
If you want to import content types with the sample content in your own empty project, you could use following guide:
-
Go to app.kontent.ai and create empty project
-
Go to "Project Settings", select API keys and copy
Project ID
-
Install Kontent.ai Backup Manager and import data to newly created project from
kontent-backup.zip
file (place appropriate values forapiKey
andprojectId
arguments):npm install -g @kontent-ai/backup-manager-js kbm --action=restore --apiKey=<Management API key> --projectId=<Project ID> --zipFilename=kontent-backup
-
Go to your Kontent.ai project and publish all the imported items.
Open the gatsby-config.js
file and set following properties for @kontent-ai/gatsby-source
plugin:
projectId
from Project settings > API keys > Delivery API > Project IDlanguageCodenames
from Project settings > Localization
For all Person
content items, there is a new page created based on on the templates/person.js
template. The template is using Gatsby Kontent.ai Components package, specifically it's RichTextElement
to resolve the content component, inline linked items, and images.
The main example is on http://localhost:8000/people/ondrej-chrastina/ that showcase the content component, inline linked items, and images resolution of the Bio element.
You could re-use the React components on multiple places.
The Bio
rich text resolution in templates/person.js
is using the src/components/repository.js
component as well as the same component is used on the templates/website.js
for linked items resolution.
For all Person
content items, there is a new page created based on the templates/person.js
template. The template is using utils/resolvers/ to resolve links to other content items into the URLs in the Bio
element.
The main example is on http://localhost:8000/people/ondrej-chrastina/ that showcase URL resolution of the Bio
element - in this case the link to John Doe
.
The overall resolution of the urls for content items in on http://localhost:8000/. There is an overview of resolved URLs for all content items based on Person
, Repository
, and Website
content type.
If you want to configure more complex and multi-level routing, take a look to the Navigation example and the you could use resolved URLs in combination with the unified URL resolution.