pluginpal / strapi-plugin-sitemap

🔌 Generate a highly customizable sitemap XML in Strapi CMS
https://www.pluginpal.io/plugin/sitemap
MIT License
252 stars 53 forks source link

Feature Request: i18n `prefix_except_default` strategy #158

Closed reslear closed 10 months ago

reslear commented 10 months ago

Implement strategy like prefix_except_default

is default language en for /[locale]/blog/[id]:

expected:

also problem with whitespace prefixes (//blog/123):

boazpoolman commented 10 months ago

So, I'm seeing two topics here.

You have an issue with duplicate forward slashes. Weirdly enough, because there is code in place to remove those, see: https://github.com/boazpoolman/strapi-plugin-sitemap/blob/master/server/services/pattern.js#L140C79-L140C79 If you can write up a new issue about that with proper steps to reproduce I can take a look at that.

For the prefix_except_default feature. You should allready be able to do this, but with a slightly different strategy. You can create different patterns for different locales.

So the EN pattern would be /blog/[id] And then you would have another pattern for ES, which would be /[locale]/blog/[id]. Or even /es/blog/[id] should do.

Does that work for you?

reslear commented 10 months ago

@boazpoolman thx for answering, so...

You have an issue with duplicate forward slashes. Weirdly enough, because there is code in place to remove those, see: https://github.com/boazpoolman/strapi-plugin-sitemap/blob/master/server/services/pattern.js#L140C79-L140C79 If you can write up a new issue about that with proper steps to reproduce I can take a look at that.

Well, it is still to come to this (if the option to make locale empty by default is developed), because by default locale cannot be `` empty. By the way, this is an idea.

So the EN pattern would be /blog/[id] And then you would have another pattern for ES, which would be /[locale]/blog/[id]. Or even /es/blog/[id] should do.

Yes I thought about that, but when ~20 languages is it worth it to manually do it for each one separately? if there was an exception option.

boazpoolman commented 10 months ago

About the double slashes; I'm still not quite sure how this is happening. Please create another issue and follow the issue template, providing me with steps to reproduce.

About this issue (#158), in the case of 20 languages you could just make one generic URL pattern, and create a single one for a specific language. That second pattern will then override the generic one.

reslear commented 10 months ago

No concerns about the double slashes; originally, I anticipated a potential issue down the road, especially if there were plans to develop an empty default language. However, the code already addresses this scenario.

To streamline, might want to contemplate incorporating a boolean setting such as "replace default language with empty value."

boazpoolman commented 10 months ago

I'll take that in consideration!

reslear commented 10 months ago

About this issue (#158), in the case of 20 languages you could just make one generic URL pattern, and create a single one for a specific language. That second pattern will then override the generic one.

ok, and I'll try this, as it looks like a potentially working workaround

reslear commented 10 months ago

Yes you are right this setup is overwritten and works as expected. Thank you

Screenshot 2024-01-27 at 06 39 27
boazpoolman commented 10 months ago

Great! I'll close this issue then.