Added white-label support
This commit is contained in:
+50
-2
@@ -76,8 +76,8 @@ export const ipalKit = (options: IpalOptions): Plugin => {
|
||||
// optional peer dependency at build time (it isn't in the plugin's own
|
||||
// node_modules). Avoids TS2307 without @ts-expect-error; the module
|
||||
// exists at runtime in projects that installed it.
|
||||
// @ts-ignore
|
||||
const mod = (await import('@clocklimited/payload-2fa')) as {
|
||||
const pkg = '@clocklimited/payload-2fa'
|
||||
const mod = (await import(pkg)) as {
|
||||
payloadTotp?: (opts: Record<string, unknown>) => Plugin
|
||||
totpPlugin?: (opts: Record<string, unknown>) => Plugin
|
||||
}
|
||||
@@ -104,6 +104,54 @@ export const ipalKit = (options: IpalOptions): Plugin => {
|
||||
}
|
||||
}
|
||||
|
||||
// --- 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
|
||||
// sees their own brand from the panel (no brand in code). Project must run
|
||||
// `pnpm generate:importmap` so Payload resolves the component paths.
|
||||
if (options.whiteLabel) {
|
||||
const wl = options.whiteLabel === true ? {} : options.whiteLabel
|
||||
const serverProps: Record<string, unknown> = {}
|
||||
if (wl.settingsSlug) {serverProps.settingsSlug = wl.settingsSlug}
|
||||
if (wl.nameField) {serverProps.nameField = wl.nameField}
|
||||
const logoProps = { ...serverProps, ...(wl.logoField ? { imageField: wl.logoField } : {}) }
|
||||
const iconProps = { ...serverProps, ...(wl.iconField ? { imageField: wl.iconField } : {}) }
|
||||
|
||||
// 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'
|
||||
? {
|
||||
...(wl.credit.text ? { text: wl.credit.text } : {}),
|
||||
...(wl.credit.url ? { url: wl.credit.url } : {}),
|
||||
}
|
||||
: {}
|
||||
|
||||
config.admin = {
|
||||
...(config.admin ?? {}),
|
||||
components: {
|
||||
...(config.admin?.components ?? {}),
|
||||
graphics: {
|
||||
...(config.admin?.components?.graphics ?? {}),
|
||||
Icon: { path: '@intecion/ipal-kit/admin#AdminIcon', serverProps: iconProps },
|
||||
Logo: { path: '@intecion/ipal-kit/admin#AdminLogo', serverProps: logoProps },
|
||||
},
|
||||
...(creditOn
|
||||
? {
|
||||
afterNavLinks: [
|
||||
...(config.admin?.components?.afterNavLinks ?? []),
|
||||
{ path: '@intecion/ipal-kit/admin#IntecionCredit', serverProps: creditProps },
|
||||
],
|
||||
}
|
||||
: {}),
|
||||
},
|
||||
...(wl.titleSuffix
|
||||
? { meta: { ...(config.admin?.meta ?? {}), titleSuffix: wl.titleSuffix } }
|
||||
: {}),
|
||||
}
|
||||
}
|
||||
|
||||
// --- i18n ---
|
||||
config.localization = buildLocalizationConfig(options.i18n)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user