Admin follow-ups: localised stats tab title, scanner names, close label, favicon hint

- Statistics view: the browser-tab title follows the admin language.
  Payload's custom-view meta.title is one plain string and its custom-view
  metadata ignores i18n, so the view renders <DocumentTitle> (/admin) with the
  translated title; it re-applies the title while the view is open because
  Next streams the English metadata in after hydration. adminDocumentTitle()
  adds admin.meta.titleSuffix the way Payload does.
- Cookie scanner: CookieIntegration.label may be { en, pl, ... }. The built-in
  names without a product name come from the shared admin texts
  (cookieIntegration*, cookieSourceProject); the scan endpoint answers in the
  request's admin language and stored source names use the scanning editor's.
- Maintenance notice: getConstructionMode(locale) returns `locale`; the "x"
  close button gets a screen-reader name "Close" / "Zamknij" (locale and
  closeLabel props; constructionCloseLabel exported).
- Favicon: FaviconCheck (/admin, afterInput on Site settings -> Site icon)
  warns in the admin language when the image is under 48x48 or not square,
  without blocking the save; validateFaviconField shares faviconProblems().
- Docs, AGENT.md and skills: the above, plus Next.js 16.4.1 or later as the
  minimum safe version (AGENT.md 4.11, ipal-setup, ipal-upgrade).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-10-27 16:31:46 +01:00
