Skip to content

ondrabus/kontent-url-slug-history-custom-element

Repository files navigation

URL slug history custom element for Kontent.ai

This custom element for Kontent.ai enables users to preserve history of URL slugs.

The element watches the URL slug element for changes. When the slug changes, the element automatically saves the previous URL slug to a history list. It's also possible to manually add and remove history entries.

Screenshot of custom element

Setup

  1. Build the code
npm run build
  1. Deploy the code to a secure public host

  2. Follow the instructions in the custom elements documentation to add the element to a content model.

    • The Hosted code URL is where you've deployed the element to in step 1.
    • Add the URL slug element's codename into configuration.

Configuration

The custom element may only be used for content types that contain the URL slug element. The configuration of the custom element looks like this:

{
    "urlSlugElementCodename": "{codename of the URL slug element}"
}

This configuration is required and the custom element won't work without it.

Deploying

Netlify has made this easy. If you click the deploy button below, it will guide you through the process of deploying the element to Netlify and leave you with a copy of this repository in your GitHub account as well.

Deploy to Netlify

What is Saved?

The value is an array of strings (old URL slugs).

["old-url-slug", "even-older-url-slug"]