feat(SW-2466): Sorting destinations by country depending on language
Approved-by: Christian Andolf Approved-by: Matilda Landström
This commit is contained in:
@@ -32,6 +32,7 @@ import {
|
||||
destinationOverviewPageRefsSchema,
|
||||
destinationOverviewPageSchema,
|
||||
} from "./output"
|
||||
import { getSortedDestinationsByLanguage } from "./utils"
|
||||
|
||||
import type {
|
||||
City,
|
||||
@@ -170,17 +171,17 @@ export const destinationOverviewPageQueryRouter = router({
|
||||
if (useStaticData) {
|
||||
switch (ctx.lang) {
|
||||
case Lang.da:
|
||||
return destinationsDataDa
|
||||
return getSortedDestinationsByLanguage(destinationsDataDa, ctx.lang)
|
||||
case Lang.de:
|
||||
return destinationsDataDe
|
||||
return getSortedDestinationsByLanguage(destinationsDataDe, ctx.lang)
|
||||
case Lang.fi:
|
||||
return destinationsDataFi
|
||||
return getSortedDestinationsByLanguage(destinationsDataFi, ctx.lang)
|
||||
case Lang.en:
|
||||
return destinationsDataEn
|
||||
return getSortedDestinationsByLanguage(destinationsDataEn, ctx.lang)
|
||||
case Lang.no:
|
||||
return destinationsDataNo
|
||||
return getSortedDestinationsByLanguage(destinationsDataNo, ctx.lang)
|
||||
case Lang.sv:
|
||||
return destinationsDataSv
|
||||
return getSortedDestinationsByLanguage(destinationsDataSv, ctx.lang)
|
||||
default:
|
||||
return []
|
||||
}
|
||||
@@ -258,9 +259,7 @@ export const destinationOverviewPageQueryRouter = router({
|
||||
})
|
||||
)
|
||||
|
||||
const data = destinations.sort((a, b) =>
|
||||
a.country.localeCompare(b.country)
|
||||
)
|
||||
const data = getSortedDestinationsByLanguage(destinations, lang)
|
||||
const fs = await import("node:fs")
|
||||
fs.writeFileSync(
|
||||
`./server/routers/contentstack/destinationOverviewPage/destinations-${lang}.json`,
|
||||
|
||||
Reference in New Issue
Block a user