From bce557cc2dc767628bed6aac87301a1be7c5431b Mon Sep 17 00:00:00 2001 From: rxliuli Date: Tue, 4 Nov 2025 05:03:50 +0800 Subject: init commit --- src/utils/seo/charts-hub-page.ts | 46 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/utils/seo/charts-hub-page.ts (limited to 'src/utils/seo/charts-hub-page.ts') diff --git a/src/utils/seo/charts-hub-page.ts b/src/utils/seo/charts-hub-page.ts new file mode 100644 index 0000000..1b670ad --- /dev/null +++ b/src/utils/seo/charts-hub-page.ts @@ -0,0 +1,46 @@ +import type { ChartsHubPage, Lockup } from '@jet-app/app-store/api/models'; +import type { SeoData } from '@amp/web-app-components/src/components/MetaTags/types'; +import type I18N from '@amp/web-apps-localization'; +import { getPlatformFromPage } from '~/utils/seo/common'; +import { truncateAroundLimit } from '~/utils/string-formatting'; + +export function seoDataForChartsHubPage( + page: ChartsHubPage, + i18n: I18N, + language: string, +): SeoData { + const platform = getPlatformFromPage(page); + const title = i18n.t('ASE.Web.AppStore.Meta.TitleWithSiteName', { + title: i18n.t('ASE.Web.AppStore.Meta.ChartsHub.Title', { + platform, + }), + }); + + let description; + const items = page.charts[0].segments[0].shelves[0].items as Array; + + if (items) { + const appsTitles = items.map(({ title }) => title); + + description = truncateAroundLimit( + i18n.t('ASE.Web.AppStore.Meta.ChartsHub.Description', { + platform, + listing1: appsTitles[0], + listing2: appsTitles[1], + listing3: appsTitles[2], + listing4: appsTitles[3], + }), + 160, + language, + ); + } + + return { + pageTitle: title, + socialTitle: title, + appleTitle: title, + description, + socialDescription: description, + appleDescription: description, + }; +} -- cgit v1.2.3