FIX: Improve category hashtag lookup (PR #10133)

This commit improves support for sub-sub-categories and does not include the ID of the category in the slug, which fixes the composer preview.

GitHub

This pull request has been mentioned on Discourse Meta. There might be relevant details there:

https://meta.discourse.org/t/hyphenated-categories-in-preview/156110/5

When would query be blank?

Can we do one SQL query instead of slug_path.size queries?

Sure, that was needed for three level mentions.

Sure, that was needed for three level mentions.

Very welcome fix! thanks @udan11 !