feat(BOOK-58): Added destination filter pages to sitemap
Approved-by: Linus Flood
This commit is contained in:
@@ -2,11 +2,12 @@ import { getStore } from "@netlify/blobs"
|
||||
|
||||
import { env } from "@/env/server"
|
||||
|
||||
import type { SitemapData, SyncItem } from "@/types/sitemap"
|
||||
import type { HotelFilterEntry, SitemapData, SyncItem } from "@/types/sitemap"
|
||||
|
||||
const branch = env.CMS_BRANCH
|
||||
const environment = env.CMS_ENVIRONMENT
|
||||
const entriesKey = `${environment}/${branch}/entries`
|
||||
const hotelFiltersKey = `${environment}/${branch}/hotelFilters`
|
||||
const syncTokenKey = `${environment}/${branch}/syncToken`
|
||||
const sitemapDataKey = `${environment}/${branch}/sitemapData`
|
||||
const lastUpdatedKey = `${environment}/${branch}/lastUpdated`
|
||||
@@ -14,6 +15,13 @@ const MAX_ENTRIES_PER_SITEMAP = 50000
|
||||
|
||||
// We need to wrap `getStore` because calling it in the root of the file causes
|
||||
// it to be executed during build time. This is not supported by Netlify.
|
||||
// To run this locally, you need to change the arguments to `getStore` like this:
|
||||
// return getStore({
|
||||
// name: "sitemap",
|
||||
// siteID: "SITE_ID from netlify",
|
||||
// token: "Personal access token from Netlify",
|
||||
// })
|
||||
// See https://docs.netlify.com/build/data-and-storage/netlify-blobs/#getstore for more info.
|
||||
function store() {
|
||||
return getStore("sitemap")
|
||||
}
|
||||
@@ -22,6 +30,12 @@ export async function saveEntries(entries: SyncItem[]) {
|
||||
await store().setJSON(entriesKey, entries)
|
||||
}
|
||||
|
||||
export async function saveHotelFilters(
|
||||
hotelFilters: Record<string, HotelFilterEntry[]>
|
||||
) {
|
||||
await store().setJSON(hotelFiltersKey, hotelFilters)
|
||||
}
|
||||
|
||||
export async function saveSitemapData(sitemapData: SitemapData) {
|
||||
await store().setJSON(sitemapDataKey, sitemapData)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user