Closed KantiKuijk closed 1 year ago
Great contribution, thank you ! I will release it asap 👍
@KantiKuijk FYI, i just made new release for vite-plugin-sitemap
and vite-ssg-sitemap
to use new version of sitemap-ts
that is awesome, I never expected such a quick turnaround :)
@jbaubree It looks to me like the release of vite-plugin-sitemap
didn't work out. I'm guessing the updated sitemap-ts didn't get packaged by pkgroll or something because in dist/index.js
(https://www.npmjs.com/package/vite-plugin-sitemap?activeTab=code) it doesn't reflect the changes. (Searching for getFormattedSitemap function and looking at the changefreq, priority and lastmod in that function). I didn't check vite-ssg-sitemap
@KantiKuijk il will check it out asap
@KantiKuijk can you try v0.5.1
?
v0.5.1
is working great! no errors on build anymore, thanks for the quick response and fix.
Using the vite-plugin-sitemap, I wanted the ability to give some routes/pages a different priority than others. This pull request adds this ability, although it would have to travel upstream to be useful in the plugin. Being backwards compatible, it is still possible to use it as before. But now the
priority
option can be given a number (as before) as well as an object. The object maps routes to their respective priorities, the route being the key and the priority being the value. It is not needed to include every single route in the mapping object. A user can define the'*'
route/key to be used as the default. Every route that is not mapped, will get the value of the'*'
route. If the'*'
route is missing, it will use the hardcoded default from options.ts. Superfluous route mappings are ignored. Since this was easily extendible to thechangefreq
andlastmod
options as well, they work in the same way.The reason for changing options.ts and pulling out the object with default values, is such that those default values can be easily accessed, keeping everything DRY.
I included tests for
changefreq
andpriority
, skippinglastmod
because Dates are annoying. I also updated the readme to reflect these changes.If the implementation is lacking or should be done differently, please let me know, I'm very willing to adapt it. If on the other hand this feature is not wanted, that would be a shame imo, as I do believe it to be valuable.