@tngraphql/slugify
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

@tngraphql/slugify

npm-image license-image

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 by slug.
  • overwrite - (Default TRUE) Change the slug if the source fields change once the slug has already been built.
  • column - (Default slug) Specify which column the slug is to be stored into in the model.

Package Sidebar

Install

npm i @tngraphql/slugify

Weekly Downloads

1

Version

1.0.5

License

MIT

Unpacked Size

27.6 kB

Total Files

15

Last publish

Collaborators

  • nguyenpl117