strapi-community / strapi-plugin-slugify

A plugin for Strapi Headless CMS that provides the ability to auto slugify a field for any content type.
https://market.strapi.io/plugins/strapi-plugin-slugify
MIT License
45 stars 21 forks source link

Feature request: multiple references for one slug #122

Closed DanielPantle closed 9 months ago

DanielPantle commented 9 months ago

Hi,

I would like to use this plugin, but I need slugs generated out of multiple fields.

Use case: I have events where the date and the title of an event need to be part of the slug (because the same title can occur multiple times). Therefore the fields date (of type date) and title (of type string) need to be combined.

Example: for an event with title "Test Training" and date "2024-06-01" the following slug should be generated: 2024-06-01-test-training

ComfortablyCoding commented 9 months ago

Compound slugs are already possible.

Using the example given it would look something like this

module.exports = ({ env }) => ({
  // ...
  slugify: {
    enabled: true,
    config: {
      contentTypes: {
        event: {
          field: 'slug',
          references: ['date','title'],
        },
      },
    },
  },
  // ...
});
DanielPantle commented 9 months ago

@ComfortablyCoding thanks for clarifying, thats great! I created a PR to include a note in the README that this is possible, see https://github.com/ComfortablyCoding/strapi-plugin-slugify/pull/123.