@muratgozel/directus-operation-slugify
v1.1.7
Published
Generates a language aware slug from texts.
Downloads
14
Maintainers
Readme
directus-operation-slugify
Directus operation extension to generate language aware slugs.
Install
This extension is a standard directus operation extension. Refer to the official docs if you don't know how to install extensions:
https://docs.directus.io/extensions/installing-extensions.html
The extension also available as an npm package:
npm i @muratgozel/directus-operation-slugify
If you still not sure, check npm run up
and npm run up-dev
commands. Those are the ones I use for installing this extension.
Note on Directus Marketplace
Directus recently released their marketplace for extensions which makes installing a lot easier. Unfortunately this feature is still in beta and because of the limitations it brang for this kind of extension, I decided to wait and not publish this extension in the marketplace. Still, you'r able install it by setting MARKETPLACE_TRUST=all
env var in your Directus instance, that's what they said. I'll update this section and the package itself once the feature reaches satisfying kind of stability.
After installing, verify it by checking Settings - Extensions screen. The extension should be there with correct version number.
Usage
- Create a Flow with Event Hook trigger. The trigger should be configured as blocking, scoped to items.create and items.update, filtered to a collections of your choice and return Data of Last Operation.
- Add Slugify operation to the flow. The options are:
- Name of the field to generate the slug from:
title
for example if you have a collection withtitle
field and want to generate slugs based on that field. - Path to the language code or 2 letter language code:
- If you specify a dotted path such as
languages_code.code
, it will be transformed to a chain of property names as to be resolved in item's payload to find the language of the payload. - If you don't have a language code in your collection, you can just type a 2 letter language code here such as
en
but be aware that it might effect the generated slugs.
- If you specify a dotted path such as
- Name of the slug field: The name of the field in your collection to save the generated slug under.
slug
for example.
- Name of the field to generate the slug from:
That's all.
From now on, the extension will generate a slug:
- on creating new items on relevant collections and
- on updating items on relevant collections only if the slug field is empty.
Version management of this repository done by releaser 🚀
Thanks for watching 🐬