@tngraphql/slugify
v1.0.5
Published
Add slugs to tngraphql lucid models
Downloads
7
Maintainers
Readme
@tngraphql/slugify
Options
slugifyModel takes an options object as it's second parameter.
class ExampleModel extends BaseModel {
@column({ isPrimary: true })
public id: string
@column()
public name: string;
@column()
public slug: string;
static boot() {
super.boot();
this.uses([Sluggable]);
}
/**
* Return the sluggable configuration array for this model.
*
* @return array
*/
public sluggable() {
return {
source: ['name'],
slugOptions: {lower: true},
overwrite: false,
column: 'slug'
}
}
}
Available Options
source
- (Required) Array of field names in the model to build the slug from.suffixSource
- (Optional) Array of field names in the model to use as the source for additional suffixes to make the slug unique (before defaulting to adding numbers to the end of the slug).slugOptions
- (Default{lower: true}
) Pass additional options for slug generation as defined byslug
.overwrite
- (DefaultTRUE
) Change the slug if the source fields change once the slug has already been built.column
- (Defaultslug
) Specify which column the slug is to be stored into in the model.