strapi-community / strapi-plugin-slugify

A plugin for Strapi Headless CMS that provides the ability to auto slugify a field for any content type.

Home Page:https://market.strapi.io/plugins/strapi-plugin-slugify

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature request: multiple references for one slug

DanielPantle opened this issue · comments

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

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'],
        },
      },
    },
  },
  // ...
});

@ComfortablyCoding thanks for clarifying, thats great! I created a PR to include a note in the README that this is possible, see #123.