-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(slugs): allow filters in template strings #6690
base: main
Are you sure you want to change the base?
Conversation
const filterFunction = getFilterFunction(filter); | ||
if (filterFunction) { | ||
replacement = filterFunction(replacement); | ||
} | ||
|
||
if (processor) { | ||
return processor(replacement); | ||
} else { | ||
const filterFunction = getFilterFunction(filter); | ||
if (filterFunction) { | ||
replacement = filterFunction(replacement); | ||
} | ||
replacement = processor(replacement); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of the the early return if the processor
arg is passed in, check for filters first and apply them.
Moved the processor
call after filters since it looks like that is used to make the slugs safer for URL/filenames.
Also happy to update the docs if the rest of the code looks good 👍 |
✅ Deploy Preview for decap-www canceled.
|
Could really use this feature, hopefully it gets approved and merged! |
Process template filters first, then strip `'` and `.` characters from slug strings. Fixes decaporg#4783
If this allows use setting for example our own slug filter, it would be awesome. For example: slug: {{title | my_own_slugify}} |
Process template filters first, then strip
'
and.
characters from slug strings.Fixes #4783
Summary
Provides greater control over field values used in entry slug strings.
Test plan
Added a new
formatters
test which failed under the existing setup. UpdatedcompileStringTemplate()
function such that new test and all existing tests pass.Checklist
yarn format
.yarn test
.