Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions 0001-template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
- Start Date: (fill in today's date, YYYY-MM-DD)
- RFC PR: (leave this empty)

# Summary

Adding the slug option to content type so that they can be retrieved by a string key rather than by ID. Good for SEO support for blog like features.

# Motivation

Please reference the issues [here](https://github.com/strapi/strapi/issues/752) for more details on the exact need.

# Detailed design

Below are the screens for the proposed implementation, which we have ready to submit as a PR.

## Content Type

When creating a new content type after setting the basic informations

![Content Type enable slug](images/content-type-edit-flow-1.png )

The user is able to configure the slug by clicking on the `Configure` button.

![Content Type enable slug](images/content-type-edit-flow-2.png )

In the new options configuration screen the user will find an option to pick which property to use for the slug. In the future there are plans to add more options for each content type like draft & archive, ownership and versioning.

![Content Type enable slug](images/content-type-edit-flow-3.png )

Once a content type is saved the user can always access the configuration options by clicking on the `Configure` button
![Content Type enable slug](images/content-type-edit-flow-4.png )

## Instance View Updates

When a slug is configured for a content type when creating an instance of it the user will see the slug entry displayed below the property that was selected.

![Slug entry below selected property](images/instance-view-with-slug.png)

By clicking the edit buttons the user is able to change the slug

![Edit Slug](images/instance-view-edit-slug.png)

## Changes to API permission

In the API permission there is now an options for findonebyslug which will return an item by it's slug

![API permissions findonebyslug](images/api-permission-findonebyslug.png)

Sample API response:

![API response by slug](images/api-response-byslug.png)

# Alternatives

There is one workaround described [here](https://github.com/strapi/strapi/issues/752#issuecomment-447541531) but it is not as flexible as it doesn't allow for slug management in the CMS and in some cases the computed slug could be wrong. For example if the title is "It's a wonderful day" the computed slug would be "its-a-wonderful-day" which is actually bad grammar.

# Known Issues

There is an [knows issues](https://github.com/strapi/strapi/issues/1189) with unique attributes in stripe which we are leveraging for slug uniqueness in the collection so once that is fixed the slug should work as well.
Binary file added images/api-permission-findonebyslug.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/api-response-byslug.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/content-type-edit-flow-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/content-type-edit-flow-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/content-type-edit-flow-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/content-type-edit-flow-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/instance-view-edit-slug.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/instance-view-with-slug.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.