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
13 changes: 3 additions & 10 deletions app/[lang]/(site)/tools/images/[category]/[name]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -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,
Expand Down
7 changes: 5 additions & 2 deletions app/[lang]/(site)/tools/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,12 @@ function Tool({ tool, lang, index }: { tool: CustomPackage; lang: Lang; index: n
<Image
src={imageSrc(tool.image)}
alt={p.screenshot.replace('{name}', tool.name)}
fill
// The box's 16:9 as size, so the img carries one in the HTML;
// the screenshots differ and are cropped to it.
width={1280}
height={720}
sizes="(max-width: 1023px) 100vw, 50vw"
className="object-cover object-left-top"
className="h-full w-full object-cover object-left-top"
/>
</div>
)}
Expand Down
6 changes: 4 additions & 2 deletions components/products/ProductCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"
/>
) : (
<span className="absolute inset-0 grid place-items-center px-4 text-center font-display text-h3 font-semibold text-[var(--color-muted-foreground)]">
Expand Down
36 changes: 35 additions & 1 deletion lib/images.ts
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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<ImageRecord, 'name' | 'label' | 'width' | 'height'>,
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.
Expand Down
14 changes: 7 additions & 7 deletions lib/pageSeo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export const PAGE_SEO: Record<string, Record<Lang, PageSeo>> = {
},
'/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: {
Expand All @@ -121,14 +121,14 @@ export const PAGE_SEO: Record<string, Record<Lang, PageSeo>> = {
},
'/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': {
Expand Down Expand Up @@ -223,11 +223,11 @@ export const PAGE_SEO: Record<string, Record<Lang, PageSeo>> = {
// 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.',
},
},
Expand Down
30 changes: 29 additions & 1 deletion tests/imageListing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof vi.fn>
const mQueryOne = queryOne as unknown as ReturnType<typeof vi.fn>
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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)
}
})
})