diff --git a/app/[lang]/(site)/tools/images/[category]/[name]/page.tsx b/app/[lang]/(site)/tools/images/[category]/[name]/page.tsx index fb220e0..1b078fe 100644 --- a/app/[lang]/(site)/tools/images/[category]/[name]/page.tsx +++ b/app/[lang]/(site)/tools/images/[category]/[name]/page.tsx @@ -12,7 +12,7 @@ import { Card } from '@/components/ui/Card' import { alternatesFor } from '@/lib/seo' import { getRequestLang } from '@/lib/serverLang' import { imagesTranslations, type Lang } from '@/lib/i18n' -import { getImage, getNeighbours, imageTitle, inOtherCategory, listCategories } from '@/lib/images' +import { getImage, getNeighbours, imageDescription, imageTitle, inOtherCategory, listCategories } from '@/lib/images' import { absoluteUrl } from '@/lib/siteUrl' import { publicPath } from '@/lib/routes' @@ -39,15 +39,8 @@ export async function generateMetadata({ params }: { params: Params }): Promise< inOtherCategory(category, image.name), ]) const where = shared ? categories.find(c => c.slug === category)?.name : undefined - const display = image.label || image.name - const title = imageTitle(image, lang, where) - const lead = lang === 'de' - ? `Freigestelltes ${display}-Bild aus GTA V${where ? ` (${where})` : ''}, ${image.width} mal ${image.height} Pixel, kostenlos für FiveM-Scripts.` - : `Transparent ${display} image from GTA V${where ? ` (${where})` : ''}, ${image.width} by ${image.height} pixels, free for FiveM scripts.` - const tail = lang === 'de' ? ' Direkt über die CDN-URL nutzbar.' : ' Use the CDN URL directly.' - // A long label pushed the description past the 155 characters a search - // result shows. The CDN hint is the part that can go. - const description = (lead + tail).length <= 155 ? lead + tail : lead + const title = imageTitle(image, lang, where) + const description = imageDescription(image, lang, where) return { title, diff --git a/app/[lang]/(site)/tools/page.tsx b/app/[lang]/(site)/tools/page.tsx index 3d63a30..46b2e9f 100644 --- a/app/[lang]/(site)/tools/page.tsx +++ b/app/[lang]/(site)/tools/page.tsx @@ -90,9 +90,12 @@ function Tool({ tool, lang, index }: { tool: CustomPackage; lang: Lang; index: n {p.screenshot.replace('{name}', )} diff --git a/components/products/ProductCard.tsx b/components/products/ProductCard.tsx index c25a11c..2818f3d 100644 --- a/components/products/ProductCard.tsx +++ b/components/products/ProductCard.tsx @@ -40,13 +40,15 @@ export function ProductCard({ card, lang, headingLevel = 3 }: Props) { // The name right below is the link; the picture adds nothing a // screen reader would need twice. alt="" - fill + // The box's 16:10 as size, so the img carries one in the HTML. + width={1600} + height={1000} // The grid never makes a card wider than about 30rem plus a gap // (`--grid-card`), and on a phone it is the full width. sizes="(max-width: 640px) 100vw, 520px" // Screenshots of a UI: the top holds the title bar and the // navigation, which say most about what is shown. - className="object-cover object-top" + className="h-full w-full object-cover object-top" /> ) : ( diff --git a/lib/images.ts b/lib/images.ts index 6136029..b8dfa89 100644 --- a/lib/images.ts +++ b/lib/images.ts @@ -1,5 +1,6 @@ import { query, queryOne } from '@/lib/db' import type { Lang } from '@/lib/i18n' +import { plainExcerpt } from '@/lib/seo' /** * Image gallery: data access and URL building. @@ -275,12 +276,45 @@ export function imageTitle( const worded = (subject: string) => lang === 'de' ? (isPng ? `${subject}, freigestelltes PNG` : `${subject}, ${format}`) : (isPng ? `${subject}, transparent PNG` : `${subject}, ${format}`) - const candidates = [worded(named), `${named} ${format}`, worded(image.name), `${image.name} ${format}`] + // The short forms differ by language too. "… PNG" in both made the English + // and German page of 637 images share a title (crawl of 25.11.2026). + const short = (subject: string) => lang === 'de' ? `${subject} als ${format}` : `${subject} ${format}` + const candidates = [worded(named), short(named), worded(image.name), short(image.name)] const placed = where ? candidates.map(c => `${c}, ${where}`) : candidates return placed.find(c => c.length <= IMAGE_TITLE_MAX) ?? (where ? `${image.name}, ${where}` : image.name) } +/** Longest description a search result shows. */ +export const IMAGE_DESCRIPTION_MAX = 155 + +/** + * Meta description of an image page. It names the spawn name next to the + * label, because labels repeat: `cavalcade` and `cavalcade2` are both + * "Albany Cavalcade" with the same size, and 174 descriptions were shared by + * two or three pages (crawl of 25.11.2026). `where` as in `imageTitle`. + */ +export function imageDescription( + image: Pick, + lang: Lang, + where?: string, +): string { + const label = image.label?.trim() + const display = label && label.toLowerCase() !== image.name.toLowerCase() + ? `${label} (${image.name})` + : image.name + const place = where ? ` (${where})` : '' + const lead = (subject: string) => lang === 'de' + ? `Freigestelltes Bild von ${subject} aus GTA V${place}, ${image.width} mal ${image.height} Pixel, kostenlos für FiveM-Scripts.` + : `Transparent image of ${subject} from GTA V${place}, ${image.width} by ${image.height} pixels, free for FiveM scripts.` + const tail = lang === 'de' ? ' Direkt über die CDN-URL nutzbar.' : ' Use the CDN URL directly.' + // First the CDN hint goes, then the label; the spawn name stays, it is what + // tells two pages apart. + const candidates = [lead(display) + tail, lead(display), lead(image.name) + tail, lead(image.name)] + return candidates.find(c => c.length <= IMAGE_DESCRIPTION_MAX) + ?? plainExcerpt(lead(image.name), IMAGE_DESCRIPTION_MAX - 1) +} + /** * Whether an image with this spawn name is also published in another * category. Those pages need the category in title and description. diff --git a/lib/pageSeo.ts b/lib/pageSeo.ts index 6e1570e..748e540 100644 --- a/lib/pageSeo.ts +++ b/lib/pageSeo.ts @@ -101,7 +101,7 @@ export const PAGE_SEO: Record> = { }, '/discord/ticket-bot/stats': { en: { - title: 'Bot Statistics', + title: 'Ticket Bot Statistics', description: 'Anonymous live statistics of the MSK Ticket Bot across all Discord servers. No server IDs, usernames or other personal data are shown.', }, de: { @@ -121,14 +121,14 @@ export const PAGE_SEO: Record> = { }, '/legal/terms': { en: { title: 'Terms & Conditions', description: 'The terms and conditions of MSK Scripts for buying and using its resources. The German version is binding, this page is a translation.' }, - de: { title: 'AGB', description: 'Allgemeine Geschäftsbedingungen für den Kauf und die Nutzung der Ressourcen von MSK Scripts.' }, + de: { title: 'Allgemeine Geschäftsbedingungen', description: 'Allgemeine Geschäftsbedingungen für den Kauf und die Nutzung der Ressourcen von MSK Scripts.' }, }, '/legal/imprint': { - en: { title: 'Imprint', description: 'Legal notice of MSK Scripts under § 5 DDG: provider, postal address and contact details of Moritz Kohm in Edingen-Neckarhausen.' }, - de: { title: 'Impressum', description: 'Impressum von MSK Scripts nach § 5 DDG: Anbieter, Anschrift und Kontaktdaten von Moritz Kohm in Edingen-Neckarhausen.' }, + en: { title: 'Imprint and Contact', description: 'Legal notice of MSK Scripts under § 5 DDG: provider, postal address and contact details of Moritz Kohm in Edingen-Neckarhausen.' }, + de: { title: 'Impressum und Kontakt', description: 'Impressum von MSK Scripts nach § 5 DDG: Anbieter, Anschrift und Kontaktdaten von Moritz Kohm in Edingen-Neckarhausen.' }, }, '/legal/privacy': { - en: { title: 'Privacy Policy', description: 'How MSK Scripts handles personal data under the GDPR: what is stored, for how long, who receives it and which rights you have.' }, + en: { title: 'Privacy Policy (GDPR)', description: 'How MSK Scripts handles personal data under the GDPR: what is stored, for how long, who receives it and which rights you have.' }, de: { title: 'Datenschutzerklärung', description: 'Wie MSK Scripts mit personenbezogenen Daten umgeht: was gespeichert wird, wie lange, wer es erhält und welche Rechte du nach der DSGVO hast.' }, }, '/legal/withdrawal': { @@ -223,11 +223,11 @@ export const PAGE_SEO: Record> = { // That is why the title holds what people search for, not the section name. '/tools/images/upload': { en: { - title: 'Submit an Image', + title: 'Submit an Image to the Gallery', description: 'Send us a transparent GTA V or FiveM asset image for the gallery. Reviewed by hand, credited to you, free for everyone to use.', }, de: { - title: 'Bild einreichen', + title: 'Bild für die Galerie einreichen', description: 'Schick uns ein freigestelltes GTA-V- oder FiveM-Asset für die Galerie. Wird von Hand geprüft und ist danach für alle kostenlos nutzbar.', }, }, diff --git a/tests/imageListing.test.ts b/tests/imageListing.test.ts index 2d685fe..bc02ca3 100644 --- a/tests/imageListing.test.ts +++ b/tests/imageListing.test.ts @@ -3,7 +3,7 @@ import { describe, it, expect, beforeEach, vi } from 'vitest' vi.mock('@/lib/db', () => ({ query: vi.fn(), queryOne: vi.fn() })) import { query, queryOne } from '@/lib/db' -import { IMAGE_TITLE_MAX, imageTitle, listImages } from '@/lib/images' +import { IMAGE_DESCRIPTION_MAX, IMAGE_TITLE_MAX, imageDescription, imageTitle, listImages } from '@/lib/images' const mQuery = query as unknown as ReturnType const mQueryOne = queryOne as unknown as ReturnType @@ -52,6 +52,14 @@ describe('imageTitle', () => { expect(title).toBe('baller6, transparent PNG') }) + it('never gives the English and German page the same title', () => { + // ".22 Long Rifle (ammo-22) PNG, Items" stood on both language versions. + const image = { name: 'ammo-22', label: '.22 Long Rifle', ext: 'png' } + expect(imageTitle(image, 'en', 'Items')).not.toBe(imageTitle(image, 'de', 'Items')) + const long = { name: 'acapulcogold_untrimmed_bud', label: 'Acapulco Gold Untrimmed Bud', ext: 'png' } + expect(imageTitle(long, 'en')).not.toBe(imageTitle(long, 'de')) + }) + it('names the category for an image published in two categories', () => { const image = { name: 'ammo-22', label: '.22 Long Rifle', ext: 'png' } const items = imageTitle(image, 'en', 'Items') @@ -88,3 +96,23 @@ describe('imageTitle', () => { expect(title).not.toContain('PNG') }) }) + +describe('imageDescription', () => { + const base = { label: 'Albany Cavalcade', width: 1024, height: 619 } + + it('tells images with the same label and size apart by spawn name', () => { + for (const lang of ['en', 'de'] as const) { + const a = imageDescription({ ...base, name: 'cavalcade' }, lang) + const b = imageDescription({ ...base, name: 'cavalcade2' }, lang) + expect(a).not.toBe(b) + expect(b).toContain('cavalcade2') + } + }) + + it('stays inside what a search result shows', () => { + const long = { name: 'phentermine_hydrochloride_pppetite_suppressant', label: 'Phentermine Hydrochloride Appetite Suppressant', width: 512, height: 512 } + for (const lang of ['en', 'de'] as const) { + expect(imageDescription(long, lang, 'Items').length).toBeLessThanOrEqual(IMAGE_DESCRIPTION_MAX) + } + }) +})