summaryrefslogtreecommitdiff
path: root/src/utils/seo/editorial-shelf-collection-page.ts
diff options
context:
space:
mode:
authorrxliuli <rxliuli@gmail.com>2025-11-04 05:03:50 +0800
committerrxliuli <rxliuli@gmail.com>2025-11-04 05:03:50 +0800
commitbce557cc2dc767628bed6aac87301a1be7c5431b (patch)
treeb51a051228d01fe3306cd7626d4a96768aadb944 /src/utils/seo/editorial-shelf-collection-page.ts
init commit
Diffstat (limited to 'src/utils/seo/editorial-shelf-collection-page.ts')
-rw-r--r--src/utils/seo/editorial-shelf-collection-page.ts51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/utils/seo/editorial-shelf-collection-page.ts b/src/utils/seo/editorial-shelf-collection-page.ts
new file mode 100644
index 0000000..dd152df
--- /dev/null
+++ b/src/utils/seo/editorial-shelf-collection-page.ts
@@ -0,0 +1,51 @@
+import type I18N from '@amp/web-apps-localization';
+import type { GenericPage } from '@jet-app/app-store/api/models';
+import type { SeoData } from '@amp/web-app-components/src/components/MetaTags/types';
+import { isPageHeaderShelf } from '~/components/jet/shelf/PageHeaderShelf.svelte';
+import { getPlatformFromPage } from '~/utils/seo/common';
+import { commaSeparatedList } from '../string-formatting';
+
+export function seoDataForEditorialShelfCollectionPage(
+ page: GenericPage,
+ i18n: I18N,
+): SeoData {
+ let title = page.title;
+ let description;
+ const headerShelf = page.shelves.find(isPageHeaderShelf);
+
+ if (headerShelf) {
+ title = headerShelf.items[0].title;
+ description = headerShelf.items[0].subtitle;
+ }
+
+ if (!description) {
+ const platform = getPlatformFromPage(page);
+ const titles = page.shelves
+ .filter((shelf) => !isPageHeaderShelf(shelf))
+ .flatMap(({ items }) => items)
+ .slice(0, 3)
+ .map((item) => item.title);
+
+ description = i18n.t(
+ 'ASE.Web.AppStore.Meta.EditorialShelfCollection.Description',
+ {
+ platform,
+ listOfApps: commaSeparatedList(titles),
+ },
+ );
+ }
+
+ const titleWithSiteName = i18n.t(
+ 'ASE.Web.AppStore.Meta.TitleWithSiteName',
+ { title },
+ );
+
+ return {
+ pageTitle: titleWithSiteName,
+ socialTitle: titleWithSiteName,
+ appleTitle: titleWithSiteName,
+ description,
+ socialDescription: description,
+ appleDescription: description,
+ };
+}