I have no idea how hard this would be but do you all think this Solution from @kishanprmr could somehow be added to the TEXT HELPER piece?
Personally, I can see doing this over and over.
What do you think @ashrafsam ?
TimMan
I have no idea how hard this would be but do you all think this Solution from @kishanprmr could somehow be added to the TEXT HELPER piece?
Personally, I can see doing this over and over.
What do you think @ashrafsam ?
TimMan
@TimMan Maybe change the Replace action, instead of having 1 search and 1 replace value to a list of searches and replace values like this?
If it makes sense we can ping our pieces team to see what they can do about it
That was exactly what I was looking for before I turned to the Code Piece!
@ashrafsam, similar to the above request, is there any chance we could add ‘slugify’ to the text helper piece, I think it would be beneficial for when specifying blog URL’s.
For the time being, I just use a key:value
pair, and put the title from whatever piece as the value
, then target it in a code piece. I will paste the code here in case it helps anyone else:
export const code = async (inputs) => {
// Extract the title from inputs
const title = inputs.title;
// Function to slugify text
const slugify = (text) => {
return text
.toString()
.toLowerCase()
.trim()
.replace(/\s+/g, '-') // Replace spaces with hyphens
.replace(/[^\w-]+/g, '') // Remove non-word characters except hyphens
.replace(/--+/g, '-'); // Replace consecutive hyphens with a single hyphen
};
// Generate the slug from the title
const slug = slugify(title);
// Return the slug
return slug;
};
Result:
I feel this addition would be great. (I know we can just use the reg-ex too, but hey why not expand the text helper to make it even more awesome than it already is).
Kind regards,
GunnerJnr