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
10 changes: 4 additions & 6 deletions app/[lang]/(site)/report/ReportClient.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use client'

import { useState } from 'react'
import { useSearchParams } from 'next/navigation'
import { CircleNotch as Loader2, WarningCircle } from '@/components/icons'

import { useLang } from '@/components/i18n/LangProvider'
Expand All @@ -22,15 +21,14 @@ import { LegalFormShell, Field, FormCard, INPUT_CLASS, TEXTAREA_CLASS } from '@/

interface Done { title: string; text: string }

export function ReportClient() {
export function ReportClient({ initialUrl }: { initialUrl: string }) {
const { lang } = useLang()
const params = useSearchParams()
const t = legalFormTranslations[lang]
const tl = layoutTranslations[lang]

// Derived initial value instead of `setState` in an effect: the
// query parameter is already fixed on the first render.
const [contentUrl, setContentUrl] = useState(() => params.get('url') ?? '')
// Initial value from the server, which read `?url=`: no `setState` in an
// effect, and no client-only render that pushed the heading behind the footer.
const [contentUrl, setContentUrl] = useState(initialUrl)
const [reason, setReason] = useState('')
const [name, setName] = useState('')
const [email, setEmail] = useState('')
Expand Down
19 changes: 9 additions & 10 deletions app/[lang]/(site)/report/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import type { Metadata } from 'next'
import { Suspense } from 'react'

import { alternatesFor } from '@/lib/seo'
import { pageSeo } from '@/lib/pageSeo'
import { getRequestLang } from '@/lib/serverLang'
Expand All @@ -16,12 +14,13 @@ export async function generateMetadata(): Promise<Metadata> {
}
}

export default function ReportPage() {
// `useSearchParams` (the prefilled URL) needs a Suspense boundary,
// otherwise Next refuses to build the page.
return (
<Suspense>
<ReportClient />
</Suspense>
)
type Search = Promise<{ url?: string | string[] }>

export default async function ReportPage({ searchParams }: { searchParams: Search }) {
// The prefilled URL is read here, on the server. Until 24.11.2026 the form
// read it with `useSearchParams` behind a Suspense boundary, so the server
// sent the footer first and streamed the heading and the form in after it:
// the page's h1 came after four h2 in the HTML.
const { url } = await searchParams
return <ReportClient initialUrl={typeof url === 'string' ? url : ''} />
}
6 changes: 2 additions & 4 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, listCategories } from '@/lib/images'
import { getImage, getNeighbours, imageTitle, listCategories } from '@/lib/images'
import { absoluteUrl } from '@/lib/siteUrl'
import { publicPath } from '@/lib/routes'

Expand All @@ -33,9 +33,7 @@ export async function generateMetadata({ params }: { params: Params }): Promise<
if (!image) return {}

const display = image.label || image.name
const title = lang === 'de'
? `${display} Bild, freigestellt (PNG)`
: `${display} image, transparent PNG`
const title = imageTitle(image, lang)
const description = lang === 'de'
? `Freigestelltes ${display}-Bild aus GTA V, ${image.width} mal ${image.height} Pixel, kostenlos für FiveM-Scripts. Direkt über die CDN-URL nutzbar.`
: `Transparent ${display} image from GTA V, ${image.width} by ${image.height} pixels, free for FiveM scripts. Use the CDN URL directly.`
Expand Down
43 changes: 36 additions & 7 deletions app/[lang]/(site)/tools/images/[category]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,20 @@ export async function generateMetadata({ params }: { params: Params }): Promise<
? `Logos, banners and brand graphics by MSK Scripts. Original works, free to use where they refer to MSK Scripts, not as your own logo.`
: `${category.count} transparent GTA V ${category.name.toLowerCase()} images, named by spawn name. Free for FiveM scripts, served from our CDN.`

// A category without a published image is a page with nothing on it. It
// stays reachable, so a link to it does not break, but it stays out of the
// index, with a description that does not start with "0 images".
if (category.count === 0) {
return {
title,
description: lang === 'de'
? `In dieser Kategorie ist noch kein Bild veröffentlicht. Die anderen Kategorien der Bildergalerie sind frei für FiveM-Scripts nutzbar.`
: `No image has been published in this category yet. The other categories of the image gallery are free to use in FiveM scripts.`,
robots: { index: false, follow: true },
alternates: alternatesFor(lang, `/tools/images/${slug}`),
}
}

return { title, description, alternates: alternatesFor(lang, `/tools/images/${slug}`) }
}

