Closed reslear closed 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?
@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.
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.
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."
I'll take that in consideration!
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
Yes you are right this setup is overwritten and works as expected. Thank you
Great! I'll close this issue then.
Implement strategy like prefix_except_default
is default language
en
for/[locale]/blog/[id]
:expected:
/en/blog/123
->/blog/123
/es/blog/123
->/es/blog/123
also problem with whitespace prefixes (
//blog/123
):Conditional string
(maybe need integrate engine like handlebars/ejs end etc..) - https://handlebarsjs.com/guide/block-helpers.html#conditionals/[locale ? locale + '/' : '' ]
.replace('//', '/')