File tree Expand file tree Collapse file tree 2 files changed +9
-5
lines changed
Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Original file line number Diff line number Diff line change 1+ import deburr from 'lodash/deburr' ;
2+ import toLower from 'lodash/toLower' ;
3+ import kebabCase from 'lodash/kebabCase' ;
4+
15export interface Config {
26 website_url : string ;
37 default_pattern : string ,
8+ slugify : ( fieldValue : string ) => string
49}
510
611const config : {
@@ -10,6 +15,7 @@ const config: {
1015 default : {
1116 website_url : null ,
1217 default_pattern : '/[pluralName]/[documentId]' ,
18+ slugify : ( fieldValue ) => kebabCase ( deburr ( toLower ( fieldValue ) ) ) ,
1319 } ,
1420 validator ( ) { } ,
1521} ;
Original file line number Diff line number Diff line change 11import { factories , Schema , UID } from '@strapi/strapi' ;
2- import deburr from 'lodash/deburr' ;
3- import toLower from 'lodash/toLower' ;
4- import kebabCase from 'lodash/kebabCase' ;
52import { getPluginService } from '../util/getPluginService' ;
63import { typedEntries } from '../util/typeHelpers' ;
4+ import { Config } from '../config' ;
75
86const contentTypeSlug = 'plugin::webtools.url-pattern' ;
97
@@ -171,8 +169,8 @@ const customServices = () => ({
171169
172170 resolvedPattern = resolvedPattern . replace ( `[${ field } ]` , fieldValue || '' ) ;
173171 } else if ( ! relationalField ) {
174- // Slugify the field value
175- const fieldValue = kebabCase ( deburr ( toLower ( String ( entity [ field ] ) ) ) ) ;
172+ const { slugify } = strapi . config . get < Config > ( 'plugin::webtools' ) ;
173+ const fieldValue = slugify ( String ( entity [ field ] ) ) ;
176174 resolvedPattern = resolvedPattern . replace ( `[${ field } ]` , fieldValue || '' ) ;
177175 } else if ( Array . isArray ( entity [ relationalField [ 0 ] ] ) ) {
178176 strapi . log . error ( 'Something went wrong whilst resolving the pattern.' ) ;
You can’t perform that action at this time.
0 commit comments