fedeya / remix-sitemap

Sitemap generator for Remix applications
https://npmjs.com/remix-sitemap
MIT License
95 stars 5 forks source link

Value of loc should not be appended to alternate href #15

Closed vdjurdjevic closed 1 year ago

vdjurdjevic commented 1 year ago

Hello,

I am trying to implement custom entry generation with generateEntries function on sitemap handle, but I am not able to generate what I want because loc value is appended to alternate href. Here is the problem:

https://github.com/fedeya/remix-sitemap/blob/eeafd0add07ea138eda91fe21e0909dd98c5be05/src/utils/xml.ts#L161

According to this: [https://developers.google.com/search/docs/specialty/international/localized-versions#sitemap](Google's sitemap guide), I should have all localized versions as locs, and also all localized versions as alternate hrefs for every loc (makes no sense to me, but that's how Google want's it).

So, what I am trying to return as entries is this:

{ loc: '/', alternateRefs: [ { href: '/', hreflang: 'sr' }, { href: '/en', hreflang: 'en' }, ] }, { loc: '/en', alternateRefs: [ { href: '/', hreflang: 'sr' }, { href: '/en', hreflang: 'en' }, ] }

But generated sitemap is not valid, because I get /en/en for alternate href for second entry.

fedeya commented 1 year ago

Hi @vdjurdjevic!

maybe can be added an absolute param in alternateRefs to avoid concatenation between href and loc to help in this use cases

vdjurdjevic commented 1 year ago

Hey, tnx for fast reply!

I think that would be great solution :)

fedeya commented 1 year ago

@vdjurdjevic this should be working on v1.3.1