vue-storefront
Version:
A Vue.js, PWA eCommerce frontend
28 lines (25 loc) • 716 B
JavaScript
/**
* Create slugify -> "create-slugify" permalink of text
* @param {String} text
*/
export function slugify (text) {
return text.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/&/g, '-and-') // Replace & with 'and'
.replace(/[^\w-]+/g, '') // Remove all non-word chars
.replace(/--+/g, '-') // Replace multiple - with single -
}
/**
* Re-format category path to be suitable for breadcrumb
* @param {Array} categoryPath
*/
export function breadCrumbRoutes (categoryPath) {
const tmpRts = []
for (let sc of categoryPath) {
tmpRts.push({
name: sc.name,
route_link: '/c/' + sc.slug
})
}
return tmpRts
}