Skip to content

Commit

Permalink
uplift the theater urls to front of the sitemap
Browse files Browse the repository at this point in the history
  • Loading branch information
Asing1001 committed Nov 1, 2023
1 parent 7659099 commit da57c1a
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/helper/sitemapGenrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,21 @@ ${await getDocument()}
}

async function getDocument() {
const theaters = await Mongo.db
.collection('theaters')
.find({}, { projection: { name: 1, _id: 0 } })
.toArray();
const theaterUrls = theaters.map(({ name }) => `/theater/${name}`);

const movies = await Mongo.db
.collection('mergedDatas')
.find({}, { projection: { movieBaseId: 1 } })
.sort({ movieBaseId: -1 })
.toArray();
const movieUrls = movies.map(({ movieBaseId }) => `/movie/${movieBaseId}`);
const theaters = await Mongo.db
.collection('theaters')
.find({}, { projection: { name: 1, _id: 0 } })
.toArray();
const theaterUrls = theaters.map(({ name }) => `/theater/${name}`);

return defaultUrl
.concat(movieUrls, theaterUrls)
.concat(theaterUrls, movieUrls)
.map((url) => getSiteMapRow(`${rootUrl}${url}`))
.join('');
}
Expand Down

0 comments on commit da57c1a

Please sign in to comment.