@palmabit/loopback-ds-slugify-mixin

1.1.1 • Public • Published

loopback-ds-slugify-mixin

Install

  npm i @palmabit/loopback-ds-slugify-mixin --save

Server Config

Add the mixins property to your server/model-config.json:

{
  "_meta": {
    "sources": [
      "loopback/common/models",
      "loopback/server/models",
      "../common/models",
      "./models"
    ],
    "mixins": [
      "loopback/common/mixins",
      "../node_modules/@palmabit/loopback-ds-slugify-mixin",
      "../common/mixins"
    ]
  }
}

Model Config

To use with your Models add the mixins attribute to the definition object of your model config.

  {
    "name": "Widget",
    "properties": {
      "name": {
        "type": "string",
      }
    },
    "mixins": {
    "Slugify": {
      "slugifyOptions": { 
        "replacement": "=",
        "remove": null,
        "lower": true,
        "suffixTimestamp": true
      },
      "slugifiedField": "slug",
      "fieldToSlugify": "name"
    }
  }
  }
  • slugifyOptions: Optional. See https://github.com/simov/slugify for more infos
  • slugifiedField: [String] Optional. Default is "slug". Support dot notation (ex. "foo.bar") for nested
  • fieldToSlugify: [String] Required. Support dot notation (ex. "foo.bar") for nested
  • suffixTimestamp: [Boolean] Optional

Changelog

Changelog File

License

The MIT License (MIT). Please see License File for more information.

Package Sidebar

Install

npm i @palmabit/loopback-ds-slugify-mixin

Weekly Downloads

0

Version

1.1.1

License

ISC

Unpacked Size

4.72 kB

Total Files

5

Last publish

Collaborators

  • palmabit-dev
  • a.sarzina
  • francesco
  • drubetti