/ src / utils / seo / app-event-detail-page.ts
app-event-detail-page.ts
 1  import type { GenericPage } from '@jet-app/app-store/api/models';
 2  import type I18N from '@amp/web-apps-localization';
 3  import type { SeoData } from '@amp/web-app-components/src/components/MetaTags/types';
 4  
 5  import { isAppEventDetailShelf } from '~/components/jet/shelf/AppEventDetailShelf.svelte';
 6  import { truncateAroundLimit } from '~/utils/string-formatting';
 7  import { MAX_DESCRIPTION_LENGTH } from '~/utils/seo/common';
 8  
 9  export function seoDataForAppEventDetailPage(
10      page: GenericPage,
11      i18n: I18N,
12      language: string,
13  ): SeoData {
14      const appEventDetailShelf = page.shelves.find(isAppEventDetailShelf);
15  
16      const { appEvent } = appEventDetailShelf?.items[0] || {};
17  
18      if (!appEvent) {
19          return {};
20      }
21  
22      const title = appEvent.title;
23      const description = truncateAroundLimit(
24          appEvent.detail,
25          MAX_DESCRIPTION_LENGTH,
26          language,
27      );
28  
29      return {
30          pageTitle: title,
31          socialTitle: title,
32          appleTitle: title,
33          description,
34          socialDescription: description,
35          appleDescription: description,
36          crop: 'fo',
37          twitterCropCode: 'fo',
38          artworkUrl: appEvent?.moduleArtwork?.template,
39          imageAltTitle: i18n.t('ASE.Web.AppStore.Meta.Image.AltText', {
40              title: title,
41          }),
42      };
43  }