File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed
examples/cms/routes/app/routes/blog/routes/posts Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change 1414<script >
1515import Crud from ' @/utils/crud/components/Crud.vue'
1616
17+ const slugify = (text ) => {
18+ const a = ' ąàáäâćęèéëêìíïîłńòóöôśùúüûźżñçßÿœæŕśńṕẃǵǹḿǘẍźḧ·/_,:;'
19+ const b = ' aaaaaceeeeeiiiilnoooosuuuuzzncsyoarsnpwgnmuxzh------'
20+ const p = new RegExp (a .split (' ' ).join (' |' ), ' g' )
21+
22+ return text .toString ().toLowerCase ()
23+ .replace (/ \s + / g , ' -' )
24+ .replace (p, c => b .charAt (a .indexOf (c)))
25+ .replace (/ &/ g , ' -and-' )
26+ .replace (/ [^ \w -] + / g , ' ' )
27+ .replace (/ --+ / g , ' -' )
28+ .replace (/ ^ -+ / , ' ' )
29+ .replace (/ -+ $ / , ' ' )
30+ }
31+
1732export default {
1833 data () {
1934 return {
@@ -62,7 +77,10 @@ export default {
6277 column: ' title' ,
6378 text: this .$t (' fields.title' ),
6479 name: ' title' ,
65- multiedit: false
80+ multiedit: false ,
81+ onChange : (value , fields ) => {
82+ fields .find (field => field .name === ' slug' ).value = slugify (value)
83+ }
6684 },
6785 {
6886 type: ' input' ,
You can’t perform that action at this time.
0 commit comments