co-authored by Claude Opus 5.5
parent 6f32ea4cdb
commit 546806fe39
35 changed files with 428 additions and 70 deletions
+27
View File
@@ -0,0 +1,27 @@
'use client'
import { useEffect } from 'react'
/**
* Sets the browser-tab title of a custom admin view in the admin language.
*
* Payload takes a custom view's `meta.title` as one plain string and does not
* translate it, so the server-rendered title stays in English. The view
* renders this with its translated title (server side, from `req.i18n`) and
* the tab follows the editor's language once the page has loaded.
*
* On a full page load Next streams the view's metadata in after hydration and
* writes the English title back, so the title is re-applied whenever the head
* changes while the view is open.
*/
export function DocumentTitle({ title }: { title: string }) {
useEffect(() => {
const apply = () => {
if (document.title !== title) {document.title = title}
}
apply()
const observer = new MutationObserver(apply)
observer.observe(document.head, { characterData: true, childList: true, subtree: true })
return () => observer.disconnect()
}, [title])
return null
}
+1 -1
View File
@@ -1,6 +1,6 @@
// Client-safe: types, texts and helpers. The config transform (applyAdminI18n) lives in apply.ts.
export type { AdminLanguage, AdminText } from './define.js'
export { ADMIN_LANGUAGES, defineTexts } from './define.js'
export { formatDateTime, formatNumber, ipalT } from './t.js'
export { adminDocumentTitle, formatDateTime, formatNumber, ipalT } from './t.js'
export { adminTexts } from './texts/index.js'
export type { AdminTextKey } from './texts/index.js'
+3
View File
@@ -17,3 +17,6 @@ export const formatNumber = (n: number, language: string) => new Intl.NumberForm
/** Date and time in the admin language's format. */
export const formatDateTime = (iso: string, language: string, timeZone?: string) =>
new Intl.DateTimeFormat(language, { dateStyle: 'medium', timeStyle: 'short', ...(timeZone ? { timeZone } : {}) }).format(new Date(iso))
/** The tab title Payload builds for a view: its title plus `admin.meta.titleSuffix`. */
export const adminDocumentTitle = (title: string, titleSuffix?: null | string) => (titleSuffix ? `${title} ${titleSuffix}` : title)
+14 -2
View File
@@ -2,6 +2,18 @@ import { defineTexts } from '../define.js'
/** Admin component texts — consent. Placeholders use Payload's {{name}} syntax. */
export const consentTexts = defineTexts({
en: {},
pl: {},
en: {
cookieIntegrationAdmin: 'Admin panel login',
cookieIntegrationConsent: 'Cookie banner',
cookieIntegrationLocale: 'Language choice',
cookieIntegrationStats: 'Built-in statistics',
cookieSourceProject: 'Project',
},
pl: {
cookieIntegrationAdmin: 'Logowanie do panelu',
cookieIntegrationConsent: 'Baner cookies',
cookieIntegrationLocale: 'Wybór języka',
cookieIntegrationStats: 'Wbudowane statystyki',
cookieSourceProject: 'Projekt',
},
})
+4
View File
@@ -4,8 +4,12 @@ import { defineTexts } from '../define.js'
export const settingsTexts = defineTexts({
en: {
brandingCredit: 'Technology supported by Intecion.com',
faviconNotSquare: 'The icon is not square ({{width}}×{{height}} px), so it may be cropped in tabs and search results.',
faviconTooSmall: 'The icon is {{width}}×{{height}} px. Google shows icons of at least 48×48 px; upload a larger one.',
},
pl: {
brandingCredit: 'Technologię wspiera Intecion.com',
faviconNotSquare: 'Ikona nie jest kwadratowa ({{width}}×{{height}} px), więc może być przycięta na kartach i w wynikach wyszukiwania.',
faviconTooSmall: 'Ikona ma {{width}}×{{height}} px. Google pokazuje ikony od 48×48 px; wgraj większą.',
},
})
+7 -5
View File
@@ -1,9 +1,9 @@
import type { Endpoint, PayloadRequest } from 'payload'
import type { CookieScanContext, CookieScannerOptions } from './types.js'
import type { CookieIntegration, CookieScanContext, CookieScannerOptions } from './types.js'
import { userMeetsRole } from '../../access/predicates.js'
import { DEFAULT_COOKIE_INTEGRATIONS } from './integrations.js'
import { DEFAULT_COOKIE_INTEGRATIONS, integrationLabel } from './integrations.js'
import { cookieScanContext, enabledCookieIntegrations, parseCookieNames, runCookieScan } from './scan.js'
export const COOKIE_SCAN_PATH = '/ipal/cookie-scan'
@@ -18,14 +18,16 @@ export function buildCookieScanEndpoints(options: CookieScannerOptions, plugin:
const allowed = async (req: PayloadRequest) =>
options.access ? Boolean(await options.access({ req })) : userMeetsRole(req, 'editor')
const integrations = options.integrations ? options.integrations(DEFAULT_COOKIE_INTEGRATIONS) : DEFAULT_COOKIE_INTEGRATIONS
const list = (items: { key: string; label: string }[]) => items.map(({ key, label }) => ({ key, label }))
// Names in the admin language of the editor who asks.
const list = (items: CookieIntegration[], req: PayloadRequest) =>
items.map((i) => ({ key: i.key, label: integrationLabel(i, req.i18n?.language) }))
return [
{
handler: async (req) => {
if (!(await allowed(req))) {return Response.json({ ok: false }, { status: 403 })}
const enabled = await enabledCookieIntegrations(integrations, await cookieScanContext(req.payload, plugin, req))
return Response.json({ integrations: list(enabled), ok: true })
return Response.json({ integrations: list(enabled, req), ok: true })
},
method: 'get',
path: COOKIE_SCAN_PATH,
@@ -41,7 +43,7 @@ export function buildCookieScanEndpoints(options: CookieScannerOptions, plugin:
}
try {
const { enabled, summary } = await runCookieScan({ names: parseCookieNames(body.names), options, payload: req.payload, plugin, req })
return Response.json({ integrations: list(enabled), ok: true, summary })
return Response.json({ integrations: list(enabled, req), ok: true, summary })
} catch (err) {
req.payload.logger.error(`[ipal] cookie scan failed: ${err instanceof Error ? err.message : String(err)}`)
return Response.json({ ok: false }, { status: 500 })
+17 -4
View File
@@ -1,9 +1,12 @@
import type { AdminTextKey } from '../../admin-i18n/texts/index.js'
import type { CookieDeclaration, CookieIntegration, CookieScanContext } from './types.js'
import { adminTexts } from '../../admin-i18n/texts/index.js'
import { validAnalyticsId } from '../../analytics/idFormats.js'
import { LOCALE_COOKIE_NAME } from '../../i18n/negotiateLocale.js'
import { getTurnstileConfig } from '../../turnstile/config.js'
import { CONSENT_COOKIE } from '../storage.js'
import { textFor } from './merge.js'
/** A tag ID from Site Integrations is filled in and valid. */
const hasId = (field: string) => (ctx: CookieScanContext) =>
@@ -16,6 +19,11 @@ const months = (n: number) => T(`${n} months`, `${n} mies.`)
const YEAR = T('1 year', '1 rok')
const TWO_YEARS = T('2 years', '2 lata')
const SITE = 'This site'
/** A name from the shared admin texts, in every admin language the plugin ships. */
const A = (key: AdminTextKey) => ({ en: adminTexts.en[key], pl: adminTexts.pl[key] })
/** Source name of the project's own `cookieScanner.declarations`. */
export const PROJECT_SOURCE = A('cookieSourceProject')
/**
* Cookies of everything the plugin itself injects — one place per integration.
@@ -37,7 +45,7 @@ export const DEFAULT_COOKIE_INTEGRATIONS: CookieIntegration[] = [
],
isEnabled: () => true,
key: 'consent',
label: 'Cookie banner',
label: A('cookieIntegrationConsent'),
},
{
declarations: (ctx) => [
@@ -52,7 +60,7 @@ export const DEFAULT_COOKIE_INTEGRATIONS: CookieIntegration[] = [
],
isEnabled: () => true,
key: 'admin',
label: 'Admin panel login',
label: A('cookieIntegrationAdmin'),
},
{
declarations: [
@@ -67,7 +75,7 @@ export const DEFAULT_COOKIE_INTEGRATIONS: CookieIntegration[] = [
],
isEnabled: (ctx) => ctx.plugin.localeCount > 1,
key: 'locale',
label: 'Language choice',
label: A('cookieIntegrationLocale'),
},
{
declarations: [
@@ -85,7 +93,7 @@ export const DEFAULT_COOKIE_INTEGRATIONS: CookieIntegration[] = [
],
isEnabled: (ctx) => ctx.plugin.stats,
key: 'stats',
label: 'Built-in statistics',
label: A('cookieIntegrationStats'),
},
{
declarations: [
@@ -281,6 +289,11 @@ export const DEFAULT_COOKIE_INTEGRATIONS: CookieIntegration[] = [
},
]
/** An integration's name in one admin language (English when that language is missing). */
export function integrationLabel(integration: Pick<CookieIntegration, 'label'>, language = 'en'): string {
return textFor(integration.label, language) ?? ''
}
/** An integration's declarations for this project. */
export function declarationsOf(integration: CookieIntegration, ctx: CookieScanContext): CookieDeclaration[] {
return typeof integration.declarations === 'function' ? integration.declarations(ctx) : integration.declarations
+10 -6
View File
@@ -13,7 +13,7 @@ import type {
import { COOKIE_REVIEW_SLUG } from './collection.js'
import { loadCookieDatabase, lookupCookie } from './cookieDatabase.js'
import { cookieNameMatches, declarationsOf, DEFAULT_COOKIE_INTEGRATIONS } from './integrations.js'
import { cookieNameMatches, declarationsOf, DEFAULT_COOKIE_INTEGRATIONS, integrationLabel, PROJECT_SOURCE } from './integrations.js'
import { mergeCookieReview, suggestionFor } from './merge.js'
/** Most names one scan looks up — the panel field is for a handful, not a dump. */
@@ -102,14 +102,18 @@ export async function collectCookieFindings({
if (!found.has(key)) {found.set(key, f)}
return key
}
for (const d of declarations) {add(fromDeclaration(d, 'project', 'Project'))}
// Source names are stored in the admin language of whoever runs the scan.
const project = integrationLabel({ label: PROJECT_SOURCE }, ctx.language)
for (const d of declarations) {add(fromDeclaration(d, 'project', project))}
for (const integration of enabled) {
for (const d of declarationsOf(integration, ctx)) {add(fromDeclaration(d, 'integration', integration.label))}
for (const d of declarationsOf(integration, ctx)) {add(fromDeclaration(d, 'integration', integrationLabel(integration, ctx.language)))}
}
const known = [
...declarations.map((d) => ({ d, detail: 'Project', source: 'project' as const })),
...integrations.flatMap((i) => declarationsOf(i, ctx).map((d) => ({ d, detail: i.label, source: 'integration' as const }))),
...declarations.map((d) => ({ d, detail: project, source: 'project' as const })),
...integrations.flatMap((i) =>
declarationsOf(i, ctx).map((d) => ({ d, detail: integrationLabel(i, ctx.language), source: 'integration' as const })),
),
]
const index = database ? await loadCookieDatabase() : null
for (const raw of names) {
@@ -247,7 +251,7 @@ export async function cookieScanContext(
} catch {
// No such global (project replaced it) — integrations keyed on its IDs count as off.
}
return { integrations, payload, plugin }
return { integrations, language: req?.i18n?.language ?? 'en', payload, plugin }
}
/**
+4 -2
View File
@@ -34,6 +34,8 @@ export type CookieDeclaration = {
export type CookieScanContext = {
/** SiteIntegrations (depth 0); `{}` when it can't be read. */
integrations: Record<string, unknown>
/** Admin language of the request (`req.i18n.language`); names stored by a scan use it. Default `'en'`. */
language?: string
payload: BasePayload
/** Plugin options that switch modules on. */
plugin: { localeCount: number; stats: boolean }
@@ -50,8 +52,8 @@ export type CookieIntegration = {
isEnabled: (ctx: CookieScanContext) => boolean | Promise<boolean>
/** Stable id, e.g. `ga4`. */
key: string
/** Shown in the panel, e.g. `Google Analytics 4`. */
label: string
/** Shown in the panel, e.g. `Google Analytics 4`, or per admin language: `{ en: 'Chat', pl: 'Czat' }`. */
label: LocalizedText
}
/** Where a review entry's suggestion came from. `manual` = added by hand in the panel. */
@@ -5,6 +5,7 @@ import { useCallback, useEffect, useId, useRef, useState } from 'react'
import type { ConstructionMode } from './types.js'
import { isPathAllowed } from './logic.js'
import { constructionCloseLabel } from './texts.js'
import { CONSTRUCTION_NOTICE_PARAM, CONSTRUCTION_NOTICE_VALUE } from './types.js'
export type ConstructionNoticeClassNames = {
@@ -22,12 +23,26 @@ export type ConstructionNoticeClassNames = {
* available — the click is cancelled. Closes with its button or Escape.
* Renders nothing while the mode is off.
*
* Unstyled (classNames, like CookieBanner); texts come from the panel.
* Unstyled (classNames, like CookieBanner); texts come from the panel. With no
* button text set, the button shows "×" and gets a screen-reader name in the
* page language ("Close" / "Zamknij"): `locale`, else `mode.locale`.
*
* // [locale]/layout.tsx
* <ConstructionNotice mode={await getConstructionMode(locale)} classNames={{ overlay: '…', dialog: '…' }} />
*/
export function ConstructionNotice({ classNames: cn = {}, mode }: { classNames?: ConstructionNoticeClassNames; mode: ConstructionMode }) {
export function ConstructionNotice({
classNames: cn = {},
closeLabel,
locale,
mode,
}: {
classNames?: ConstructionNoticeClassNames
/** Screen-reader name of the "×" button. Default: "Close" / "Zamknij" by page language. */
closeLabel?: string
/** Page language. Default: `mode.locale` (set by getConstructionMode). */
locale?: string
mode: ConstructionMode
}) {
const [open, setOpen] = useState(false)
const buttonRef = useRef<HTMLButtonElement>(null)
const titleId = useId()
@@ -76,7 +91,13 @@ export function ConstructionNotice({ classNames: cn = {}, mode }: { classNames?:
<div aria-labelledby={mode.texts.title ? titleId : undefined} aria-modal="true" className={cn.dialog} role="dialog">
{mode.texts.title ? <p className={cn.title} id={titleId}>{mode.texts.title}</p> : null}
{mode.texts.message ? <p className={cn.message}>{mode.texts.message}</p> : null}
<button className={cn.button} onClick={close} ref={buttonRef} type="button">
<button
aria-label={mode.texts.button ? undefined : (closeLabel ?? constructionCloseLabel(locale ?? mode.locale))}
className={cn.button}
onClick={close}
ref={buttonRef}
type="button"
>
{mode.texts.button ?? '×'}
</button>
</div>
+7
View File
@@ -0,0 +1,7 @@
/** Screen-reader name of the notice's close button when the panel sets no button text ("×" is shown). */
export const CONSTRUCTION_CLOSE_LABEL = 'Close'
export const CONSTRUCTION_CLOSE_LABEL_PL = 'Zamknij'
/** Close label for a page language: Polish for 'pl' / 'pl-PL', English for anything else. */
export const constructionCloseLabel = (locale?: string): string =>
locale?.toLowerCase().startsWith('pl') ? CONSTRUCTION_CLOSE_LABEL_PL : CONSTRUCTION_CLOSE_LABEL
+2
View File
@@ -8,6 +8,8 @@ export type ConstructionMode = {
enabled: boolean
/** Homepage in the current language — blocked addresses redirect here (with the notice). */
homePath: string
/** Page language the mode was read for (getConstructionMode(locale)); picks the notice's default texts. */
locale?: string
/** Notice texts from the panel, in the current language. Empty = not set. */
texts: { button?: string; message?: string; title?: string }
}
+2 -1
View File
@@ -735,7 +735,7 @@ export function createContentHelpers({
const rootOf = (code: string) => (options.config.locales.length > 1 ? `/${code}` : '/')
const homePath = resolveLinkRaw({ type: 'internal', page: settings?.homepage }, options)?.href ?? rootOf(locale)
const construction = (settings?.construction ?? {}) as { buttonLabel?: unknown; enabled?: unknown; message?: unknown; title?: unknown }
if (construction.enabled !== true) {return { allowedPaths: [], enabled: false, homePath, texts: {} }}
if (construction.enabled !== true) {return { allowedPaths: [], enabled: false, homePath, locale, texts: {} }}
const configured = await getConfiguredLocales()
const paths = await Promise.all(
@@ -753,6 +753,7 @@ export function createContentHelpers({
allowedPaths: [...new Set(paths.flat().filter((path): path is string => typeof path === 'string'))],
enabled: true,
homePath,
locale,
texts: Object.fromEntries(Object.entries(texts).filter(([, value]) => value)),
}
})
+78
View File
@@ -0,0 +1,78 @@
'use client'
import { useConfig, useFormFields, useTranslation } from '@payloadcms/ui'
import { useEffect, useState } from 'react'
import { ipalT } from '../admin-i18n/t.js'
import { faviconProblems } from './faviconProblems.js'
export type FaviconCheckProps = {
/** Upload field holding the icon. Default: the field this sits under, else 'favicon'. */
fieldPath?: string
/** Upload collection of the icon. Default 'media'. */
mediaSlug?: string
/** Set by Payload for a field component. */
path?: string
}
const id = (value: unknown) =>
typeof value === 'object' && value !== null ? (value as { id?: number | string }).id : (value as number | string | undefined)
/**
* Hint under the site icon in Site settings: Google shows a favicon only when it
* is at least 48×48 px, and a non-square one gets cropped. Reads the chosen
* image's size and warns; saving is never blocked. SVG icons pass.
*/
export function FaviconCheck({ fieldPath, mediaSlug = 'media', path }: FaviconCheckProps) {
const value = useFormFields(([f]) => f[fieldPath ?? path ?? 'favicon']?.value)
const mediaId = id(value)
const {
config: {
routes: { api },
serverURL,
},
} = useConfig()
const { t } = useTranslation()
const [problems, setProblems] = useState<string[]>([])
useEffect(() => {
if (mediaId === undefined || mediaId === null || mediaId === '') {
setProblems([])
return
}
const controller = new AbortController()
void (async () => {
try {
const res = await fetch(`${serverURL ?? ''}${api}/${mediaSlug}/${encodeURIComponent(String(mediaId))}?depth=0`, {
credentials: 'include',
signal: controller.signal,
})
const media = res.ok ? ((await res.json()) as { height?: number; mimeType?: string; width?: number }) : null
const found = media ? faviconProblems(media) : []
setProblems(found.map((p) => ipalT(t, p.key, { height: p.height, width: p.width })))
} catch {
// aborted or offline — a hint is not worth an error
}
})()
return () => controller.abort()
}, [api, mediaId, mediaSlug, serverURL, t])
if (!problems.length) {return null}
return (
<div
role="status"
style={{
background: 'var(--theme-warning-50, rgba(255, 178, 36, 0.1))',
border: '1px solid var(--theme-warning-400, #ffb224)',
borderRadius: 4,
fontSize: '0.85rem',
marginTop: '0.5rem',
padding: '0.6rem 0.9rem',
}}
>
{problems.map((text) => (
<p key={text} style={{ margin: 0 }}>{text}</p>
))}
</div>
)
}
+17
View File
@@ -0,0 +1,17 @@
/** Smallest favicon Google shows in search results. */
export const FAVICON_MIN_SIZE = 48
export type FaviconProblem = { height: number; key: 'faviconNotSquare' | 'faviconTooSmall'; width: number }
/**
* What is wrong with a favicon for Google: under 48×48 px, or not square.
* SVG scales, and an image without known dimensions is not judged.
*/
export function faviconProblems(media: { height?: null | number; mimeType?: null | string; width?: null | number }): FaviconProblem[] {
const { height, mimeType, width } = media
if (mimeType === 'image/svg+xml' || typeof width !== 'number' || typeof height !== 'number') {return []}
const out: FaviconProblem[] = []
if (width < FAVICON_MIN_SIZE || height < FAVICON_MIN_SIZE) {out.push({ height, key: 'faviconTooSmall', width })}
if (width !== height) {out.push({ height, key: 'faviconNotSquare', width })}
return out
}
+2
View File
@@ -28,6 +28,8 @@ export { composeTitle } from './composeTitle.js'
export type { TitleOrder } from './composeTitle.js'
export { createMetadataGenerator } from './createMetadataGenerator.js'
export { createPageMetadata } from './createPageMetadata.js'
export { FAVICON_MIN_SIZE, faviconProblems } from './faviconProblems.js'
export type { FaviconProblem } from './faviconProblems.js'
export { formatOpeningHours } from './formatOpeningHours.js'
export { buildHreflangAlternates } from './hreflang.js'
export {
+13 -27
View File
@@ -1,14 +1,14 @@
import type { FieldHook } from 'payload'
import { faviconProblems } from './faviconProblems.js'
/**
* Field validation for the favicon upload: Google rejects favicons under 48×48,
* so warn the editor at save time if the uploaded icon is too small or not
* square. This ENFORCES the requirement instead of silently shipping a favicon
* Google won't display.
* Server-side check of the favicon upload: Google rejects favicons under 48×48,
* and a non-square icon gets cropped. Logs a warning on save; it never blocks
* the save. Editors see the same check under the field (`FaviconCheck`, /admin).
*
* Attach to the favicon field's validate (or as a beforeValidate hook on the
* Media relationship). Non-blocking by default — returns a warning string that
* Payload surfaces; make it throw if you want a hard block.
* Attach as a beforeValidate hook on your own favicon field; the plugin wires it
* on Site settings itself.
*
* Note: dimensions come from the related Media doc (Payload stores width/height
* for image uploads), so this checks the resolved upload, not the raw file.
@@ -23,26 +23,12 @@ export const validateFaviconField: FieldHook = async ({ req, value }) => {
depth: 0,
})
const width = (media as { width?: number }).width
const height = (media as { height?: number }).height
const mimeType = (media as { mimeType?: string }).mimeType
// SVG scales infinitely — skip size checks.
if (mimeType === 'image/svg+xml') {return value}
if (typeof width === 'number' && typeof height === 'number') {
if (width < 48 || height < 48) {
req.payload.logger.warn(
`[ipal] Favicon is ${width}×${height}px. Google requires ≥48×48 to ` +
`display it in search results. Upload a larger square icon (96 or 192px).`,
)
}
if (width !== height) {
req.payload.logger.warn(
`[ipal] Favicon is not square (${width}×${height}). Use a square icon ` +
`so it isn't cropped in the browser tab or search results.`,
)
}
for (const { height, key, width } of faviconProblems(media as { height?: number; mimeType?: string; width?: number })) {
req.payload.logger.warn(
key === 'faviconTooSmall'
? `[ipal] Favicon is ${width}×${height}px. Google requires ≥48×48 to display it in search results. Upload a larger square icon (96 or 192px).`
: `[ipal] Favicon is not square (${width}×${height}). Use a square icon so it isn't cropped in the browser tab or search results.`,
)
}
} catch {
// Media lookup failed — don't block the save over a validation warning.
+4 -1
View File
@@ -5,7 +5,8 @@ import { Gutter } from '@payloadcms/ui'
import type { StatsVisit } from '../collection.js'
import { formatDateTime } from '../../admin-i18n/t.js'
import { DocumentTitle } from '../../admin-i18n/DocumentTitle.js'
import { adminDocumentTitle, formatDateTime } from '../../admin-i18n/t.js'
import { VISITOR_ID_PATTERN } from '../parse.js'
import { canReadStats } from './canReadStats.js'
import { loadRecentVisitors, loadStats, loadVisitor } from './loadStats.js'
@@ -174,6 +175,8 @@ export async function StatsView(props: Props) {
<Gutter>
<div className="ipal-stats" style={{ paddingBottom: '3rem' }}>
<style>{STATS_CSS}</style>
{/* meta.title in the view config is plain English text; this puts the tab title in the admin language */}
<DocumentTitle title={adminDocumentTitle(tr(i18n, 'statsTitle'), req.payload.config.admin?.meta?.titleSuffix)} />
{content}
</div>
</Gutter>