New Addon - BetterSlugs


#1

Hi Cockpit Community,

Cockpit provides a basic mechanism to handle slugs and we have the UniqueSlugs addon that enhances the core by providing uniqueness of slugs, however, and mostly because I have a scenario that requires a few more options I created a new addon that provides the possibility to define complete paths with dynamic tokens (e.g. blogs/[date:Y]/[field:title] or pages/[field:category]/[field:title], etc.)

The full details on addon are on the github page - https://github.com/pauloamgomes/CockpitCMS-BetterSlugs


#2

This plugin works great! I’m just confused as to how to actually implement the slugs once they’re generated. How would I navigate to, for example, blogs/2019/newpost ?

From what I understand, the only way to retrieve a single entry in a collection is to use the api and ?filter the GET request or attach a JSON to a POST request.


#3

Hey @ColinTravis, great you liked it… the slugs are just a representation on how you should access information in your frontend, remember that cockpit is a headless CMS. Let’s imagine you have a blog website, and you have a collection named blog, with a title, summary, date, etc… typically each entry should be accessed in form of blogs/<year>/<post-title>. Having that in slug helps you to build your routes in the frontend, that can be usefully mostly if you are using a static site generator like react-static or gatsby, where all blog collection entries are fetched and the routes are built using the slug as path.