11import { getLocale , getTranslations } from "next-intl/server" ;
2+ import { cache } from "react" ;
23import type { ListingSeoCopy } from "./listingUtils.ts" ;
34
45function splitKeywordList ( value : string ) {
@@ -8,38 +9,40 @@ function splitKeywordList(value: string) {
89 . filter ( Boolean ) ;
910}
1011
11- export async function getListingSeoOptions ( ) {
12- const locale = await getLocale ( ) ;
13- const t = await getTranslations ( { locale, namespace : "Listings.seo" } ) ;
12+ export const getListingSeoOptions = cache (
13+ async function getListingSeoOptions ( ) {
14+ const locale = await getLocale ( ) ;
15+ const t = await getTranslations ( { locale, namespace : "Listings.seo" } ) ;
1416
15- const seoCopy : ListingSeoCopy = {
16- privateHostName : t ( "privateHostName" ) ,
17- fallbackListingName : t ( "fallbackListingName" ) ,
18- residentialConnectName : t ( "residentialConnectName" ) ,
19- residentialIntro : ( { name, location } ) =>
20- location
21- ? t ( "residentialIntroWithLocation" , { name, location } )
22- : t ( "residentialIntro" , { name } ) ,
23- businessIntro : ( { name, location } ) =>
24- location
25- ? t ( "businessIntroWithLocation" , { name, location } )
26- : t ( "businessIntro" , { name } ) ,
27- connect : ( { name, siteName } ) =>
28- t ( "connect" , { name, siteName, explainer : t ( "siteExplainer" ) } ) ,
29- acceptedItemsLabel : t ( "acceptedItemsLabel" ) ,
30- rejectedItemsLabel : t ( "rejectedItemsLabel" ) ,
31- locationKeywords : ( { location } ) => [
32- t ( "keywords.location" , { location } ) ,
33- t ( "keywords.foodScraps" , { location } ) ,
34- t ( "keywords.compost" , { location } ) ,
35- t ( "keywords.foodScrapDropOff" , { location } ) ,
36- t ( "keywords.compostDropOff" , { location } ) ,
37- ] ,
38- baseKeywords : ( ) => splitKeywordList ( t ( "keywords.base" ) ) ,
39- } ;
17+ const seoCopy : ListingSeoCopy = {
18+ privateHostName : t ( "privateHostName" ) ,
19+ fallbackListingName : t ( "fallbackListingName" ) ,
20+ residentialConnectName : t ( "residentialConnectName" ) ,
21+ residentialIntro : ( { name, location } ) =>
22+ location
23+ ? t ( "residentialIntroWithLocation" , { name, location } )
24+ : t ( "residentialIntro" , { name } ) ,
25+ businessIntro : ( { name, location } ) =>
26+ location
27+ ? t ( "businessIntroWithLocation" , { name, location } )
28+ : t ( "businessIntro" , { name } ) ,
29+ connect : ( { name, siteName } ) =>
30+ t ( "connect" , { name, siteName, explainer : t ( "siteExplainer" ) } ) ,
31+ acceptedItemsLabel : t ( "acceptedItemsLabel" ) ,
32+ rejectedItemsLabel : t ( "rejectedItemsLabel" ) ,
33+ locationKeywords : ( { location } ) => [
34+ t ( "keywords.location" , { location } ) ,
35+ t ( "keywords.foodScraps" , { location } ) ,
36+ t ( "keywords.compost" , { location } ) ,
37+ t ( "keywords.foodScrapDropOff" , { location } ) ,
38+ t ( "keywords.compostDropOff" , { location } ) ,
39+ ] ,
40+ baseKeywords : ( ) => splitKeywordList ( t ( "keywords.base" ) ) ,
41+ } ;
4042
41- return {
42- locale,
43- seoCopy,
44- } ;
45- }
43+ return {
44+ locale,
45+ seoCopy,
46+ } ;
47+ }
48+ ) ;
0 commit comments