1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
import type {
ReviewsPage,
ShelfBasedProductPage,
} from '@jet-app/app-store/api/models';
import type { SeoData } from '@amp/web-app-components/src/components/MetaTags/types';
import type { AppStoreObjectGraph } from '@jet-app/app-store/foundation/runtime/app-store-object-graph';
import type I18N from '@amp/web-apps-localization';
import { truncateAroundLimit } from '~/utils/string-formatting';
import { MAX_DESCRIPTION_LENGTH } from '~/utils/seo/common';
import { isProductBadgeShelf } from '~/components/jet/shelf/ProductBadgeShelf.svelte';
export function seoDataForReviewsPage(
i18n: I18N,
page: ReviewsPage,
productPage: ShelfBasedProductPage,
objectGraph: AppStoreObjectGraph,
): SeoData {
const appName = productPage.lockup.title;
const artworkUrl = productPage.lockup.icon?.template;
const badgeShelf = Object.values(productPage.shelfMapping).find(
isProductBadgeShelf,
);
const developerName = badgeShelf?.items.find(
({ key }) => key === 'developer',
)?.caption;
const title = i18n.t('ASE.Web.AppStore.Meta.TitleWithSiteName', {
title: i18n.t('ASE.Web.AppStore.Meta.Reviews.Title', {
appName,
}),
});
const descriptionLocKey = developerName
? 'ASE.Web.AppStore.Meta.Product.Description'
: 'ASE.Web.AppStore.Meta.Product.DescriptionWithoutDeveloperName';
const description = truncateAroundLimit(
i18n.t(descriptionLocKey, {
appName,
developerName,
}),
MAX_DESCRIPTION_LENGTH,
objectGraph.locale.activeLanguage,
);
return {
artworkUrl,
pageTitle: title,
socialTitle: title,
appleTitle: title,
description,
socialDescription: description,
appleDescription: description,
};
}
|