Expand All @@ -59,9 +73,13 @@ export default async function CategoryPage(
const category = await findCategory(slug, lang)
if (!category) notFound()

const page = Math.max(1, Number(rawPage) || 1)
const page = Math.max(1, Math.floor(Number(rawPage)) || 1)
const result = await listImages({ category: slug, q, page, per: DEFAULT_PER_PAGE })
const pages = Math.max(1, Math.ceil(result.total / result.per))
// A page past the end answers 404. Until 24.11.2026 it answered 200 with a
// "Next" link, and a crawler followed that to page 2725 in every category
// and language, more than 21,000 addresses.
if (page > pages) notFound()

const num = (n: number) => new Intl.NumberFormat(lang === 'de' ? 'de-DE' : 'en-US').format(n)

Expand Down Expand Up @@ -131,15 +149,26 @@ export default async function CategoryPage(

{pages > 1 && (
<nav className="mt-10 flex items-center justify-center gap-4" aria-label="Pagination">
<Button asChild variant="outline" size="sm" disabled={page <= 1}>
<Link href={hrefFor(page - 1)} aria-disabled={page <= 1}>{t.page_prev}</Link>
</Button>
{/* At either end the button is disabled and has no href.
`disabled` on an `asChild` link only greyed it out, and the
href still pointed one page past the end. */}
{page > 1 ? (
<Button asChild variant="outline" size="sm">
<Link href={hrefFor(page - 1)}>{t.page_prev}</Link>
</Button>
) : (
<Button variant="outline" size="sm" disabled>{t.page_prev}</Button>
)}
<span className="font-mono text-xs text-[var(--color-muted-foreground)]">
{t.page_of.replace('{page}', num(page)).replace('{pages}', num(pages))}
</span>
<Button asChild variant="outline" size="sm" disabled={page >= pages}>
<Link href={hrefFor(page + 1)} aria-disabled={page >= pages}>{t.page_next}</Link>
</Button>
{page < pages ? (
<Button asChild variant="outline" size="sm">
<Link href={hrefFor(page + 1)}>{t.page_next}</Link>
</Button>
) : (
<Button variant="outline" size="sm" disabled>{t.page_next}</Button>
)}
</nav>
)}
</section>
Expand Down
15 changes: 13 additions & 2 deletions app/robots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,23 @@ const BLOCKED = [
'/discord/giveaway-bot/g/',
]

/**
* Pages whose query variants are blocked, not the page itself. The report
* form is linked from every image with its own `?url=` (8,478 addresses in the
* crawl of 24.11.2026), all with `/report` as canonical. The form itself stays
* crawlable, `Disallow: /en/report?` only matches addresses with a query.
*/
const QUERY_BLOCKED = ['/report']

export default function robots(): MetadataRoute.Robots {
// What exists only once (API, Auth, Botproxy) gets no prefixed line: under
// `/en/` and `/de/` it is a 404, and blocking an address that does not exist
// is just noise in a file that someone is supposed to be able to read.
const disallow = BLOCKED.flatMap(p =>
isExemptPath(p.replace(/\/$/, '')) ? [p] : LANGS.map(lang => publicPath(lang, p)))
const disallow = [
...BLOCKED.flatMap(p =>
isExemptPath(p.replace(/\/$/, '')) ? [p] : LANGS.map(lang => publicPath(lang, p))),
...QUERY_BLOCKED.flatMap(p => LANGS.map(lang => `${publicPath(lang, p)}?`)),
]

return {
rules: [
Expand Down
7 changes: 1 addition & 6 deletions components/layout/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -210,14 +210,9 @@ export function Footer() {
<p className="flex flex-wrap items-center gap-x-2 gap-y-1 border-t border-[var(--color-band-line)] pt-6 text-small text-[var(--color-band-muted)]">
<span>© {new Date().getFullYear()} MSK Scripts. {t.footer_rights}</span>
<span aria-hidden="true">·</span>
<span>
{t.footer_powered_by}{' '}
<a href="https://tebex.io" target="_blank" rel="noopener noreferrer" className="underline-offset-4 hover:text-[var(--color-band-foreground)] hover:underline">Tebex</a>
</span>
<span aria-hidden="true">·</span>
<span>
{t.footer_built_by}{' '}
<a href="https://www.musiker15.de" target="_blank" rel="noopener noreferrer" className="underline-offset-4 hover:text-[var(--color-band-foreground)] hover:underline">Musiker15</a>
<a href={`https://www.musiker15.de/${lang}`} target="_blank" rel="noopener noreferrer" className="underline-offset-4 hover:text-[var(--color-band-foreground)] hover:underline">Musiker15</a>
</span>
<span aria-hidden="true">·</span>
<a href={SITE_CONFIG.github} target="_blank" rel="noopener noreferrer" className="inline-flex min-h-11 items-center gap-1.5 underline-offset-4 hover:text-[var(--color-band-foreground)] hover:underline">
Expand Down
5 changes: 5 additions & 0 deletions components/legal/ReportLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ export function ReportLink({ path, className }: { path: string; className?: stri
return (
<Link
href={`/report?url=${encodeURIComponent(absoluteUrl(localize(path)))}`}
// Every image page carries this link with its own `?url=`, which made
// 8,478 form addresses for a crawler. They all name `/report` as their
// canonical; `nofollow` here and the `?` line in robots.txt keep a
// crawler from fetching each of them first.
rel="nofollow"
className={
className
?? 'tap-target inline-flex items-center gap-1.5 text-xs text-[var(--color-muted-foreground)] '
Expand Down
2 changes: 1 addition & 1 deletion lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { Lang } from '@/lib/i18n'
export const SITE_CONFIG = {
name: 'MSK Scripts Shop',
tagline: 'High quality FiveM resources & Discord bots for your server',
discord: 'https://discord.gg/5hHSBRHvJE',
discord: 'https://discord.com/invite/5hHSBRHvJE',
github: 'https://github.com/MSK-Scripts',
docs: 'https://docu.msk-scripts.de',
/** The contact address from the imprint. */
Expand Down
2 changes: 0 additions & 2 deletions lib/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2793,7 +2793,6 @@ export const layoutTranslations = {
footer_discord: 'Discord support',
footer_statistics: 'Statistics',
footer_rights: 'All rights reserved.',
footer_powered_by: 'Powered by',
footer_built_by: 'Built by',
// Trust line above the copyright. Every claim is backed by the T&C:
// § 2 (Tebex as merchant of record, refunds via Tebex), § 3
Expand Down Expand Up @@ -2880,7 +2879,6 @@ export const layoutTranslations = {
footer_discord: 'Discord-Support',
footer_statistics: 'Statistiken',
footer_rights: 'Alle Rechte vorbehalten.',
footer_powered_by: 'Bereitgestellt über',
footer_built_by: 'Erstellt von',
footer_trust_checkout: 'Checkout und Zahlung wickelt Tebex Limited als Merchant of Record ab.',
footer_trust_license: 'Lizenz für einen Server',
Expand Down
36 changes: 33 additions & 3 deletions lib/images.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,12 @@ export async function listImages(opts: ListOptions): Promise<ImageListResult> {
const total = Number(totalRow?.total ?? 0)

// LIMIT and OFFSET are inline, because mysql2 does not allow placeholders
// there. Both are forced above, by Math.floor and the caps above, into
// integers within known bounds, so no user value goes into the SQL
// unchecked.
// there. `per` is capped above; the page has no upper cap of its own, so a
// page past the last row stops here and never reaches the SQL. Without this
// `?page=1e300` (or `Infinity`) became `OFFSET 6e+301`, a syntax error and a
// 500, and every page past the end still cost a query.
const offset = (page - 1) * per
if (offset >= total) return { total, page, per, items: [] }

const rows = await query<ImageRow>(
`SELECT i.category, i.name, i.label, i.ext, i.width, i.height, i.bytes, i.version, i.tags
Expand All @@ -239,6 +241,34 @@ export async function listImages(opts: ListOptions): Promise<ImageListResult> {
return { total, page, per, items: rows.map(toRecord) }
}

/**
* Longest title body that, with " | MSK Scripts" from the layout template,
* stays inside the 580 px a search result shows.
*/
export const IMAGE_TITLE_MAX = 46

/**
* Title of an image page. The spawn name goes in next to the label, because
* labels repeat: "Trailer" stood on 16 vehicle pages, "Sou Cent" on 14, all
* with the same title (crawl of 24.11.2026). Long labels drop the wording
* step by step instead of running past what a search result shows.
*/
export function imageTitle(image: Pick<ImageRecord, 'name' | 'label' | 'ext'>, lang: Lang): string {
const label = image.label?.trim()
const named = label && label.toLowerCase() !== image.name.toLowerCase()
? `${label} (${image.name})`
: image.name
// The format comes from the stored file, so a JPEG in `brand` is not
// called a PNG. "transparent" only goes with a PNG.
const format = (image.ext || 'png').toUpperCase()
const isPng = format === 'PNG'
const full = lang === 'de'
? (isPng ? `${named}, freigestelltes PNG` : `${named}, ${format}`)
: (isPng ? `${named}, transparent PNG` : `${named}, ${format}`)
const candidates = [full, `${named} ${format}`, `${image.name} ${format}`]
return candidates.find(c => c.length <= IMAGE_TITLE_MAX) ?? image.name
}

export async function getImage(category: string, name: string): Promise<ImageRecord | null> {
const row = await queryOne<ImageRow>(
`SELECT category, name, label, ext, width, height, bytes, version, tags
Expand Down
18 changes: 9 additions & 9 deletions lib/pageSeo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,34 +102,34 @@ export const PAGE_SEO: Record<string, Record<Lang, PageSeo>> = {
'/discord/ticket-bot/stats': {
en: {
title: 'Bot Statistics',
description: 'Anonymous live statistics of the MSK Ticket Bot across all servers.',
description: 'Anonymous live statistics of the MSK Ticket Bot across all Discord servers. No server IDs, usernames or other personal data are shown.',
},
de: {
title: 'Ticket-Bot-Statistiken',
description: 'Anonyme Live-Zahlen des MSK Ticket Bots über alle Server hinweg.',
description: 'Anonyme Live-Zahlen des MSK Ticket Bots über alle Discord-Server hinweg. Server-IDs, Nutzernamen und andere personenbezogene Daten zeigt die Seite nicht.',
},
},
'/discord/giveaway-bot/stats': {
en: {
title: 'Giveaway Bot Statistics',
description: 'Anonymous live statistics of the MSK Giveaway Bot across all Discord servers.',
description: 'Anonymous live statistics of the MSK Giveaway Bot across all Discord servers. No server IDs, usernames or other personal data are shown.',
},
de: {
title: 'Giveaway-Bot-Statistiken',
description: 'Anonyme Live-Zahlen des MSK Giveaway Bots über alle Discord-Server hinweg.',
description: 'Anonyme Live-Zahlen des MSK Giveaway Bots über alle Discord-Server hinweg. Server-IDs, Nutzernamen und andere personenbezogene Daten zeigt die Seite nicht.',
},
},
'/legal/terms': {
en: { title: 'Terms & Conditions', description: 'Terms and conditions for buying and using MSK Scripts resources.' },
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.' },
},
'/legal/imprint': {
en: { title: 'Imprint', description: 'Legal notice and contact details for MSK Scripts, Moritz Kohm.' },
de: { title: 'Impressum', description: 'Anbieterkennzeichnung und Kontaktdaten von MSK Scripts, Moritz Kohm.' },
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.' },
},
'/legal/privacy': {
en: { title: 'Privacy Policy', description: 'How MSK Scripts handles personal data, in line with the GDPR.' },
de: { title: 'Datenschutzerklärung', description: 'Wie MSK Scripts mit personenbezogenen Daten umgeht, nach den Vorgaben der DSGVO.' },
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.' },
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': {
en: {
Expand Down
2 changes: 1 addition & 1 deletion tests/aboutFigures.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('aboutFigures', () => {
expect(figures.map(f => f.label)).toEqual(['Mitglieder im Discord', 'Server auf msk_core', 'Doku-Seiten'])
const discord = byLabel(figures, 'Discord')
expect(discord?.value).toBe('1.627')
expect(discord?.href).toBe('https://discord.gg/5hHSBRHvJE')
expect(discord?.href).toBe('https://discord.com/invite/5hHSBRHvJE')
expect(discord?.external).toBe(true)
expect(byLabel(aboutFigures('en', 1627, 262, 252), 'Discord')?.value).toBe('1,627')
})
Expand Down
Loading