diff --git a/src/routes/sitemap.xml.js b/src/routes/sitemap.xml.js index f1de5b4..da8e216 100644 --- a/src/routes/sitemap.xml.js +++ b/src/routes/sitemap.xml.js @@ -47,7 +47,7 @@ export async function get (req, res, next) { baseURL = `http${(req.httpVersion >= 2) ? 's' : ''}://${req.headers.host}` // Get locations - const locationsReq = await fetch(`${apiEndpoints.rest}/items/locations?fields=slug,country.slug`) + const locationsReq = await fetch(`${apiEndpoints.rest}/items/locations?fields=slug,country.slug,modified_on`) const locationsData = await locationsReq.json() const locations = locationsData.data @@ -56,7 +56,7 @@ export async function get (req, res, next) { const latestPhotoReq = await fetch(`${apiEndpoints.rest}/items/photos?fields=created_on&limit=1&sort=created_on&filter[location.slug][rlike]=%${location.slug}`) const latestPhotoData = await latestPhotoReq.json() const latestPhoto = latestPhotoData.data[0] - location.updated = latestPhoto.created_on + location.updated = latestPhoto ? latestPhoto.created_on : location.modified_on return location }) await Promise.all(updatedLocations) @@ -68,4 +68,4 @@ export async function get (req, res, next) { // Render sitemap const sitemap = render(pages, locations) res.end(sitemap) -} +} \ No newline at end of file