From da57c1a83527d2d55e995761bab94db21887a3bf Mon Sep 17 00:00:00 2001 From: Sing Ming Chen Date: Wed, 1 Nov 2023 11:22:43 +0000 Subject: [PATCH] uplift the theater urls to front of the sitemap --- src/helper/sitemapGenrator.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/helper/sitemapGenrator.ts b/src/helper/sitemapGenrator.ts index d295fd9..7a421cb 100644 --- a/src/helper/sitemapGenrator.ts +++ b/src/helper/sitemapGenrator.ts @@ -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(''); }