Admin link previews: site name, description, preview image, noindex; technology support credit
- adminMeta (default on, with or without whiteLabel): robots noindex/nofollow, title suffix "— <site> | Panel", og:site_name and en/pl description from Site settings, preview image GET /api/ipal/admin-og (next/og, from the logo or name, no external service) and icon GET /api/ipal/admin-icon - the site name sits in a process-wide store read through getters, so link previews stay current after a Site settings save and across config loads - agency option (default Intecion.com) feeds the credit, description and image; credit reads "Technology support: Intecion.com" (pl: Wsparcie technologiczne) - the project's own admin.meta keys always win; adminMeta: false / agency: false - dev: whiteLabel on; docs: white-label.md, AGENT.md, ipal-reference/setup/upgrade Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
6998b44431
commit
3c828d963d
+61
-4
@@ -1,5 +1,6 @@
|
||||
import type { Config, Plugin } from 'payload'
|
||||
|
||||
import type { ResolvedAdminMeta } from './modules/branding/adminMeta.js'
|
||||
import type { IpalOptions, TotpPluginFactory } from './types.js'
|
||||
|
||||
import { buildCookieSettings } from './globals/CookieSettings/index.js'
|
||||
@@ -10,6 +11,8 @@ import { buildSiteIntegrations } from './globals/SiteIntegrations/index.js'
|
||||
import { buildSiteSettings } from './globals/SiteSettings/index.js'
|
||||
import { adminOnly, adminOrSelf, injectRoles } from './modules/access/index.js'
|
||||
import { applyAdminI18n } from './modules/admin-i18n/apply.js'
|
||||
import { buildAdminImageEndpoints } from './modules/branding/adminImages.js'
|
||||
import { buildAdminMeta, DEFAULT_AGENCY, syncAdminMeta } from './modules/branding/adminMeta.js'
|
||||
import { buildConsentLogCollection, buildConsentLogEndpoint } from './modules/consent/consentLog.js'
|
||||
import { addCookieScannerTabs } from './modules/consent/scanner/adminTabs.js'
|
||||
import { buildCookieApprovalEndpoints, COOKIE_APPROVAL_VIEW_PATH } from './modules/consent/scanner/approval.js'
|
||||
@@ -222,6 +225,8 @@ export const ipalKit = (options: IpalOptions): Plugin => {
|
||||
}
|
||||
}
|
||||
|
||||
const agency = options.agency === undefined ? DEFAULT_AGENCY : options.agency
|
||||
|
||||
// --- white-label admin branding ---
|
||||
// Inject admin.components.graphics.Logo/Icon pointing at the plugin's
|
||||
// /admin export. The components read SiteSettings at render, so each client
|
||||
@@ -237,14 +242,16 @@ export const ipalKit = (options: IpalOptions): Plugin => {
|
||||
|
||||
// Vendor credit ("Technology by Intecion.com") under the nav — on by
|
||||
// default, hidden with credit:false, text/url overridable.
|
||||
const creditOn = wl.credit !== false
|
||||
const creditProps =
|
||||
wl.credit && typeof wl.credit === 'object'
|
||||
const creditOn = wl.credit !== false && agency !== false
|
||||
const creditProps = {
|
||||
...(agency ? { agency: agency.name, url: agency.url } : {}),
|
||||
...(wl.credit && typeof wl.credit === 'object'
|
||||
? {
|
||||
...(wl.credit.text ? { text: wl.credit.text } : {}),
|
||||
...(wl.credit.url ? { url: wl.credit.url } : {}),
|
||||
}
|
||||
: {}
|
||||
: {}),
|
||||
}
|
||||
|
||||
config.admin = {
|
||||
...(config.admin ?? {}),
|
||||
@@ -280,6 +287,33 @@ export const ipalKit = (options: IpalOptions): Plugin => {
|
||||
}
|
||||
}
|
||||
|
||||
// --- admin <head>: link previews + noindex (default on) ---
|
||||
// Static parts now; the site name parts come from Site settings in onInit
|
||||
// and after every save (syncAdminMeta). The project's own admin.meta keys win.
|
||||
let adminMeta: null | ResolvedAdminMeta = null
|
||||
const brandFields = options.whiteLabel && options.whiteLabel !== true ? options.whiteLabel : {}
|
||||
const settingsSlug = brandFields.settingsSlug ?? 'site-settings'
|
||||
if (options.adminMeta !== false) {
|
||||
const built = buildAdminMeta({
|
||||
agency,
|
||||
apiRoute: config.routes?.api,
|
||||
defaultLocale: options.i18n.defaultLocale,
|
||||
meta: config.admin?.meta,
|
||||
options: options.adminMeta ?? {},
|
||||
})
|
||||
adminMeta = built.resolved
|
||||
config.admin = { ...(config.admin ?? {}), meta: built.meta }
|
||||
config.endpoints = [
|
||||
...(config.endpoints ?? []),
|
||||
...buildAdminImageEndpoints(built.resolved, {
|
||||
iconField: brandFields.iconField,
|
||||
logoField: brandFields.logoField,
|
||||
nameField: brandFields.nameField,
|
||||
settingsSlug,
|
||||
}),
|
||||
]
|
||||
}
|
||||
|
||||
// --- i18n ---
|
||||
config.localization = buildLocalizationConfig(options.i18n)
|
||||
// Admin languages (en + pl unless the project set its own) and the plugin's texts.
|
||||
@@ -349,6 +383,28 @@ export const ipalKit = (options: IpalOptions): Plugin => {
|
||||
// The project's globalOverrides win (access, admin, hooks merged; a function = full control).
|
||||
config.globals = [...(config.globals ?? []), ...applyGlobalOverrides(withRevalidate, options.globalOverrides)]
|
||||
|
||||
// A new site name refreshes the panel's link preview texts.
|
||||
if (adminMeta) {
|
||||
const resolved = adminMeta
|
||||
config.globals = config.globals.map((g) =>
|
||||
g.slug === settingsSlug
|
||||
? {
|
||||
...g,
|
||||
hooks: {
|
||||
...g.hooks,
|
||||
afterChange: [
|
||||
...(g.hooks?.afterChange ?? []),
|
||||
async ({ doc, req }) => {
|
||||
await syncAdminMeta(req.payload, resolved, { nameField: brandFields.nameField, settingsSlug })
|
||||
return doc
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
: g,
|
||||
)
|
||||
}
|
||||
|
||||
config.endpoints = [...(config.endpoints ?? []), testEmailEndpoint]
|
||||
|
||||
// --- consent log: proof of consent (opt-in) ---
|
||||
@@ -502,6 +558,7 @@ export const ipalKit = (options: IpalOptions): Plugin => {
|
||||
config.onInit = async (payload) => {
|
||||
if (incomingOnInit) {await incomingOnInit(payload)}
|
||||
await migrateCookieSettingsSaveButton(payload)
|
||||
if (adminMeta) {await syncAdminMeta(payload, adminMeta, { nameField: brandFields.nameField, settingsSlug })}
|
||||
payload.logger.info('[ipal] Plugin initialized.')
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user