pauloamgomes / contentful-better-slugs

The Better Slugs is a simple UI extension for Contentful CMS that provides a more enhanced way to deal with slug fields.
MIT License
30 stars 16 forks source link

Bug report: forward slashes escaped in Slug Pattern token #10

Closed nbaosullivan closed 1 year ago

nbaosullivan commented 3 years ago

Thanks again for your fantastic Contentful extension.

I have a Slug Pattern configuration for a path field:

[field:parentPage:slug]/[field:title]

The parentPage is a reference field to another page's slug value. This works beautifully if the slug does not contain any forward slashes /, but if the slug has multiple path parts to it, e.g. parent/child then the forward slash is replaced with a hyphen when the slug is generated based on the pattern [field:parentPage:slug]/[field:title].

Instead of populating the slug as parent/child/grandchild it results in parent-child/grandchild.

Is this a bug, or limitation?

pauloamgomes commented 3 years ago

That's a good catch, in fact, don't think it's a bug but more a limitation. Anyway, I'll take a look once have a little time and make it work on the way you mentioned.

nbaosullivan commented 3 years ago

Thanks for the quick reply @pauloamgomes! Look forward to hearing back then, thanks again!

nbaosullivan commented 3 years ago

Hey @pauloamgomes, sorry to poke you about about this, but do you have a guess at when you might be able to take a look at this?

pauloamgomes commented 3 years ago

Hey @nbaosullivan , sorry for the delay, but a bit busy in the meantime.. It should work now, forward slashes when present in referenced fields will not be replaced anymore.

nbaosullivan commented 3 years ago

Hi @pauloamgomes, no worries at all - thank you so much! Looks good to me.

It's had one side effect though, in the field that I have the following pattern: [field:parentPage:slug]/[field:title], the parentPage field was not compulsory, the slug field would remain unchanged if:

However, it seems that despite the having the setting

Do not update slug if entry is published (required)
If the entry is published sometimes is desirable to not change the slug
 Yes

(and the content being published) the slug is automatically updated. Could this change have affected this auto-population?

nbaosullivan commented 3 years ago

I've checked my other fields without the parentPage token, and the prevent-auto-update feature works as expected there. An example where it's fine is articles/[field:title] but when editing published content that has the slug pattern set to [field:parentPage:slug]/[field:title] the prevent-auto-update feature seems to be ignored.

nbaosullivan commented 3 years ago

I've temporarily reverted to f4e4132 so that published URLs aren't overridden.

pauloamgomes commented 3 years ago

Hi @nbaosullivan, that's weird because the change should not affect that functionality.. I did some testing and also can't replicate, resuming:

I have a content model Page Type with a slug field using pattern: [field:name] I have another content model Page, with a reference field to Page Type and a slug based on the page type: /[field:pageType:slug]/[field:title]

I tried to create a new entry and follow the normal workflow, every time that I have the entry published the slug doesn't auto update!

nbaosullivan commented 3 years ago

Thanks for investigating. That is weird, not really sure what's different my side then. Is it necessary to update the extension with this fix? I had it set to self-hosted with your Github url but have now switched to hosting f4e4132 via Contentful

pauloamgomes commented 3 years ago

Yes, the extension got some changes in the meantime, so maybe better to redeploy it and test again

On Tue, Mar 23, 2021 at 10:01 AM nbaosullivan @.***> wrote:

Thanks for investigating. That is weird, not really sure what's different my side then. Is it necessary to update the extension with this fix? I had it set to self-hosted with your Github url but have now switched to hosting f4e4132 via Contentful

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/pauloamgomes/contentful-better-slugs/issues/10#issuecomment-804735504, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAY65KF3KFBYK4TBML3L4DTFBKG5ANCNFSM4YMYLB3Q .

nbaosullivan commented 3 years ago

Hi @pauloamgomes. It correctly does not update the path if the reference field is populated, but if the reference field is not populated, changes to the title update the path, even when the entry is published and the configuration is correctly set. Before this, the behaviour for when the reference field was empty is that the autocomplete wouldn't work - which I think is a fair option, but it would be amazing if when the reference field is missing, it just ignores that part? Either way would be fantastic and would mean I could deploy this update. Thanks so much for your contribution!

pauloamgomes commented 1 year ago

This extension is now archived and replaced by https://github.com/pauloamgomes/contentful-better-slugs-app/tree/V1.0.0