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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
import type { Opt } from '@jet/environment/types/optional';
import type { Organization } from 'schema-dts';
import type { WebRenderablePage } from '@jet-app/app-store/api/models/web-renderable-page';
import type I18N from '@amp/web-apps-localization';
import type { SeoData } from '@amp/web-app-components/src/components/MetaTags/types';
export const MAX_DESCRIPTION_LENGTH = 160;
export const AppleOrganization: Organization = {
'@type': 'Organization',
name: 'Apple Inc',
url: 'http://www.apple.com',
logo: {
'@type': 'ImageObject',
url: 'https://www.apple.com/ac/structured-data/images/knowledge_graph_logo.png',
},
};
export function updateCanonicalURL(
page: WebRenderablePage,
canonicalURL: string,
): void {
const seoData = page.seoData as Opt<SeoData>;
if (!seoData) {
return;
}
seoData.url = canonicalURL;
}
export function seoDataForAnyPage(
page: WebRenderablePage,
i18n: I18N,
): SeoData {
const pageTitle =
'title' in page
? i18n.t('ASE.Web.AppStore.Meta.TitleWithPlatformAndSiteName', {
title: page.title,
platform: getPlatformFromPage(page),
})
: i18n.t('ASE.Web.AppStore.Meta.SiteName');
const description = i18n.t('ASE.Web.AppStore.Meta.Description');
return {
url: page.canonicalURL ?? '',
siteName: i18n.t('ASE.Web.AppStore.Meta.SiteName'),
pageTitle,
socialTitle: pageTitle,
appleTitle: pageTitle,
description,
socialDescription: description,
appleDescription: description,
width: 1200,
height: 630,
twitterWidth: 1200,
twitterHeight: 630,
twitterCropCode: 'wa',
crop: 'wa',
fileType: 'jpg',
artworkUrl: '/assets/images/share/app-store.png',
twitterSite: '@AppStore',
};
}
export function getPlatformFromPage(page: WebRenderablePage): Opt<string> {
return page.webNavigation?.platforms.find((platform) => platform.isActive)
?.action.title;
}
|