-
-
Notifications
You must be signed in to change notification settings - Fork 836
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
Cleaned up discussion idWithSlug handling #2046
Cleaned up discussion idWithSlug handling #2046
Conversation
1e04451
to
11c8d06
Compare
Because we now auto-format our JS code with Prettier, this branch now has conflicts with Please take the steps outlined in the forum to resolve the conflicts. |
11c8d06
to
1e5df10
Compare
Keeping this logic on the backend could be useful in preparation for transliteration changes. |
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.
This works on my machine and it looks good. Will for sure help with Slug customization for communities that need it.
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.
Seems like a good idea.
There's one question I have before merging: If we use this as a base for transliteration drivers in discussion slugs, perhaps it should be called something different in the API ('fullSlug', perhaps?) As @franzliedke pointed out in #2049, the REST API is something that we are somewhat commited to support. |
@askvortsov1 I'm happy with |
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.
Here's a bit of nitpicking from me.
Otherwise like the idea 👍
You want to rename idWithSlug
into fullSlug
? I think idWithSlug
makes more sense here. It clearly says what it is, and also sounds like it would be a generated value.
@clarkwinkelmann For this particular instance, idWithSlug makes more sense. But if we want to return one value for transliteration, naming it 'fullSlug' might be better, especially if a transliteration driver uses just the ID |
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.
I'm okay with the current version of this PR.
Regarding fullSlug
, I feel like this implies the ID is not part of the content of the attribute. And then, the full slug is just the slug? Because the slug isn't the real canonical ID of a discussion, I would find odd to use an attribute named like that to build links. Having id
in the name clearly implies we can use this in an URL and Flarum will be able to match it with the right discussion even if the slug changes down the road.
@clarkwinkelmann But in the same way, if the transliteration strategy does not include a slug at all, wouldn't idWithSlug also be incorrect? |
Another answer to the name of the object could be |
@askvortsov1 I think this needs discussing in a new issue. Right now routing is fully ID based, and the ID must always be the first part of the URL. Slug is only there for SEO and is irrelevant to routing. If you want to propose a change in how discussion routing works, a new issue would be best I think. If we're only discussing names without a change in how it works, maybe one could be called the "minimal" URL (just id) and the other the "canonical" or "friendly" URL (id + slug) ? Maybe |
Sorry, I don't think I'm wording this well. I recognize that this idWithSlug is only there for SEO, but if we want to have it vary depending on the transliteration scheme, imo we should call it something generic enough that its not tied to any given implementation. I apologize for all the bikeshedding here, I just think that when we choose a name that goes in core's public REST API, we should support it. As per https://en.wikipedia.org/wiki/Clean_URL, perhaps 'cleanId' (or 'friendlyId' as you suggest) could be the way to go here. |
IMO, the word "id" needs to be in it, because the URL structure is So yeah, maybe one of Even though the Wikipedia page makes it very clear what "clean URL" mean, I feel like it sounds like |
@flarum/core Do we have a preference for friendlyId or seoId? |
@askvortsov1 between those two I vote |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. We do this to keep the amount of open issues to a manageable minimum. |
Superceded by #2456 |
Fixes #1360
Changes proposed in this pull request:
Reviewers should focus on:
Confirmed
composer test
).