feat(slugs): allow filters in template strings#6690
Open
stormwarning wants to merge 1 commit intodecaporg:mainfrom
Open
feat(slugs): allow filters in template strings#6690stormwarning wants to merge 1 commit intodecaporg:mainfrom
stormwarning wants to merge 1 commit intodecaporg:mainfrom
Conversation
stormwarning
commented
Feb 10, 2023
Comment on lines
+193
to
+199
| 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); |
Author
There was a problem hiding this comment.
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.
Author
|
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}} |
Merged
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
formatterstest which failed under the existing setup. UpdatedcompileStringTemplate()function such that new test and all existing tests pass.Checklist
yarn format.yarn test.