fedeya / remix-sitemap

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

sitemap function applying toString() to lastmod field #42

Closed BryceBlankinship closed 1 year ago

BryceBlankinship commented 1 year ago

It seems as though the sitemap function is applying a toString() to the lastmod field, which messes up js date formatting. This may be something you're unable to change, but just so you're aware passing js dates doesn't work as expected.

`export const sitemap = async () => { const brands = await getAllBrands();

/**TODO: one day make this accurate */
const lastModified = new Date();
lastModified.setMonth(lastModified.getMonth() - 1)

// toString() is messing this up
console.log(lastModified)

return brands.map(brand => ({
    loc: `/products/${brand.name}`,
    lastmod: lastModified //toString() seems to be applied here, converting the output from ISO format to 
    //"Thu Jul 27 2023 19:25:17 GMT-0400 (Eastern Daylight Time)",
    images: [{ loc: `https://storage.googleapis.com/example-logos/${brand.logoUri}` }]
}));

}`

Resulting in this: `

Thu Jul 27 2023 19:25:17 GMT-0400 (Eastern Daylight Time)

But needs to be this:

2023-08-27T23:25:17.083Z

`

BryceBlankinship commented 1 year ago

perhaps add into the docs that you have to use .toISOString()