Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions apps/web/locales/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -1221,6 +1221,8 @@
"shareAuditCopyLinkTitle": "ZkopΓ­rovat odkaz na produkt",
"shareAuditCopiedLinkBtn": "βœ“ Odkaz zkopΓ­rovΓ‘n!",
"shareAuditCopyLinkBtn": "KopΓ­rovat odkaz",
"shareAuditDownloadPngTitle": "StΓ‘hnout obrΓ‘zek karty pravdy (PNG 4:5) pro sΓ­tΔ› a chat",
"shareAuditDownloadPngBtn": "StΓ‘hnout kartu (PNG 4:5)",
"specsToolbarCopiedMd": "10 skupin parametrΕ― zkopΓ­rovΓ‘no!",
"specsToolbarCopyMd": "KopΓ­rovat 10 skupin parametrΕ― MD",
"specsToolbarExportCsv": "Exportovat parametry CSV",
Expand Down
2 changes: 2 additions & 0 deletions apps/web/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1221,6 +1221,8 @@
"shareAuditCopyLinkTitle": "Copy product URL",
"shareAuditCopiedLinkBtn": "βœ“ Copied link!",
"shareAuditCopyLinkBtn": "Copy link",
"shareAuditDownloadPngTitle": "Download a 4:5 truth card PNG to share on forums or chat",
"shareAuditDownloadPngBtn": "Download truth card (PNG)",
"specsToolbarCopiedMd": "Copied 10-group specs!",
"specsToolbarCopyMd": "Copy 10-group specs MD",
"specsToolbarExportCsv": "Export specs CSV",
Expand Down
2 changes: 2 additions & 0 deletions apps/web/locales/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1221,6 +1221,8 @@
"shareAuditCopyLinkTitle": "Sao chΓ©p đường dαΊ«n sαΊ£n phαΊ©m",
"shareAuditCopiedLinkBtn": "βœ“ Đã chΓ©p link!",
"shareAuditCopyLinkBtn": "ChΓ©p link",
"shareAuditDownloadPngTitle": "TαΊ£i αΊ£nh thαΊ» sα»± thαΊ­t (PNG 4:5) để chia sαΊ» lΓͺn diα»…n Δ‘Γ n hoαΊ·c nhΓ³m chat",
"shareAuditDownloadPngBtn": "TαΊ£i thαΊ» sα»± thαΊ­t (PNG 4:5)",
"specsToolbarCopiedMd": "Đã chΓ©p 10 nhΓ³m thΓ΄ng sα»‘!",
"specsToolbarCopyMd": "Sao chΓ©p 10 nhΓ³m thΓ΄ng sα»‘ MD",
"specsToolbarExportCsv": "XuαΊ₯t CSV thΓ΄ng sα»‘",
Expand Down
21 changes: 19 additions & 2 deletions apps/web/src/app/[locale]/compare/[versus]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ import {
import { catalogRowSlug, type ItemCatalogRow } from '@/lib/item-directory';
import { getItemSlugsFor } from '@/server/rate/item-directory';
import { normalizeRateLocale } from '@/lib/rate-i18n';
import { defaultOpenGraph, fitTitle, fitDescription } from '@/lib/seo';
import {
buildOgTruthCardImage,
defaultOpenGraph,
defaultTwitterCard,
fitTitle,
fitDescription,
} from '@/lib/seo';
import { scoreMasterProductForLeaderboard } from '@/lib/leaderboard-engine';
import PageShell from '../../components/page-shell';
import CompareWorkspace from '@/components/compare/CompareWorkspace';
Expand Down Expand Up @@ -102,9 +108,12 @@ export async function generateMetadata({
return notFoundMeta();
}

const canonicalVersusSlug = plan
? plan.canonical.replace(/^\/compare\//, '')
: `${pair[0]}-vs-${pair[1]}`;
const canonicalUrl = plan
? `https://rate.vn${plan.canonical}`
: `https://rate.vn/compare/${pair[0]}-vs-${pair[1]}`;
: `https://rate.vn/compare/${canonicalVersusSlug}`;
const fullTitle = t('versusMetaTitle', { nameA: a.name, nameB: b.name });
// Both names first; the fixed text, then the site name, give way to fit a
// search result (DOS/Rate#777). The share card keeps the full title.
Expand All @@ -124,6 +133,12 @@ export async function generateMetadata({
}),
lang
);
const ogImage = buildOgTruthCardImage({
type: 'versus',
versus: canonicalVersusSlug,
locale: lang,
alt: `${a.name} vs ${b.name}`,
});

return {
title,
Expand All @@ -136,7 +151,9 @@ export async function generateMetadata({
title: fullTitle,
description,
url: canonicalUrl,
images: [ogImage],
},
twitter: defaultTwitterCard(ogImage),
};
}

Expand Down
27 changes: 24 additions & 3 deletions apps/web/src/app/[locale]/deals/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ import {
type ItemCatalogRow,
} from '@/server/rate';
import { normalizeRateLocale } from '@/lib/rate-i18n';
import {
buildOgTruthCardImage,
defaultOpenGraph,
defaultTwitterCard,
} from '@/lib/seo';
import PageShell from '../components/page-shell';
import CompareTrayBar from '@/components/compare/CompareTrayBar';
import DealFinderWorkspace from '@/components/deals/DealFinderWorkspace';
Expand All @@ -26,12 +31,28 @@ export async function generateMetadata({
const { locale } = await params;
const lang = normalizeRateLocale(locale);
const t = await getTranslations({ locale: lang, namespace: 'deals' });
const title = t('metaTitle');
const description = t('metaDescription');
const canonicalUrl = 'https://rate.vn/deals';
const ogImage = buildOgTruthCardImage({
type: 'deals',
locale: lang,
alt: title,
});
return {
title: t('metaTitle'),
description: t('metaDescription'),
title,
description,
alternates: {
canonical: 'https://rate.vn/deals',
canonical: canonicalUrl,
},
openGraph: {
...defaultOpenGraph(lang),
title,
description,
url: canonicalUrl,
images: [ogImage],
},
twitter: defaultTwitterCard(ogImage),
};
}

Expand Down
26 changes: 14 additions & 12 deletions apps/web/src/app/[locale]/smartphones/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,10 @@ import { startRenderTiming } from '@/lib/render-timing';
import { bayesianTierKey, radarExplanation } from '@/lib/product-detail-copy';
import {
absoluteUrl,
buildOgTruthCardImage,
defaultOpenGraph,
defaultTwitterCard,
fitTitle,
SHARE_IMAGE,
fitDescription,
} from '@/lib/seo';
import JReviewsSection from '@/components/reviews/JReviewsSection';
Expand Down Expand Up @@ -246,9 +247,15 @@ export async function generateCategoryProductMetadata(
const hasPrice = marketStats.minPrice > 0;
const name = (isItemGroup ? itemMeta?.name : null) || product.name;
const minPrice = formatNumber(marketStats.minPrice, locale);
const canonicalUrl = `https://rate.vn${categoryBasePath}/${
itemRoute?.kind === 'render' ? itemRoute.itemSlug : product.slug
}`;
const canonicalSlug =
itemRoute?.kind === 'render' ? itemRoute.itemSlug : product.slug;
const canonicalUrl = `https://rate.vn${categoryBasePath}/${canonicalSlug}`;
const ogImage = buildOgTruthCardImage({
type: 'product',
slug: canonicalSlug,
locale: lang,
alt: name,
});

return {
// The product name first; the site name, then the price give way to fit
Expand Down Expand Up @@ -285,18 +292,12 @@ export async function generateCategoryProductMetadata(
title: t('ogTitle', { name }),
description: hasPrice ? t('ogDesc', { minPrice }) : t('ogDescNoStock'),
url: canonicalUrl,
// A credited photo carries its notice only on the page, so a share
// preview uses the site image instead (DOS/Rate#1756).
images: [shareImage(firstImageUrl(product.images))],
images: [ogImage],
},
twitter: defaultTwitterCard(ogImage),
};
}

/** The Open Graph image: the product photo, unless it needs a credit. */
function shareImage(src: string | null): string | typeof SHARE_IMAGE {
return src && !deviceImageCredit(src) ? src : SHARE_IMAGE;
}

export async function generateMetadata({
params,
}: {
Expand Down Expand Up @@ -881,6 +882,7 @@ export async function ProductDetailView({
{t('auditPriceBtn', { count: v.offers.length })}
</a>
<ProductShareAuditButton
slug={v.product.slug}
name={v.product.name}
brand={v.product.brand}
modelKey={v.product.model_key}
Expand Down
Loading
Loading