editorial-shelf-collection-page.ts
1 import type I18N from '@amp/web-apps-localization'; 2 import type { GenericPage } from '@jet-app/app-store/api/models'; 3 import type { SeoData } from '@amp/web-app-components/src/components/MetaTags/types'; 4 import { isPageHeaderShelf } from '~/components/jet/shelf/PageHeaderShelf.svelte'; 5 import { getPlatformFromPage } from '~/utils/seo/common'; 6 import { commaSeparatedList } from '../string-formatting'; 7 8 export function seoDataForEditorialShelfCollectionPage( 9 page: GenericPage, 10 i18n: I18N, 11 ): SeoData { 12 let title = page.title; 13 let description; 14 const headerShelf = page.shelves.find(isPageHeaderShelf); 15 16 if (headerShelf) { 17 title = headerShelf.items[0].title; 18 description = headerShelf.items[0].subtitle; 19 } 20 21 if (!description) { 22 const platform = getPlatformFromPage(page); 23 const titles = page.shelves 24 .filter((shelf) => !isPageHeaderShelf(shelf)) 25 .flatMap(({ items }) => items) 26 .slice(0, 3) 27 .map((item) => item.title); 28 29 description = i18n.t( 30 'ASE.Web.AppStore.Meta.EditorialShelfCollection.Description', 31 { 32 platform, 33 listOfApps: commaSeparatedList(titles), 34 }, 35 ); 36 } 37 38 const titleWithSiteName = i18n.t( 39 'ASE.Web.AppStore.Meta.TitleWithSiteName', 40 { title }, 41 ); 42 43 return { 44 pageTitle: titleWithSiteName, 45 socialTitle: titleWithSiteName, 46 appleTitle: titleWithSiteName, 47 description, 48 socialDescription: description, 49 appleDescription: description, 50 }; 51 }