Skip to content

Repository files navigation

loopback-slug

url friendly generator for loopback.io framework.

build status

Installation

This module is installed via npm:

$ npm install loopback-slug
or
$ npm install git://github.com/rikhart/loopback-slug.git

Example Usage

Edit the /common/models/name_of_your_models.js and add a hook method. Use the hook "beforeSave" method to add the functionality, pass the Model,newdata,and the configoptions.

Configoptions:(json object)

  • separator (Default: '-') - Separator to use for characters.
  • slug (Default: 'slug') - Parts that are uploaded simultaneously.
  • fields (Default: 'title') - Array that will use to form the slug.
  • lowercase (Default: false) - Convert the slug to lowercase.
WorksinlastloopbackVersion,wherecurrentInstanceispartofthectx.varloopbackslug=require("loopback-slug");module.exports=function(Category){Category.observe('before save',function(ctx,next){//!!importantloopbackslug.middleware(Category,ctx,{fields: ['name'],slug: "slug"},function(err){if(err)returnnext(err);elsenext(null);});});};

License

Apache-2.0 © Dick Van Ocampo Davila

About

url friendly generator for loopback.io framework.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages