Important
This sample app relies on the Dancing Goat project, which is no longer available for creation in Kontent.ai.
If you still wish to use this project, you can import the Dancing Goat project using the Data Ops tool by following the instructions provided in our Dancing Goat repository.
This is a sample ASP.NET Core MVC app that uses the Kontent.ai Delivery .NET SDK to retrieve content from Kontent.ai.
To run the app:
-
Clone the app repository
-
Run
npm install && npm run build
in theDancingGoat
directory to build CSS files for the project (node.js must be installed before running this command) -
Open the
DancingGoat.sln
solution file and run the app -
Follow the setup wizard to setup your project or adjust the
\DancingGoat\appsettings.json
file:{ // ... "DeliveryOptions": { "ProjectId": "YOUR_PROJECT_ID" } // ... }
Follow the step-by-step tutorial for even more details.
With the help of Kontent.ai model generator you can generate models from your project. This process will create classes that you can work with within your codebase. To run the generation, use the Powershell script ./DancingGoat/Tools/GenerateModels.ps1 or Bash script ./DancingGoat/Tools/GenerateModels.sh.
Be aware that by default, the scripts downloads the models from the default Dancing Goat project. If you want to download models from your custom project, change the project id inside the script file.
Content contributors sometimes need to fix errors or typos right when they see them on the website. The sample app allows users to navigate from a piece of content on the site straight to the corresponding content item or element in Kontent.ai.
To see Edit mode in action:
-
In your Kontent.ai project navigate to Project Settings -> API keys to get the Preview API key.
-
Enable Delivery Preview API by adding the key to the
\DancingGoat\appsettings.json
file:{ // ... "DeliveryOptions": { "UsePreviewApi": true, "PreviewApiKey": "YOUR_DELIVERY_PREVIEW_API_KEY" } // ... }
- Delivery Preview API: change the key named
PreviewApiKey
in theDeliveryOptions
section, and use the Delivery Preview API key as its value. To enable calls over the Delivery Preview API, you also need to change the value totrue
of the key namedUsePreviewApi
.
- Delivery Preview API: change the key named
-
Run the app.
-
Navigate to the About us section.
-
Click the Edit mode switch in the bottom-left corner.
Edit buttons will appear next to each piece of content on the page.
To explore how the functionality is implemented, navigate to the TagHelpers
folder.
The sample app contains a sample implementation of the img-asset
tag helper from the Kontent.Ai.AspNetCore NuGet package. Using the img-asset
tag helper, you can easily create an img
tag with srcset
and sizes
attributes. Read more about image transformation API.
You can adjust the behaviour in the appsettings.json
file.
"ImageTransformationOptions": {
"ResponsiveWidths": [ 200, 400, 600, 800, 1000, 1200, 1400, 1600, 2000, 4000 ]
},
The app demonstrates the usage of language prefixes (e.g. /en-US/articles
) for localizing URLs for SEO purposes. Each language is identified by its codename, in case of this project, it is en-US
and es-ES
.
The used language is obtained from the URL via /DancingGoat/Infrastructure/RouteRequestCultureProvider
and set as the culture of the app.
Check out the contributing page to see the best places to file issues, start discussions, and begin contributing.