Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
73eacb09c2 | ||
|
|
2665cfa7b6 | ||
|
|
5c466b664c | ||
|
|
78e2f8fc7f | ||
|
|
13d669b757 |
@@ -194,7 +194,7 @@ Wpinaj w kolekcje gdzie dotyczy (patrz `hooks.md`):
|
|||||||
|
|
||||||
- **buildSecurityHeaders** w next.config — HSTS, COOP, nosniff, Referrer-Policy (z automatu, uniwersalne).
|
- **buildSecurityHeaders** w next.config — HSTS, COOP, nosniff, Referrer-Policy (z automatu, uniwersalne).
|
||||||
- **buildCsp** — generator CSP z twardymi regułami (base-uri, object-src, frame-ancestors). Flagi: turnstile, analytics, youtube, r2Url. Wdrażaj przez `report-only` → sprawdź konsolę → `enforce`.
|
- **buildCsp** — generator CSP z twardymi regułami (base-uri, object-src, frame-ancestors). Flagi: turnstile, analytics, youtube, r2Url. Wdrażaj przez `report-only` → sprawdź konsolę → `enforce`.
|
||||||
- **2FA WYMUSZONE** — `ipalKit({ twoFactor: { issuer: 'Nazwa Firmy' } })` + `pnpm add @clocklimited/payload-2fa@3.0.0-beta.7`. Wymuszone dla WSZYSTKICH użytkowników (forceSetup), bez opcji wyłączenia per user. NIE ustawiaj `twoFactor: false` (chyba że klient wprost odmawia). Bez zależności = błąd buildu. Patrz security.md.
|
- **2FA WYMUSZONE** — `pnpm add @clocklimited/payload-2fa@3.0.0-beta.7`, potem WSTRZYKNIJ: `import { payloadTotp } from '@clocklimited/payload-2fa'` + `ipalKit({ twoFactor: { issuer: 'Nazwa Firmy', plugin: payloadTotp } })`. Wstrzyknięcie obowiązkowe — bez niego plugin robi dynamiczny import, którego Next nie wbundluje → „Cannot find module" na froncie. (Ewentualnie zamiast wstrzyknięcia: `serverExternalPackages: ['@clocklimited/payload-2fa']` w next.config.) Wymuszone dla WSZYSTKICH (forceSetup), bez opcji per user. NIE `twoFactor: false` (chyba że klient wprost odmawia). Patrz security.md.
|
||||||
- **Ścieżka panelu** — `ipalKit({ adminRoute: '/its' })` ukrywa panel. WYMAGA przeniesienia folderu `app/(payload)/admin/` → `app/(payload)/its/`. To obscurity, nie security (2FA to prawdziwa ochrona).
|
- **Ścieżka panelu** — `ipalKit({ adminRoute: '/its' })` ukrywa panel. WYMAGA przeniesienia folderu `app/(payload)/admin/` → `app/(payload)/its/`. To obscurity, nie security (2FA to prawdziwa ochrona).
|
||||||
- CSP zostaje w projekcie (domeny), ale skeleton z pluginu. NIE Trusted Types (psuje Turnstile/GA).
|
- CSP zostaje w projekcie (domeny), ale skeleton z pluginu. NIE Trusted Types (psuje Turnstile/GA).
|
||||||
|
|
||||||
|
|||||||
+19
-12
@@ -17,29 +17,36 @@
|
|||||||
* set, nothing is forced.
|
* set, nothing is forced.
|
||||||
*/
|
*/
|
||||||
type BrandingProps = {
|
type BrandingProps = {
|
||||||
/** SiteSettings global slug. Default 'site-settings'. */
|
|
||||||
settingsSlug?: string;
|
|
||||||
/** Field holding the site name. Default 'siteName'. */
|
|
||||||
nameField?: string;
|
|
||||||
/** Upload field to render as the image. Default 'logo' (Logo) / 'favicon' (Icon). */
|
/** Upload field to render as the image. Default 'logo' (Logo) / 'favicon' (Icon). */
|
||||||
imageField?: string;
|
imageField?: string;
|
||||||
|
/** Field holding the site name. Default 'siteName'. */
|
||||||
|
nameField?: string;
|
||||||
|
/** SiteSettings global slug. Default 'site-settings'. */
|
||||||
|
settingsSlug?: string;
|
||||||
};
|
};
|
||||||
/** Admin panel logo (login screen + nav). SiteSettings `logo`, falls back to `siteName`. */
|
/**
|
||||||
|
* Admin panel logo — this is the LARGE logo on the login / unauthorized screens
|
||||||
|
* (Payload uses `graphics.Icon` for the small nav glyph). SiteSettings `logo`,
|
||||||
|
* falls back to `siteName` text. Sized generously for the login screen.
|
||||||
|
*/
|
||||||
export declare function AdminLogo(props?: BrandingProps): Promise<import("react/jsx-runtime").JSX.Element | null>;
|
export declare function AdminLogo(props?: BrandingProps): Promise<import("react/jsx-runtime").JSX.Element | null>;
|
||||||
/** Admin panel icon (small nav glyph). SiteSettings `favicon`, falls back to initials. */
|
/** Admin panel icon (small nav glyph). SiteSettings `favicon`, falls back to initials. */
|
||||||
export declare function AdminIcon(props?: BrandingProps): Promise<import("react/jsx-runtime").JSX.Element | null>;
|
export declare function AdminIcon(props?: BrandingProps): Promise<import("react/jsx-runtime").JSX.Element | null>;
|
||||||
/**
|
/**
|
||||||
* Discreet vendor credit shown at the bottom of the admin nav: "Technology by
|
* Discreet vendor credit: "Technology supported by Intecion.com". This is the
|
||||||
* Intecion.com". This is the PLUGIN VENDOR's credit (Intecion ships ipal-kit),
|
* PLUGIN VENDOR's credit (Intecion ships ipal-kit, the framework), not client
|
||||||
* not client data — so a sensible default here is fine and A0-safe. The client's
|
* data — a sensible default here is fine and A0-safe. The client's own brand
|
||||||
* own brand still owns the logo/name above (AdminLogo); this is a small line
|
* still owns the logo/name; this is a small line stating who supports the tech.
|
||||||
* stating who provides the technology. Text/URL overridable; turn it off with
|
* Text/URL overridable; turn it off with `whiteLabel: { credit: false }`.
|
||||||
* `whiteLabel: { credit: false }`.
|
|
||||||
*
|
*
|
||||||
* Wired by ipalKit into admin.components.afterNavLinks.
|
* Wired by ipalKit into admin.components.afterNavLinks (nav) AND afterLogin
|
||||||
|
* (login screen footer). `variant` adjusts placement:
|
||||||
|
* - 'nav' → left-aligned line under the nav links
|
||||||
|
* - 'login' → centered line below the login form
|
||||||
*/
|
*/
|
||||||
export declare function IntecionCredit(props?: {
|
export declare function IntecionCredit(props?: {
|
||||||
text?: string;
|
text?: string;
|
||||||
url?: string;
|
url?: string;
|
||||||
|
variant?: 'login' | 'nav';
|
||||||
}): import("react/jsx-runtime").JSX.Element;
|
}): import("react/jsx-runtime").JSX.Element;
|
||||||
export {};
|
export {};
|
||||||
|
|||||||
+61
-40
@@ -26,76 +26,97 @@ async function loadBranding(settingsSlug, nameField, imageField) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/** Admin panel logo (login screen + nav). SiteSettings `logo`, falls back to `siteName`. */ export async function AdminLogo(props = {}) {
|
/**
|
||||||
const { settingsSlug = 'site-settings', nameField = 'siteName', imageField = 'logo' } = props;
|
* Admin panel logo — this is the LARGE logo on the login / unauthorized screens
|
||||||
|
* (Payload uses `graphics.Icon` for the small nav glyph). SiteSettings `logo`,
|
||||||
|
* falls back to `siteName` text. Sized generously for the login screen.
|
||||||
|
*/ export async function AdminLogo(props = {}) {
|
||||||
|
const { imageField = 'logo', nameField = 'siteName', settingsSlug = 'site-settings' } = props;
|
||||||
const { name, url } = await loadBranding(settingsSlug, nameField, imageField);
|
const { name, url } = await loadBranding(settingsSlug, nameField, imageField);
|
||||||
if (url) {
|
if (url) {
|
||||||
return /*#__PURE__*/ _jsx("img", {
|
return /*#__PURE__*/ _jsx("img", {
|
||||||
src: url,
|
|
||||||
alt: name ?? '',
|
alt: name ?? '',
|
||||||
|
src: url,
|
||||||
style: {
|
style: {
|
||||||
maxHeight: 60,
|
height: 'auto',
|
||||||
maxWidth: 240,
|
maxHeight: 120,
|
||||||
width: 'auto',
|
maxWidth: 420,
|
||||||
height: 'auto'
|
width: 'auto'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (name) return /*#__PURE__*/ _jsx("div", {
|
if (name) {
|
||||||
style: {
|
return /*#__PURE__*/ _jsx("div", {
|
||||||
fontSize: '1.5rem',
|
style: {
|
||||||
fontWeight: 600
|
fontSize: '2rem',
|
||||||
},
|
fontWeight: 600
|
||||||
children: name
|
},
|
||||||
});
|
children: name
|
||||||
|
});
|
||||||
|
}
|
||||||
return null // nothing configured → Payload's default
|
return null // nothing configured → Payload's default
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
/** Admin panel icon (small nav glyph). SiteSettings `favicon`, falls back to initials. */ export async function AdminIcon(props = {}) {
|
/** Admin panel icon (small nav glyph). SiteSettings `favicon`, falls back to initials. */ export async function AdminIcon(props = {}) {
|
||||||
const { settingsSlug = 'site-settings', nameField = 'siteName', imageField = 'favicon' } = props;
|
const { imageField = 'favicon', nameField = 'siteName', settingsSlug = 'site-settings' } = props;
|
||||||
const { name, url } = await loadBranding(settingsSlug, nameField, imageField);
|
const { name, url } = await loadBranding(settingsSlug, nameField, imageField);
|
||||||
if (url) {
|
if (url) {
|
||||||
return /*#__PURE__*/ _jsx("img", {
|
return /*#__PURE__*/ _jsx("img", {
|
||||||
src: url,
|
|
||||||
alt: name ?? '',
|
alt: name ?? '',
|
||||||
|
src: url,
|
||||||
style: {
|
style: {
|
||||||
|
height: 'auto',
|
||||||
maxHeight: 28,
|
maxHeight: 28,
|
||||||
maxWidth: 28,
|
maxWidth: 28,
|
||||||
width: 'auto',
|
width: 'auto'
|
||||||
height: 'auto'
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (name) return /*#__PURE__*/ _jsx("div", {
|
if (name) {
|
||||||
style: {
|
return /*#__PURE__*/ _jsx("div", {
|
||||||
fontWeight: 700
|
style: {
|
||||||
},
|
fontWeight: 700
|
||||||
children: name.slice(0, 2).toUpperCase()
|
},
|
||||||
});
|
children: name.slice(0, 2).toUpperCase()
|
||||||
|
});
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Discreet vendor credit shown at the bottom of the admin nav: "Technology by
|
* Discreet vendor credit: "Technology supported by Intecion.com". This is the
|
||||||
* Intecion.com". This is the PLUGIN VENDOR's credit (Intecion ships ipal-kit),
|
* PLUGIN VENDOR's credit (Intecion ships ipal-kit, the framework), not client
|
||||||
* not client data — so a sensible default here is fine and A0-safe. The client's
|
* data — a sensible default here is fine and A0-safe. The client's own brand
|
||||||
* own brand still owns the logo/name above (AdminLogo); this is a small line
|
* still owns the logo/name; this is a small line stating who supports the tech.
|
||||||
* stating who provides the technology. Text/URL overridable; turn it off with
|
* Text/URL overridable; turn it off with `whiteLabel: { credit: false }`.
|
||||||
* `whiteLabel: { credit: false }`.
|
|
||||||
*
|
*
|
||||||
* Wired by ipalKit into admin.components.afterNavLinks.
|
* Wired by ipalKit into admin.components.afterNavLinks (nav) AND afterLogin
|
||||||
|
* (login screen footer). `variant` adjusts placement:
|
||||||
|
* - 'nav' → left-aligned line under the nav links
|
||||||
|
* - 'login' → centered line below the login form
|
||||||
*/ export function IntecionCredit(props = {}) {
|
*/ export function IntecionCredit(props = {}) {
|
||||||
const { text = 'Technology by Intecion.com', url = 'https://intecion.com' } = props;
|
const { text = 'Technology supported by Intecion.com', url = 'https://intecion.com', variant = 'nav' } = props;
|
||||||
|
const style = variant === 'login' ? {
|
||||||
|
color: 'inherit',
|
||||||
|
display: 'block',
|
||||||
|
fontSize: '0.75rem',
|
||||||
|
marginTop: '2rem',
|
||||||
|
opacity: 0.6,
|
||||||
|
padding: '0.5rem',
|
||||||
|
textAlign: 'center',
|
||||||
|
textDecoration: 'none'
|
||||||
|
} : {
|
||||||
|
color: 'inherit',
|
||||||
|
display: 'block',
|
||||||
|
fontSize: '0.75rem',
|
||||||
|
opacity: 0.6,
|
||||||
|
padding: '0.75rem 1rem',
|
||||||
|
textDecoration: 'none'
|
||||||
|
};
|
||||||
return /*#__PURE__*/ _jsx("a", {
|
return /*#__PURE__*/ _jsx("a", {
|
||||||
href: url,
|
href: url,
|
||||||
target: "_blank",
|
|
||||||
rel: "noopener noreferrer",
|
rel: "noopener noreferrer",
|
||||||
style: {
|
style: style,
|
||||||
display: 'block',
|
target: "_blank",
|
||||||
padding: '0.75rem 1rem',
|
|
||||||
fontSize: '0.75rem',
|
|
||||||
opacity: 0.6,
|
|
||||||
textDecoration: 'none'
|
|
||||||
},
|
|
||||||
children: text
|
children: text
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
@@ -47,7 +47,7 @@ import { buildLocalizedPath, getDefaultLocale, isValidLocale } from '../i18n/ind
|
|||||||
if (doc._status && doc._status !== 'published') {
|
if (doc._status && doc._status !== 'published') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (doc.meta?.noindex) {
|
if (doc.noindex || doc.meta?.noindex) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const title = typeof doc.title === 'string' ? doc.title : undefined;
|
const title = typeof doc.title === 'string' ? doc.title : undefined;
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+2
-2
@@ -70,7 +70,7 @@ import { buildLocalizedPath } from '../i18n/index.js';
|
|||||||
if (raw._status && raw._status !== 'published') {
|
if (raw._status && raw._status !== 'published') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (raw.meta?.noindex) {
|
if (raw.noindex || raw.meta?.noindex) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const title = typeof raw.title === 'string' ? raw.title : undefined;
|
const title = typeof raw.title === 'string' ? raw.title : undefined;
|
||||||
@@ -111,7 +111,7 @@ import { buildLocalizedPath } from '../i18n/index.js';
|
|||||||
if (raw._status && raw._status !== 'published') {
|
if (raw._status && raw._status !== 'published') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (raw.meta?.noindex) {
|
if (raw.noindex || raw.meta?.noindex) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const title = typeof raw.title === 'string' ? raw.title : undefined;
|
const title = typeof raw.title === 'string' ? raw.title : undefined;
|
||||||
|
|||||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+8
-1
@@ -53,6 +53,13 @@ type BuildMetadataArgs = {
|
|||||||
locale: string;
|
locale: string;
|
||||||
/** SEO meta from the document (plugin-seo group). */
|
/** SEO meta from the document (plugin-seo group). */
|
||||||
meta?: null | SeoMeta;
|
meta?: null | SeoMeta;
|
||||||
|
/**
|
||||||
|
* Top-level noindex flag (buildNoindexField). Checked alongside meta.noindex:
|
||||||
|
* plugin-seo's meta group doesn't declare noindex, so a mirror into
|
||||||
|
* meta.noindex is stripped on save — the top-level field is the one that
|
||||||
|
* persists. Either being true emits robots index:false.
|
||||||
|
*/
|
||||||
|
noindex?: boolean | null;
|
||||||
/** Page title or site name first. Defaults to 'page-first'. */
|
/** Page title or site name first. Defaults to 'page-first'. */
|
||||||
order?: TitleOrder;
|
order?: TitleOrder;
|
||||||
/**
|
/**
|
||||||
@@ -98,5 +105,5 @@ type BuildMetadataArgs = {
|
|||||||
* pieces (meta group, site name, image URL, localized slugs) and passes them
|
* pieces (meta group, site name, image URL, localized slugs) and passes them
|
||||||
* in — the plugin composes, it doesn't fetch.
|
* in — the plugin composes, it doesn't fetch.
|
||||||
*/
|
*/
|
||||||
export declare function buildMetadata({ baseUrl, config, homeSlug, imageUrl, locale, meta, order, pageTitle, prefix, query, separator, siteDescription, siteName, slugs, }: BuildMetadataArgs): PageMetadata;
|
export declare function buildMetadata({ baseUrl, config, homeSlug, imageUrl, locale, meta, noindex, order, pageTitle, prefix, query, separator, siteDescription, siteName, slugs, }: BuildMetadataArgs): PageMetadata;
|
||||||
export {};
|
export {};
|
||||||
|
|||||||
Vendored
+2
-2
@@ -9,7 +9,7 @@ import { buildHreflangAlternates } from './hreflang.js';
|
|||||||
* Designed for use inside Next.js `generateMetadata`. The caller resolves the
|
* Designed for use inside Next.js `generateMetadata`. The caller resolves the
|
||||||
* pieces (meta group, site name, image URL, localized slugs) and passes them
|
* pieces (meta group, site name, image URL, localized slugs) and passes them
|
||||||
* in — the plugin composes, it doesn't fetch.
|
* in — the plugin composes, it doesn't fetch.
|
||||||
*/ export function buildMetadata({ baseUrl, config, homeSlug = 'home', imageUrl, locale, meta, order, pageTitle, prefix, query, separator, siteDescription, siteName, slugs }) {
|
*/ export function buildMetadata({ baseUrl, config, homeSlug = 'home', imageUrl, locale, meta, noindex, order, pageTitle, prefix, query, separator, siteDescription, siteName, slugs }) {
|
||||||
// Title source priority: titleOverride (exact, wins outright) > meta.title
|
// Title source priority: titleOverride (exact, wins outright) > meta.title
|
||||||
// (SEO title an editor set) > pageTitle (the document's own name). This means
|
// (SEO title an editor set) > pageTitle (the document's own name). This means
|
||||||
// a page with no SEO title still shows its name (e.g. 'Sprzątanie biur')
|
// a page with no SEO title still shows its name (e.g. 'Sprzątanie biur')
|
||||||
@@ -83,7 +83,7 @@ import { buildHreflangAlternates } from './hreflang.js';
|
|||||||
// robots: noindex pages are excluded (follow keeps link authority). Indexed
|
// robots: noindex pages are excluded (follow keeps link authority). Indexed
|
||||||
// pages get generous snippet/preview limits so Google can show rich results
|
// pages get generous snippet/preview limits so Google can show rich results
|
||||||
// (long snippets, large image previews, full video previews).
|
// (long snippets, large image previews, full video previews).
|
||||||
...meta?.noindex ? {
|
...noindex || meta?.noindex ? {
|
||||||
robots: {
|
robots: {
|
||||||
follow: true,
|
follow: true,
|
||||||
index: false
|
index: false
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
+12
-15
@@ -2,29 +2,26 @@ import type { CheckboxField, Field } from 'payload';
|
|||||||
type BuildNoindexFieldArgs = {
|
type BuildNoindexFieldArgs = {
|
||||||
/** Help text under the checkbox. */
|
/** Help text under the checkbox. */
|
||||||
description?: string;
|
description?: string;
|
||||||
/** Sidebar label. Default 'Wyklucz z indeksowania (noindex)'. */
|
/** Sidebar label. Default 'Exclude from indexing (noindex)'. */
|
||||||
label?: string;
|
label?: string;
|
||||||
/**
|
|
||||||
* Dotted path, inside the document, that the SEO read path (metadata +
|
|
||||||
* sitemap) consumes. Default 'meta.noindex' — the plugin-seo `meta` group.
|
|
||||||
* The checkbox value is mirrored here on every save, so editors toggle one
|
|
||||||
* friendly switch and the machinery reads a stable location.
|
|
||||||
*/
|
|
||||||
metaPath?: string;
|
|
||||||
/** Field name for the editor-facing checkbox. Default 'noindex'. */
|
/** Field name for the editor-facing checkbox. Default 'noindex'. */
|
||||||
name?: string;
|
name?: string;
|
||||||
/** Extend/override the generated checkbox (position, access, etc.). */
|
/** Extend/override the generated checkbox (position, access, etc.). */
|
||||||
overrides?: Partial<CheckboxField>;
|
overrides?: Partial<CheckboxField>;
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* A sidebar `noindex` checkbox that mirrors into `meta.noindex` (what the
|
* A top-level sidebar `noindex` checkbox. When ticked, the page is excluded from
|
||||||
* sitemap and metadata generators actually read). Replaces the hand-rolled
|
* `sitemap.xml`, `llms.txt`, site search, and gets `robots: noindex, follow` —
|
||||||
* checkbox + `beforeChange` hook with its `(data as any).meta.noindex = …`
|
* ALL automatically, no per-project filtering.
|
||||||
* glue copied into every project — no `any`, one source of truth for editors,
|
|
||||||
* one stable read location for the engine.
|
|
||||||
*
|
*
|
||||||
* Idempotent and order-independent: if either the checkbox OR an existing
|
* Why top-level (not mirrored into `meta.noindex`): plugin-seo's `meta` group
|
||||||
* `meta.noindex` is set, the page ends up noindex; the two can't drift apart.
|
* declares only title/description/image, so Payload silently strips any extra
|
||||||
|
* key (`meta.noindex`) during sanitization — an earlier version mirrored there
|
||||||
|
* and the value vanished, leaking noindex pages into the sitemap. The value now
|
||||||
|
* lives on this top-level field, which persists; every reader in the kit
|
||||||
|
* (buildSitemapEntries, buildMetadata/createPageMetadata, buildLlmsTxt,
|
||||||
|
* searchContent) checks `doc.noindex` (and still tolerates a legacy
|
||||||
|
* `meta.noindex`). One field, one source of truth, zero project glue.
|
||||||
*
|
*
|
||||||
* // collections/Pages.ts
|
* // collections/Pages.ts
|
||||||
* import { buildNoindexField } from '@intecion/ipal-kit'
|
* import { buildNoindexField } from '@intecion/ipal-kit'
|
||||||
|
|||||||
+13
-47
@@ -1,49 +1,23 @@
|
|||||||
/** Read a dotted path (e.g. 'meta.noindex') off a loosely-typed object. */ function readPath(obj, path) {
|
|
||||||
let cur = obj;
|
|
||||||
for (const key of path){
|
|
||||||
if (cur == null || typeof cur !== 'object') {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
cur = cur[key];
|
|
||||||
}
|
|
||||||
return cur;
|
|
||||||
}
|
|
||||||
/** Write a dotted path, creating intermediate objects as needed. */ function writePath(obj, path, value) {
|
|
||||||
let cur = obj;
|
|
||||||
for(let i = 0; i < path.length - 1; i++){
|
|
||||||
const key = path[i];
|
|
||||||
const next = cur[key];
|
|
||||||
if (next == null || typeof next !== 'object') {
|
|
||||||
cur[key] = {};
|
|
||||||
}
|
|
||||||
cur = cur[key];
|
|
||||||
}
|
|
||||||
cur[path[path.length - 1]] = value;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* A sidebar `noindex` checkbox that mirrors into `meta.noindex` (what the
|
* A top-level sidebar `noindex` checkbox. When ticked, the page is excluded from
|
||||||
* sitemap and metadata generators actually read). Replaces the hand-rolled
|
* `sitemap.xml`, `llms.txt`, site search, and gets `robots: noindex, follow` —
|
||||||
* checkbox + `beforeChange` hook with its `(data as any).meta.noindex = …`
|
* ALL automatically, no per-project filtering.
|
||||||
* glue copied into every project — no `any`, one source of truth for editors,
|
|
||||||
* one stable read location for the engine.
|
|
||||||
*
|
*
|
||||||
* Idempotent and order-independent: if either the checkbox OR an existing
|
* Why top-level (not mirrored into `meta.noindex`): plugin-seo's `meta` group
|
||||||
* `meta.noindex` is set, the page ends up noindex; the two can't drift apart.
|
* declares only title/description/image, so Payload silently strips any extra
|
||||||
|
* key (`meta.noindex`) during sanitization — an earlier version mirrored there
|
||||||
|
* and the value vanished, leaking noindex pages into the sitemap. The value now
|
||||||
|
* lives on this top-level field, which persists; every reader in the kit
|
||||||
|
* (buildSitemapEntries, buildMetadata/createPageMetadata, buildLlmsTxt,
|
||||||
|
* searchContent) checks `doc.noindex` (and still tolerates a legacy
|
||||||
|
* `meta.noindex`). One field, one source of truth, zero project glue.
|
||||||
*
|
*
|
||||||
* // collections/Pages.ts
|
* // collections/Pages.ts
|
||||||
* import { buildNoindexField } from '@intecion/ipal-kit'
|
* import { buildNoindexField } from '@intecion/ipal-kit'
|
||||||
* fields: [ /* … *\/ buildNoindexField() ],
|
* fields: [ /* … *\/ buildNoindexField() ],
|
||||||
*/ export function buildNoindexField(args = {}) {
|
*/ export function buildNoindexField(args = {}) {
|
||||||
const { name = 'noindex', description = 'Check to exclude this page from indexing (robots: noindex, follow) and from sitemap.xml.', label = 'Exclude from indexing (noindex)', metaPath = 'meta.noindex', overrides = {} } = args;
|
const { name = 'noindex', description = 'Check to exclude this page from indexing (robots: noindex, follow), the sitemap, llms.txt and site search.', label = 'Exclude from indexing (noindex)', overrides = {} } = args;
|
||||||
const segments = metaPath.split('.');
|
const { admin: adminOverrides, ...restOverrides } = overrides;
|
||||||
const mirror = ({ data, value })=>{
|
|
||||||
const shouldNoindex = Boolean(value ?? readPath(data, segments));
|
|
||||||
if (data && typeof data === 'object') {
|
|
||||||
writePath(data, segments, shouldNoindex);
|
|
||||||
}
|
|
||||||
return shouldNoindex;
|
|
||||||
};
|
|
||||||
const { admin: adminOverrides, hooks: hooksOverrides, ...restOverrides } = overrides;
|
|
||||||
return {
|
return {
|
||||||
name,
|
name,
|
||||||
type: 'checkbox',
|
type: 'checkbox',
|
||||||
@@ -53,14 +27,6 @@
|
|||||||
...adminOverrides
|
...adminOverrides
|
||||||
},
|
},
|
||||||
defaultValue: false,
|
defaultValue: false,
|
||||||
hooks: {
|
|
||||||
...hooksOverrides,
|
|
||||||
// mirror runs first, then any project-supplied beforeChange hooks.
|
|
||||||
beforeChange: [
|
|
||||||
mirror,
|
|
||||||
...hooksOverrides?.beforeChange ?? []
|
|
||||||
]
|
|
||||||
},
|
|
||||||
label,
|
label,
|
||||||
...restOverrides
|
...restOverrides
|
||||||
};
|
};
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
+5
-1
@@ -29,7 +29,11 @@ import { buildHreflangAlternates } from './hreflang.js';
|
|||||||
if (doc._status && doc._status !== 'published') {
|
if (doc._status && doc._status !== 'published') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (doc.meta?.noindex) {
|
// Check BOTH the top-level checkbox (buildNoindexField, the field that
|
||||||
|
// persists) AND meta.noindex — plugin-seo's meta group doesn't declare
|
||||||
|
// noindex, so a mirror into meta.noindex is stripped on save. Reading both
|
||||||
|
// makes exclusion automatic regardless of where the flag ended up.
|
||||||
|
if (doc.noindex || doc.meta?.noindex) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (hasExcludedSlug(doc.slug)) {
|
if (hasExcludedSlug(doc.slug)) {
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
+1
@@ -90,6 +90,7 @@ import { slugsAcrossLocales } from './slugsAcrossLocales.js';
|
|||||||
...base,
|
...base,
|
||||||
imageUrl: resolveOgImage(doc),
|
imageUrl: resolveOgImage(doc),
|
||||||
meta: doc.meta,
|
meta: doc.meta,
|
||||||
|
noindex: doc.noindex,
|
||||||
pageTitle: doc.title,
|
pageTitle: doc.title,
|
||||||
prefix,
|
prefix,
|
||||||
query,
|
query,
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+41
-22
@@ -62,29 +62,35 @@ import { buildSeoPlugin, injectAutoFillMeta, injectSeoTabs } from './modules/seo
|
|||||||
if (!tf?.issuer) {
|
if (!tf?.issuer) {
|
||||||
throw new Error('[ipal] twoFactor.issuer is required (name shown in the authenticator ' + 'app). Pass twoFactor: { issuer: "Your Site" }, or twoFactor: false to ' + 'opt out (discouraged).');
|
throw new Error('[ipal] twoFactor.issuer is required (name shown in the authenticator ' + 'app). Pass twoFactor: { issuer: "Your Site" }, or twoFactor: false to ' + 'opt out (discouraged).');
|
||||||
}
|
}
|
||||||
try {
|
// Prefer the INJECTED plugin factory (recommended): the project imports
|
||||||
// Dynamic specifier via a variable so TS doesn't try to resolve this
|
// payloadTotp from @clocklimited/payload-2fa and passes it in. Then the
|
||||||
// optional peer dependency at build time (it isn't in the plugin's own
|
// plugin never imports the optional peer itself — no dynamic import, so
|
||||||
// node_modules). Avoids TS2307 without @ts-expect-error; the module
|
// Next can't fail to bundle it (the cause of "Cannot find module
|
||||||
// exists at runtime in projects that installed it.
|
// '@clocklimited/payload-2fa'" crashing even public frontend pages).
|
||||||
const pkg = '@clocklimited/payload-2fa';
|
let totp = tf.plugin;
|
||||||
const mod = await import(pkg);
|
if (!totp) {
|
||||||
// The package exports `payloadTotp`; older/other builds may use
|
// Fallback: dynamic import. Variable specifier dodges the plugin's own
|
||||||
// `totpPlugin`. Accept either so a rename doesn't break us.
|
// TS2307, but Next may NOT trace it into the server bundle — projects
|
||||||
const totp = mod.payloadTotp ?? mod.totpPlugin;
|
// using this path MUST add '@clocklimited/payload-2fa' to
|
||||||
if (typeof totp !== 'function') {
|
// serverExternalPackages in next.config (see docs/security.md).
|
||||||
throw new Error('expected export payloadTotp (or totpPlugin) to be a function — ' + 'check the installed @clocklimited/payload-2fa version');
|
try {
|
||||||
|
const pkg = '@clocklimited/payload-2fa';
|
||||||
|
const mod = await import(pkg);
|
||||||
|
totp = mod.payloadTotp ?? mod.totpPlugin;
|
||||||
|
} catch (err) {
|
||||||
|
throw new Error('[ipal] 2FA is enforced but @clocklimited/payload-2fa could not be loaded. ' + 'Best fix — inject it: `import { payloadTotp } from "@clocklimited/payload-2fa"` ' + 'then `twoFactor: { issuer, plugin: payloadTotp }`. Or install it AND add ' + "'@clocklimited/payload-2fa' to serverExternalPackages in next.config. Or set " + `twoFactor: false to opt out (discouraged). Original error: ${String(err)}`);
|
||||||
}
|
}
|
||||||
config = await totp({
|
|
||||||
collection: tf.collectionSlug ?? 'users',
|
|
||||||
forceSetup: true,
|
|
||||||
totp: {
|
|
||||||
issuer: tf.issuer
|
|
||||||
}
|
|
||||||
})(config);
|
|
||||||
} catch (err) {
|
|
||||||
throw new Error('[ipal] 2FA is enforced but @clocklimited/payload-2fa is not installed. ' + 'Run: pnpm add @clocklimited/payload-2fa — or set twoFactor: false to ' + `opt out (discouraged). Original error: ${String(err)}`);
|
|
||||||
}
|
}
|
||||||
|
if (typeof totp !== 'function') {
|
||||||
|
throw new Error('[ipal] 2FA: expected payloadTotp (or totpPlugin) to be a function — check the ' + 'injected `plugin` or the installed @clocklimited/payload-2fa version.');
|
||||||
|
}
|
||||||
|
config = await totp({
|
||||||
|
collection: tf.collectionSlug ?? 'users',
|
||||||
|
forceSetup: true,
|
||||||
|
totp: {
|
||||||
|
issuer: tf.issuer
|
||||||
|
}
|
||||||
|
})(config);
|
||||||
}
|
}
|
||||||
// --- white-label admin branding ---
|
// --- white-label admin branding ---
|
||||||
// Inject admin.components.graphics.Logo/Icon pointing at the plugin's
|
// Inject admin.components.graphics.Logo/Icon pointing at the plugin's
|
||||||
@@ -139,11 +145,24 @@ import { buildSeoPlugin, injectAutoFillMeta, injectSeoTabs } from './modules/seo
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
...creditOn ? {
|
...creditOn ? {
|
||||||
|
afterLogin: [
|
||||||
|
...config.admin?.components?.afterLogin ?? [],
|
||||||
|
{
|
||||||
|
path: '@intecion/ipal-kit/admin#IntecionCredit',
|
||||||
|
serverProps: {
|
||||||
|
...creditProps,
|
||||||
|
variant: 'login'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
afterNavLinks: [
|
afterNavLinks: [
|
||||||
...config.admin?.components?.afterNavLinks ?? [],
|
...config.admin?.components?.afterNavLinks ?? [],
|
||||||
{
|
{
|
||||||
path: '@intecion/ipal-kit/admin#IntecionCredit',
|
path: '@intecion/ipal-kit/admin#IntecionCredit',
|
||||||
serverProps: creditProps
|
serverProps: {
|
||||||
|
...creditProps,
|
||||||
|
variant: 'nav'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
} : {}
|
} : {}
|
||||||
|
|||||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+24
-1
@@ -1,4 +1,15 @@
|
|||||||
import type { Field } from 'payload';
|
import type { Field, Plugin } from 'payload';
|
||||||
|
/**
|
||||||
|
* Factory shape of @clocklimited/payload-2fa's `payloadTotp` export — injected
|
||||||
|
* so the plugin never imports the optional peer itself.
|
||||||
|
*/
|
||||||
|
export type TotpPluginFactory = (options: {
|
||||||
|
collection: string;
|
||||||
|
forceSetup: boolean;
|
||||||
|
totp: {
|
||||||
|
issuer: string;
|
||||||
|
};
|
||||||
|
}) => Plugin;
|
||||||
import type { AccessOption } from './modules/access/types.js';
|
import type { AccessOption } from './modules/access/types.js';
|
||||||
import type { ContentOption } from './modules/content/types.js';
|
import type { ContentOption } from './modules/content/types.js';
|
||||||
import type { FormsOption } from './modules/forms/types.js';
|
import type { FormsOption } from './modules/forms/types.js';
|
||||||
@@ -71,6 +82,18 @@ export type IpalOptions = {
|
|||||||
collectionSlug?: string;
|
collectionSlug?: string;
|
||||||
/** Name shown in the authenticator app (e.g. company/site name). */
|
/** Name shown in the authenticator app (e.g. company/site name). */
|
||||||
issuer: string;
|
issuer: string;
|
||||||
|
/**
|
||||||
|
* The 2FA plugin factory, INJECTED from the project:
|
||||||
|
* `import { payloadTotp } from '@clocklimited/payload-2fa'`. Strongly
|
||||||
|
* recommended — injecting it (the same pattern as NextResponse /
|
||||||
|
* revalidatePath) means the plugin never dynamically imports the
|
||||||
|
* optional peer, which Next can fail to bundle into the server chunks
|
||||||
|
* ("Cannot find module '@clocklimited/payload-2fa'" at runtime, even on
|
||||||
|
* public frontend pages). If omitted, the plugin falls back to a dynamic
|
||||||
|
* import and you MUST add '@clocklimited/payload-2fa' to
|
||||||
|
* serverExternalPackages in next.config. See docs/security.md.
|
||||||
|
*/
|
||||||
|
plugin?: TotpPluginFactory;
|
||||||
} | false;
|
} | false;
|
||||||
/**
|
/**
|
||||||
* White-label the admin panel: show the CLIENT's brand (logo + name) in the
|
* White-label the admin panel: show the CLIENT's brand (logo + name) in the
|
||||||
|
|||||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -210,7 +210,7 @@ Wpinaj w kolekcje gdzie dotyczy (patrz `hooks.md`):
|
|||||||
|
|
||||||
- **buildSecurityHeaders** w next.config — HSTS, COOP, nosniff, Referrer-Policy (z automatu, uniwersalne).
|
- **buildSecurityHeaders** w next.config — HSTS, COOP, nosniff, Referrer-Policy (z automatu, uniwersalne).
|
||||||
- **buildCsp** — generator CSP z twardymi regułami (base-uri, object-src, frame-ancestors). Flagi: turnstile, analytics, youtube, r2Url. Wdrażaj przez `report-only` → sprawdź konsolę → `enforce`.
|
- **buildCsp** — generator CSP z twardymi regułami (base-uri, object-src, frame-ancestors). Flagi: turnstile, analytics, youtube, r2Url. Wdrażaj przez `report-only` → sprawdź konsolę → `enforce`.
|
||||||
- **2FA WYMUSZONE** — `ipalKit({ twoFactor: { issuer: 'Nazwa Firmy' } })` + `pnpm add @clocklimited/payload-2fa@3.0.0-beta.7`. Wymuszone dla WSZYSTKICH użytkowników (forceSetup), bez opcji wyłączenia per user. NIE ustawiaj `twoFactor: false` (chyba że klient wprost odmawia). Bez zależności = błąd buildu. Patrz security.md.
|
- **2FA WYMUSZONE** — `pnpm add @clocklimited/[email protected]`, potem WSTRZYKNIJ: `import { payloadTotp } from '@clocklimited/payload-2fa'` + `ipalKit({ twoFactor: { issuer: 'Nazwa Firmy', plugin: payloadTotp } })`. Wstrzyknięcie obowiązkowe — bez niego plugin robi dynamiczny import, którego Next nie wbundluje → „Cannot find module" na froncie. (Ewentualnie: `serverExternalPackages: ['@clocklimited/payload-2fa']` w next.config.) Wymuszone dla WSZYSTKICH (forceSetup), bez opcji per user. NIE `twoFactor: false` (chyba że klient wprost odmawia). Patrz security.md.
|
||||||
- **Ścieżka panelu** — `ipalKit({ adminRoute: '/its' })` ukrywa panel. WYMAGA przeniesienia folderu `app/(payload)/admin/` → `app/(payload)/its/`. To obscurity, nie security (2FA to prawdziwa ochrona).
|
- **Ścieżka panelu** — `ipalKit({ adminRoute: '/its' })` ukrywa panel. WYMAGA przeniesienia folderu `app/(payload)/admin/` → `app/(payload)/its/`. To obscurity, nie security (2FA to prawdziwa ochrona).
|
||||||
- CSP zostaje w projekcie (domeny), ale skeleton z pluginu. NIE Trusted Types (psuje Turnstile/GA).
|
- CSP zostaje w projekcie (domeny), ale skeleton z pluginu. NIE Trusted Types (psuje Turnstile/GA).
|
||||||
|
|
||||||
|
|||||||
+24
-6
@@ -258,23 +258,41 @@ pnpm add @clocklimited/[email protected]
|
|||||||
Uwaga: pakiet nie ma jeszcze stabilnego 3.0.0 — użyj konkretnej wersji beta
|
Uwaga: pakiet nie ma jeszcze stabilnego 3.0.0 — użyj konkretnej wersji beta
|
||||||
(albo `^3.0.0-0`, żeby dopuścić prereleasy). Sam `^3.0.0` da błąd
|
(albo `^3.0.0-0`, żeby dopuścić prereleasy). Sam `^3.0.0` da błąd
|
||||||
ERR_PNPM_NO_MATCHING_VERSION.
|
ERR_PNPM_NO_MATCHING_VERSION.
|
||||||
To PEER dependency — ipal-kit importuje ją dynamicznie tylko gdy 2FA włączone
|
|
||||||
(domyślnie). Bez niej i z włączonym 2FA plugin rzuci jasny błąd.
|
|
||||||
|
|
||||||
### Konfiguracja (payload.config.ts)
|
### Konfiguracja (payload.config.ts) — WSTRZYKNIJ plugin (zalecane)
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
|
import { payloadTotp } from '@clocklimited/payload-2fa'
|
||||||
|
|
||||||
ipalKit({
|
ipalKit({
|
||||||
i18n: i18nConfig,
|
i18n: i18nConfig,
|
||||||
twoFactor: {
|
twoFactor: {
|
||||||
issuer: 'Nazwa Firmy', // pokazywane w aplikacji authenticator (Google Auth itp.)
|
issuer: 'Nazwa Firmy', // pokazywane w aplikacji authenticator
|
||||||
// collectionSlug: 'users', // domyślnie 'users'
|
plugin: payloadTotp, // ← WSTRZYKNIJ — patrz niżej dlaczego
|
||||||
|
// collectionSlug: 'users',
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Dlaczego `plugin: payloadTotp` (wstrzyknięcie):** to ten sam wzorzec co
|
||||||
|
`NextResponse`/`revalidatePath` — projekt podaje peer-dep, plugin go NIE
|
||||||
|
importuje. Bez tego plugin robi dynamiczny import, którego **Next potrafi nie
|
||||||
|
wbundlować** do server chunks → błąd runtime **„Cannot find module
|
||||||
|
'@clocklimited/payload-2fa'"** lecący nawet na publicznych stronach frontu.
|
||||||
|
Wstrzyknięcie eliminuje ten problem u źródła.
|
||||||
|
|
||||||
|
**Jeśli NIE wstrzykujesz** (zostawiasz dynamiczny import) — MUSISZ dodać pakiet do
|
||||||
|
`serverExternalPackages` w `next.config`, żeby Next nie próbował go bundlować:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
// next.config.ts
|
||||||
|
const nextConfig = {
|
||||||
|
serverExternalPackages: ['@clocklimited/payload-2fa'],
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
Plugin ustawia `forceSetup: true` — każdy użytkownik MUSI skonfigurować TOTP po
|
Plugin ustawia `forceSetup: true` — każdy użytkownik MUSI skonfigurować TOTP po
|
||||||
zalogowaniu (przekierowanie na setup). Nie ma opcji „włącz/wyłącz" dla użytkownika.
|
zalogowaniu. Nie ma opcji „włącz/wyłącz" dla użytkownika.
|
||||||
|
|
||||||
### Wyłączenie (ODRADZANE)
|
### Wyłączenie (ODRADZANE)
|
||||||
|
|
||||||
|
|||||||
+19
-7
@@ -731,9 +731,9 @@ Alternatywnie: dodaj `noindex` do System Pages o rolach prawnych automatycznie.
|
|||||||
|
|
||||||
### buildNoindexField — przyjazny checkbox w sidebarze
|
### buildNoindexField — przyjazny checkbox w sidebarze
|
||||||
|
|
||||||
Zamiast własnego checkboxa + hooka z `(data as any).meta.noindex = …` użyj
|
Jeden przełącznik w sidebarze. Zaznaczony → strona **automatycznie** wypada z:
|
||||||
gotowego pola. Jeden przełącznik dla redaktora, zgrany z `meta.noindex` (to
|
`sitemap.xml`, `llms.txt`, wyszukiwarki, i dostaje `robots: noindex, follow` —
|
||||||
czyta sitemap i metadata), bez `any`, bez rozjazdu między dwoma miejscami:
|
bez żadnego ręcznego filtrowania w projekcie.
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { buildNoindexField } from '@intecion/ipal-kit'
|
import { buildNoindexField } from '@intecion/ipal-kit'
|
||||||
@@ -743,10 +743,22 @@ export const Pages: CollectionConfig = {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Idempotentne: jeśli ustawiony checkbox LUB istniejące `meta.noindex` — strona
|
**Pole jest top-level (`doc.noindex`), NIE mirrorowane do `meta.noindex`.**
|
||||||
wychodzi `noindex`; nie da się ich rozjechać. Opcje: `name` (domyślnie
|
Dlaczego: grupa `meta` z plugin-seo deklaruje tylko title/description/image, więc
|
||||||
`'noindex'`), `label`, `description`, `metaPath` (domyślnie `'meta.noindex'`),
|
Payload przy sanityzacji **po cichu wycina** każdy dodatkowy klucz (`meta.noindex`)
|
||||||
`overrides` (pozycja, access itp.).
|
— wcześniejsza wersja mirrorowała tam wartość i znikała, przez co strony noindex
|
||||||
|
trafiały do sitemapy. Teraz wartość żyje na polu top-level (które się zapisuje), a
|
||||||
|
wszystkie czytniki kitu (`buildSitemapEntries`, `buildMetadata`/
|
||||||
|
`createPageMetadata`, `buildLlmsTxt`, `searchContent`) sprawdzają `doc.noindex`
|
||||||
|
(oraz, dla zgodności wstecznej, ewentualne `meta.noindex`). Jedno pole, jedno
|
||||||
|
źródło prawdy, zero kleju w projekcie.
|
||||||
|
|
||||||
|
Opcje: `name` (domyślnie `'noindex'`), `label`, `description`, `overrides`
|
||||||
|
(pozycja, access itp.).
|
||||||
|
|
||||||
|
> Naprawione w 1.7.5 — wcześniej (mirror do `meta.noindex`) strony noindex
|
||||||
|
> potrafiły wyciekać do sitemapy. Po aktualizacji `app/sitemap.xml/route.ts`
|
||||||
|
> wraca do czystej jednolinijki, bez ręcznego filtrowania.
|
||||||
|
|
||||||
## robots.txt — blokada parametrów (crawl budget)
|
## robots.txt — blokada parametrów (crawl budget)
|
||||||
|
|
||||||
|
|||||||
+16
-6
@@ -37,20 +37,30 @@ whiteLabel: {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Kredyt dostawcy — „Technology by Intecion.com"
|
## Kredyt dostawcy — „Technology supported by Intecion.com"
|
||||||
|
|
||||||
Pod nawigacją panelu (`afterNavLinks`) wyświetla się dyskretny kredyt
|
Dyskretny kredyt **„Technology supported by Intecion.com"** (link do
|
||||||
**„Technology by Intecion.com"** z linkiem do `https://intecion.com`. To kredyt
|
`https://intecion.com`) pojawia się w **dwóch miejscach**:
|
||||||
DOSTAWCY technologii (Intecion dostarcza ipal-kit) — marka klienta nadal rządzi
|
- **pod nawigacją** panelu (`afterNavLinks`, wariant `nav` — wyrównany do lewej),
|
||||||
logiem i nazwą u góry; to tylko mała linijka „kto dostarcza technologię".
|
- **na dole ekranu logowania** (`afterLogin`, wariant `login` — wyśrodkowany).
|
||||||
|
|
||||||
|
To kredyt DOSTAWCY technologii (Intecion dostarcza framework ipal-kit) — marka
|
||||||
|
klienta nadal rządzi logiem i nazwą; to tylko linijka „kto wspiera technologię".
|
||||||
|
|
||||||
Domyślnie włączony z `whiteLabel`. Sterowanie:
|
Domyślnie włączony z `whiteLabel`. Sterowanie:
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
whiteLabel: { credit: false } // ukryj
|
whiteLabel: { credit: false } // ukryj (oba miejsca)
|
||||||
whiteLabel: { credit: { text: 'Powered by Intecion', url: 'https://intecion.com' } } // własny tekst/url
|
whiteLabel: { credit: { text: 'Powered by Intecion', url: 'https://intecion.com' } } // własny tekst/url
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Logo na ekranie logowania
|
||||||
|
|
||||||
|
`AdminLogo` to DUŻE logo na ekranie logowania (Payload używa `graphics.Icon` do
|
||||||
|
małej ikony w nawigacji). Renderuje się sporo większe (`maxHeight 120 / maxWidth
|
||||||
|
420`), żeby marka klienta była wyraźna przy logowaniu. Mała ikona nav to `favicon`
|
||||||
|
przez `AdminIcon`.
|
||||||
|
|
||||||
## Jak to działa
|
## Jak to działa
|
||||||
|
|
||||||
- `AdminLogo` / `AdminIcon` to **Server Components** czytające SiteSettings przy
|
- `AdminLogo` / `AdminIcon` to **Server Components** czytające SiteSettings przy
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@intecion/ipal-kit",
|
"name": "@intecion/ipal-kit",
|
||||||
"version": "1.7.2",
|
"version": "1.7.6",
|
||||||
"description": "Intecion Payload Advanced Library — a Payload CMS 3 plugin: i18n, SEO, forms, consent, analytics, blog/archives.",
|
"description": "Intecion Payload Advanced Library — a Payload CMS 3 plugin: i18n, SEO, forms, consent, analytics, blog/archives.",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|||||||
@@ -20,21 +20,21 @@ import { getPayload } from 'payload'
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
type BrandingProps = {
|
type BrandingProps = {
|
||||||
/** SiteSettings global slug. Default 'site-settings'. */
|
|
||||||
settingsSlug?: string
|
|
||||||
/** Field holding the site name. Default 'siteName'. */
|
|
||||||
nameField?: string
|
|
||||||
/** Upload field to render as the image. Default 'logo' (Logo) / 'favicon' (Icon). */
|
/** Upload field to render as the image. Default 'logo' (Logo) / 'favicon' (Icon). */
|
||||||
imageField?: string
|
imageField?: string
|
||||||
|
/** Field holding the site name. Default 'siteName'. */
|
||||||
|
nameField?: string
|
||||||
|
/** SiteSettings global slug. Default 'site-settings'. */
|
||||||
|
settingsSlug?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
type MediaLike = { url?: string | null } | null | undefined
|
type MediaLike = { url?: null | string } | null | undefined
|
||||||
|
|
||||||
async function loadBranding(
|
async function loadBranding(
|
||||||
settingsSlug: string,
|
settingsSlug: string,
|
||||||
nameField: string,
|
nameField: string,
|
||||||
imageField: string,
|
imageField: string,
|
||||||
): Promise<{ name: string | null; url: string | null }> {
|
): Promise<{ name: null | string; url: null | string }> {
|
||||||
try {
|
try {
|
||||||
// Consumer alias — resolved in the project's build, hidden from plugin tsc.
|
// Consumer alias — resolved in the project's build, hidden from plugin tsc.
|
||||||
const spec = '@payload-config'
|
const spec = '@payload-config'
|
||||||
@@ -45,7 +45,7 @@ async function loadBranding(
|
|||||||
depth: 1,
|
depth: 1,
|
||||||
})) as Record<string, unknown>
|
})) as Record<string, unknown>
|
||||||
|
|
||||||
const name = typeof settings[nameField] === 'string' ? (settings[nameField] as string) : null
|
const name = typeof settings[nameField] === 'string' ? (settings[nameField]) : null
|
||||||
const image = settings[imageField] as MediaLike
|
const image = settings[imageField] as MediaLike
|
||||||
const url =
|
const url =
|
||||||
image && typeof image === 'object' && typeof image.url === 'string' ? image.url : null
|
image && typeof image === 'object' && typeof image.url === 'string' ? image.url : null
|
||||||
@@ -55,65 +55,86 @@ async function loadBranding(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Admin panel logo (login screen + nav). SiteSettings `logo`, falls back to `siteName`. */
|
/**
|
||||||
|
* Admin panel logo — this is the LARGE logo on the login / unauthorized screens
|
||||||
|
* (Payload uses `graphics.Icon` for the small nav glyph). SiteSettings `logo`,
|
||||||
|
* falls back to `siteName` text. Sized generously for the login screen.
|
||||||
|
*/
|
||||||
export async function AdminLogo(props: BrandingProps = {}) {
|
export async function AdminLogo(props: BrandingProps = {}) {
|
||||||
const { settingsSlug = 'site-settings', nameField = 'siteName', imageField = 'logo' } = props
|
const { imageField = 'logo', nameField = 'siteName', settingsSlug = 'site-settings' } = props
|
||||||
const { name, url } = await loadBranding(settingsSlug, nameField, imageField)
|
const { name, url } = await loadBranding(settingsSlug, nameField, imageField)
|
||||||
if (url) {
|
if (url) {
|
||||||
return (
|
return (
|
||||||
<img
|
<img
|
||||||
src={url}
|
|
||||||
alt={name ?? ''}
|
alt={name ?? ''}
|
||||||
style={{ maxHeight: 60, maxWidth: 240, width: 'auto', height: 'auto' }}
|
src={url}
|
||||||
|
style={{ height: 'auto', maxHeight: 120, maxWidth: 420, width: 'auto' }}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (name) return <div style={{ fontSize: '1.5rem', fontWeight: 600 }}>{name}</div>
|
if (name) {return <div style={{ fontSize: '2rem', fontWeight: 600 }}>{name}</div>}
|
||||||
return null // nothing configured → Payload's default
|
return null // nothing configured → Payload's default
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Admin panel icon (small nav glyph). SiteSettings `favicon`, falls back to initials. */
|
/** Admin panel icon (small nav glyph). SiteSettings `favicon`, falls back to initials. */
|
||||||
export async function AdminIcon(props: BrandingProps = {}) {
|
export async function AdminIcon(props: BrandingProps = {}) {
|
||||||
const { settingsSlug = 'site-settings', nameField = 'siteName', imageField = 'favicon' } = props
|
const { imageField = 'favicon', nameField = 'siteName', settingsSlug = 'site-settings' } = props
|
||||||
const { name, url } = await loadBranding(settingsSlug, nameField, imageField)
|
const { name, url } = await loadBranding(settingsSlug, nameField, imageField)
|
||||||
if (url) {
|
if (url) {
|
||||||
return (
|
return (
|
||||||
<img
|
<img
|
||||||
src={url}
|
|
||||||
alt={name ?? ''}
|
alt={name ?? ''}
|
||||||
style={{ maxHeight: 28, maxWidth: 28, width: 'auto', height: 'auto' }}
|
src={url}
|
||||||
|
style={{ height: 'auto', maxHeight: 28, maxWidth: 28, width: 'auto' }}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (name) return <div style={{ fontWeight: 700 }}>{name.slice(0, 2).toUpperCase()}</div>
|
if (name) {return <div style={{ fontWeight: 700 }}>{name.slice(0, 2).toUpperCase()}</div>}
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Discreet vendor credit shown at the bottom of the admin nav: "Technology by
|
* Discreet vendor credit: "Technology supported by Intecion.com". This is the
|
||||||
* Intecion.com". This is the PLUGIN VENDOR's credit (Intecion ships ipal-kit),
|
* PLUGIN VENDOR's credit (Intecion ships ipal-kit, the framework), not client
|
||||||
* not client data — so a sensible default here is fine and A0-safe. The client's
|
* data — a sensible default here is fine and A0-safe. The client's own brand
|
||||||
* own brand still owns the logo/name above (AdminLogo); this is a small line
|
* still owns the logo/name; this is a small line stating who supports the tech.
|
||||||
* stating who provides the technology. Text/URL overridable; turn it off with
|
* Text/URL overridable; turn it off with `whiteLabel: { credit: false }`.
|
||||||
* `whiteLabel: { credit: false }`.
|
|
||||||
*
|
*
|
||||||
* Wired by ipalKit into admin.components.afterNavLinks.
|
* Wired by ipalKit into admin.components.afterNavLinks (nav) AND afterLogin
|
||||||
|
* (login screen footer). `variant` adjusts placement:
|
||||||
|
* - 'nav' → left-aligned line under the nav links
|
||||||
|
* - 'login' → centered line below the login form
|
||||||
*/
|
*/
|
||||||
export function IntecionCredit(props: { text?: string; url?: string } = {}) {
|
export function IntecionCredit(
|
||||||
const { text = 'Technology by Intecion.com', url = 'https://intecion.com' } = props
|
props: { text?: string; url?: string; variant?: 'login' | 'nav' } = {},
|
||||||
|
) {
|
||||||
|
const {
|
||||||
|
text = 'Technology supported by Intecion.com',
|
||||||
|
url = 'https://intecion.com',
|
||||||
|
variant = 'nav',
|
||||||
|
} = props
|
||||||
|
const style =
|
||||||
|
variant === 'login'
|
||||||
|
? {
|
||||||
|
color: 'inherit' as const,
|
||||||
|
display: 'block',
|
||||||
|
fontSize: '0.75rem',
|
||||||
|
marginTop: '2rem',
|
||||||
|
opacity: 0.6,
|
||||||
|
padding: '0.5rem',
|
||||||
|
textAlign: 'center' as const,
|
||||||
|
textDecoration: 'none',
|
||||||
|
}
|
||||||
|
: {
|
||||||
|
color: 'inherit' as const,
|
||||||
|
display: 'block',
|
||||||
|
fontSize: '0.75rem',
|
||||||
|
opacity: 0.6,
|
||||||
|
padding: '0.75rem 1rem',
|
||||||
|
textDecoration: 'none',
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<a
|
<a href={url} rel="noopener noreferrer" style={style} target="_blank">
|
||||||
href={url}
|
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
style={{
|
|
||||||
display: 'block',
|
|
||||||
padding: '0.75rem 1rem',
|
|
||||||
fontSize: '0.75rem',
|
|
||||||
opacity: 0.6,
|
|
||||||
textDecoration: 'none',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{text}
|
{text}
|
||||||
</a>
|
</a>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ type PageRow = {
|
|||||||
_status?: string
|
_status?: string
|
||||||
id: number | string
|
id: number | string
|
||||||
meta?: { description?: unknown; noindex?: boolean } | null
|
meta?: { description?: unknown; noindex?: boolean } | null
|
||||||
|
noindex?: boolean | null
|
||||||
slug?: unknown
|
slug?: unknown
|
||||||
title?: unknown
|
title?: unknown
|
||||||
}
|
}
|
||||||
@@ -91,7 +92,7 @@ export async function searchContent({
|
|||||||
const results: SearchResult[] = []
|
const results: SearchResult[] = []
|
||||||
for (const doc of docs) {
|
for (const doc of docs) {
|
||||||
if (doc._status && doc._status !== 'published') {continue}
|
if (doc._status && doc._status !== 'published') {continue}
|
||||||
if (doc.meta?.noindex) {continue}
|
if (doc.noindex || doc.meta?.noindex) {continue}
|
||||||
const title = typeof doc.title === 'string' ? doc.title : undefined
|
const title = typeof doc.title === 'string' ? doc.title : undefined
|
||||||
const slug = typeof doc.slug === 'string' ? doc.slug : undefined
|
const slug = typeof doc.slug === 'string' ? doc.slug : undefined
|
||||||
if (!title || !slug) {continue}
|
if (!title || !slug) {continue}
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ type PageRow = {
|
|||||||
_status?: string
|
_status?: string
|
||||||
id: number | string
|
id: number | string
|
||||||
meta?: { description?: unknown; noindex?: boolean } | null
|
meta?: { description?: unknown; noindex?: boolean } | null
|
||||||
|
noindex?: boolean | null
|
||||||
slug?: unknown
|
slug?: unknown
|
||||||
title?: unknown
|
title?: unknown
|
||||||
}
|
}
|
||||||
@@ -131,7 +132,7 @@ export async function buildLlmsTxt({
|
|||||||
const sections: string[] = []
|
const sections: string[] = []
|
||||||
for (const raw of result.docs as PageRow[]) {
|
for (const raw of result.docs as PageRow[]) {
|
||||||
if (raw._status && raw._status !== 'published') {continue}
|
if (raw._status && raw._status !== 'published') {continue}
|
||||||
if (raw.meta?.noindex) {continue}
|
if (raw.noindex || raw.meta?.noindex) {continue}
|
||||||
|
|
||||||
const title = typeof raw.title === 'string' ? raw.title : undefined
|
const title = typeof raw.title === 'string' ? raw.title : undefined
|
||||||
const slug = typeof raw.slug === 'string' ? raw.slug : undefined
|
const slug = typeof raw.slug === 'string' ? raw.slug : undefined
|
||||||
@@ -153,7 +154,7 @@ export async function buildLlmsTxt({
|
|||||||
const pageLinks: string[] = []
|
const pageLinks: string[] = []
|
||||||
for (const raw of result.docs as PageRow[]) {
|
for (const raw of result.docs as PageRow[]) {
|
||||||
if (raw._status && raw._status !== 'published') {continue}
|
if (raw._status && raw._status !== 'published') {continue}
|
||||||
if (raw.meta?.noindex) {continue}
|
if (raw.noindex || raw.meta?.noindex) {continue}
|
||||||
|
|
||||||
const title = typeof raw.title === 'string' ? raw.title : undefined
|
const title = typeof raw.title === 'string' ? raw.title : undefined
|
||||||
const slug = typeof raw.slug === 'string' ? raw.slug : undefined
|
const slug = typeof raw.slug === 'string' ? raw.slug : undefined
|
||||||
|
|||||||
@@ -57,6 +57,13 @@ type BuildMetadataArgs = {
|
|||||||
locale: string
|
locale: string
|
||||||
/** SEO meta from the document (plugin-seo group). */
|
/** SEO meta from the document (plugin-seo group). */
|
||||||
meta?: null | SeoMeta
|
meta?: null | SeoMeta
|
||||||
|
/**
|
||||||
|
* Top-level noindex flag (buildNoindexField). Checked alongside meta.noindex:
|
||||||
|
* plugin-seo's meta group doesn't declare noindex, so a mirror into
|
||||||
|
* meta.noindex is stripped on save — the top-level field is the one that
|
||||||
|
* persists. Either being true emits robots index:false.
|
||||||
|
*/
|
||||||
|
noindex?: boolean | null
|
||||||
/** Page title or site name first. Defaults to 'page-first'. */
|
/** Page title or site name first. Defaults to 'page-first'. */
|
||||||
order?: TitleOrder
|
order?: TitleOrder
|
||||||
/**
|
/**
|
||||||
@@ -110,6 +117,7 @@ export function buildMetadata({
|
|||||||
imageUrl,
|
imageUrl,
|
||||||
locale,
|
locale,
|
||||||
meta,
|
meta,
|
||||||
|
noindex,
|
||||||
order,
|
order,
|
||||||
pageTitle,
|
pageTitle,
|
||||||
prefix,
|
prefix,
|
||||||
@@ -163,7 +171,7 @@ export function buildMetadata({
|
|||||||
// robots: noindex pages are excluded (follow keeps link authority). Indexed
|
// robots: noindex pages are excluded (follow keeps link authority). Indexed
|
||||||
// pages get generous snippet/preview limits so Google can show rich results
|
// pages get generous snippet/preview limits so Google can show rich results
|
||||||
// (long snippets, large image previews, full video previews).
|
// (long snippets, large image previews, full video previews).
|
||||||
...(meta?.noindex
|
...(noindex || meta?.noindex
|
||||||
? { robots: { follow: true, index: false } }
|
? { robots: { follow: true, index: false } }
|
||||||
: {
|
: {
|
||||||
robots: {
|
robots: {
|
||||||
|
|||||||
@@ -1,54 +1,29 @@
|
|||||||
import type { CheckboxField, Field, FieldHook } from 'payload'
|
import type { CheckboxField, Field } from 'payload'
|
||||||
|
|
||||||
type BuildNoindexFieldArgs = {
|
type BuildNoindexFieldArgs = {
|
||||||
/** Help text under the checkbox. */
|
/** Help text under the checkbox. */
|
||||||
description?: string
|
description?: string
|
||||||
/** Sidebar label. Default 'Wyklucz z indeksowania (noindex)'. */
|
/** Sidebar label. Default 'Exclude from indexing (noindex)'. */
|
||||||
label?: string
|
label?: string
|
||||||
/**
|
|
||||||
* Dotted path, inside the document, that the SEO read path (metadata +
|
|
||||||
* sitemap) consumes. Default 'meta.noindex' — the plugin-seo `meta` group.
|
|
||||||
* The checkbox value is mirrored here on every save, so editors toggle one
|
|
||||||
* friendly switch and the machinery reads a stable location.
|
|
||||||
*/
|
|
||||||
metaPath?: string
|
|
||||||
/** Field name for the editor-facing checkbox. Default 'noindex'. */
|
/** Field name for the editor-facing checkbox. Default 'noindex'. */
|
||||||
name?: string
|
name?: string
|
||||||
/** Extend/override the generated checkbox (position, access, etc.). */
|
/** Extend/override the generated checkbox (position, access, etc.). */
|
||||||
overrides?: Partial<CheckboxField>
|
overrides?: Partial<CheckboxField>
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Read a dotted path (e.g. 'meta.noindex') off a loosely-typed object. */
|
|
||||||
function readPath(obj: null | Record<string, unknown> | undefined, path: string[]): unknown {
|
|
||||||
let cur: unknown = obj
|
|
||||||
for (const key of path) {
|
|
||||||
if (cur == null || typeof cur !== 'object') {return undefined}
|
|
||||||
cur = (cur as Record<string, unknown>)[key]
|
|
||||||
}
|
|
||||||
return cur
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Write a dotted path, creating intermediate objects as needed. */
|
|
||||||
function writePath(obj: Record<string, unknown>, path: string[], value: unknown): void {
|
|
||||||
let cur: Record<string, unknown> = obj
|
|
||||||
for (let i = 0; i < path.length - 1; i++) {
|
|
||||||
const key = path[i]
|
|
||||||
const next = cur[key]
|
|
||||||
if (next == null || typeof next !== 'object') {cur[key] = {}}
|
|
||||||
cur = cur[key] as Record<string, unknown>
|
|
||||||
}
|
|
||||||
cur[path[path.length - 1]] = value
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A sidebar `noindex` checkbox that mirrors into `meta.noindex` (what the
|
* A top-level sidebar `noindex` checkbox. When ticked, the page is excluded from
|
||||||
* sitemap and metadata generators actually read). Replaces the hand-rolled
|
* `sitemap.xml`, `llms.txt`, site search, and gets `robots: noindex, follow` —
|
||||||
* checkbox + `beforeChange` hook with its `(data as any).meta.noindex = …`
|
* ALL automatically, no per-project filtering.
|
||||||
* glue copied into every project — no `any`, one source of truth for editors,
|
|
||||||
* one stable read location for the engine.
|
|
||||||
*
|
*
|
||||||
* Idempotent and order-independent: if either the checkbox OR an existing
|
* Why top-level (not mirrored into `meta.noindex`): plugin-seo's `meta` group
|
||||||
* `meta.noindex` is set, the page ends up noindex; the two can't drift apart.
|
* declares only title/description/image, so Payload silently strips any extra
|
||||||
|
* key (`meta.noindex`) during sanitization — an earlier version mirrored there
|
||||||
|
* and the value vanished, leaking noindex pages into the sitemap. The value now
|
||||||
|
* lives on this top-level field, which persists; every reader in the kit
|
||||||
|
* (buildSitemapEntries, buildMetadata/createPageMetadata, buildLlmsTxt,
|
||||||
|
* searchContent) checks `doc.noindex` (and still tolerates a legacy
|
||||||
|
* `meta.noindex`). One field, one source of truth, zero project glue.
|
||||||
*
|
*
|
||||||
* // collections/Pages.ts
|
* // collections/Pages.ts
|
||||||
* import { buildNoindexField } from '@intecion/ipal-kit'
|
* import { buildNoindexField } from '@intecion/ipal-kit'
|
||||||
@@ -57,23 +32,12 @@ function writePath(obj: Record<string, unknown>, path: string[], value: unknown)
|
|||||||
export function buildNoindexField(args: BuildNoindexFieldArgs = {}): Field {
|
export function buildNoindexField(args: BuildNoindexFieldArgs = {}): Field {
|
||||||
const {
|
const {
|
||||||
name = 'noindex',
|
name = 'noindex',
|
||||||
description = 'Check to exclude this page from indexing (robots: noindex, follow) and from sitemap.xml.',
|
description = 'Check to exclude this page from indexing (robots: noindex, follow), the sitemap, llms.txt and site search.',
|
||||||
label = 'Exclude from indexing (noindex)',
|
label = 'Exclude from indexing (noindex)',
|
||||||
metaPath = 'meta.noindex',
|
|
||||||
overrides = {},
|
overrides = {},
|
||||||
} = args
|
} = args
|
||||||
|
|
||||||
const segments = metaPath.split('.')
|
const { admin: adminOverrides, ...restOverrides } = overrides
|
||||||
|
|
||||||
const mirror: FieldHook = ({ data, value }) => {
|
|
||||||
const shouldNoindex = Boolean(value ?? readPath(data as Record<string, unknown>, segments))
|
|
||||||
if (data && typeof data === 'object') {
|
|
||||||
writePath(data as Record<string, unknown>, segments, shouldNoindex)
|
|
||||||
}
|
|
||||||
return shouldNoindex
|
|
||||||
}
|
|
||||||
|
|
||||||
const { admin: adminOverrides, hooks: hooksOverrides, ...restOverrides } = overrides
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name,
|
name,
|
||||||
@@ -84,11 +48,6 @@ export function buildNoindexField(args: BuildNoindexFieldArgs = {}): Field {
|
|||||||
...adminOverrides,
|
...adminOverrides,
|
||||||
},
|
},
|
||||||
defaultValue: false,
|
defaultValue: false,
|
||||||
hooks: {
|
|
||||||
...hooksOverrides,
|
|
||||||
// mirror runs first, then any project-supplied beforeChange hooks.
|
|
||||||
beforeChange: [mirror, ...(hooksOverrides?.beforeChange ?? [])],
|
|
||||||
},
|
|
||||||
label,
|
label,
|
||||||
...restOverrides,
|
...restOverrides,
|
||||||
} as CheckboxField
|
} as CheckboxField
|
||||||
|
|||||||
@@ -52,6 +52,8 @@ type DocRow = {
|
|||||||
_status?: string
|
_status?: string
|
||||||
id: number | string
|
id: number | string
|
||||||
meta?: { noindex?: boolean } | null
|
meta?: { noindex?: boolean } | null
|
||||||
|
/** Top-level checkbox (buildNoindexField) — the field that actually persists. */
|
||||||
|
noindex?: boolean | null
|
||||||
slug?: unknown
|
slug?: unknown
|
||||||
updatedAt?: string
|
updatedAt?: string
|
||||||
}
|
}
|
||||||
@@ -78,7 +80,11 @@ function hasExcludedSlug(slug: unknown): boolean {
|
|||||||
/** Skip drafts, noindex, and system/error pages (404 etc.). */
|
/** Skip drafts, noindex, and system/error pages (404 etc.). */
|
||||||
function isIndexable(doc: DocRow): boolean {
|
function isIndexable(doc: DocRow): boolean {
|
||||||
if (doc._status && doc._status !== 'published') {return false}
|
if (doc._status && doc._status !== 'published') {return false}
|
||||||
if (doc.meta?.noindex) {return false}
|
// Check BOTH the top-level checkbox (buildNoindexField, the field that
|
||||||
|
// persists) AND meta.noindex — plugin-seo's meta group doesn't declare
|
||||||
|
// noindex, so a mirror into meta.noindex is stripped on save. Reading both
|
||||||
|
// makes exclusion automatic regardless of where the flag ended up.
|
||||||
|
if (doc.noindex || doc.meta?.noindex) {return false}
|
||||||
if (hasExcludedSlug(doc.slug)) {return false}
|
if (hasExcludedSlug(doc.slug)) {return false}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,6 +43,8 @@ type PageMetadataContext = {
|
|||||||
type DocShape = {
|
type DocShape = {
|
||||||
id: number | string
|
id: number | string
|
||||||
meta?: null | SeoMeta
|
meta?: null | SeoMeta
|
||||||
|
/** Top-level noindex checkbox (buildNoindexField) — the field that persists. */
|
||||||
|
noindex?: boolean | null
|
||||||
/** The document's own title (page name), used as the fallback page title. */
|
/** The document's own title (page name), used as the fallback page title. */
|
||||||
title?: null | string
|
title?: null | string
|
||||||
}
|
}
|
||||||
@@ -153,6 +155,7 @@ export function createPageMetadata(args: CreatePageMetadataArgs) {
|
|||||||
...base,
|
...base,
|
||||||
imageUrl: resolveOgImage(doc),
|
imageUrl: resolveOgImage(doc),
|
||||||
meta: doc.meta,
|
meta: doc.meta,
|
||||||
|
noindex: doc.noindex,
|
||||||
pageTitle: doc.title,
|
pageTitle: doc.title,
|
||||||
prefix,
|
prefix,
|
||||||
query,
|
query,
|
||||||
|
|||||||
+48
-27
@@ -1,6 +1,6 @@
|
|||||||
import type { Config, Plugin } from 'payload'
|
import type { Config, Plugin } from 'payload'
|
||||||
|
|
||||||
import type { IpalOptions } from './types.js'
|
import type { IpalOptions, TotpPluginFactory } from './types.js'
|
||||||
|
|
||||||
import { buildCookieSettings } from './globals/CookieSettings/index.js'
|
import { buildCookieSettings } from './globals/CookieSettings/index.js'
|
||||||
import { buildNotifications } from './globals/Notifications/index.js'
|
import { buildNotifications } from './globals/Notifications/index.js'
|
||||||
@@ -71,37 +71,48 @@ export const ipalKit = (options: IpalOptions): Plugin => {
|
|||||||
'opt out (discouraged).',
|
'opt out (discouraged).',
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
try {
|
// Prefer the INJECTED plugin factory (recommended): the project imports
|
||||||
// Dynamic specifier via a variable so TS doesn't try to resolve this
|
// payloadTotp from @clocklimited/payload-2fa and passes it in. Then the
|
||||||
// optional peer dependency at build time (it isn't in the plugin's own
|
// plugin never imports the optional peer itself — no dynamic import, so
|
||||||
// node_modules). Avoids TS2307 without @ts-expect-error; the module
|
// Next can't fail to bundle it (the cause of "Cannot find module
|
||||||
// exists at runtime in projects that installed it.
|
// '@clocklimited/payload-2fa'" crashing even public frontend pages).
|
||||||
const pkg = '@clocklimited/payload-2fa'
|
let totp: TotpPluginFactory | undefined = tf.plugin
|
||||||
const mod = (await import(pkg)) as {
|
|
||||||
payloadTotp?: (opts: Record<string, unknown>) => Plugin
|
if (!totp) {
|
||||||
totpPlugin?: (opts: Record<string, unknown>) => Plugin
|
// Fallback: dynamic import. Variable specifier dodges the plugin's own
|
||||||
}
|
// TS2307, but Next may NOT trace it into the server bundle — projects
|
||||||
// The package exports `payloadTotp`; older/other builds may use
|
// using this path MUST add '@clocklimited/payload-2fa' to
|
||||||
// `totpPlugin`. Accept either so a rename doesn't break us.
|
// serverExternalPackages in next.config (see docs/security.md).
|
||||||
const totp = mod.payloadTotp ?? mod.totpPlugin
|
try {
|
||||||
if (typeof totp !== 'function') {
|
const pkg = '@clocklimited/payload-2fa'
|
||||||
|
const mod = (await import(pkg)) as {
|
||||||
|
payloadTotp?: TotpPluginFactory
|
||||||
|
totpPlugin?: TotpPluginFactory
|
||||||
|
}
|
||||||
|
totp = mod.payloadTotp ?? mod.totpPlugin
|
||||||
|
} catch (err) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'expected export payloadTotp (or totpPlugin) to be a function — ' +
|
'[ipal] 2FA is enforced but @clocklimited/payload-2fa could not be loaded. ' +
|
||||||
'check the installed @clocklimited/payload-2fa version',
|
'Best fix — inject it: `import { payloadTotp } from "@clocklimited/payload-2fa"` ' +
|
||||||
|
'then `twoFactor: { issuer, plugin: payloadTotp }`. Or install it AND add ' +
|
||||||
|
"'@clocklimited/payload-2fa' to serverExternalPackages in next.config. Or set " +
|
||||||
|
`twoFactor: false to opt out (discouraged). Original error: ${String(err)}`,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
config = await totp({
|
}
|
||||||
collection: tf.collectionSlug ?? 'users',
|
|
||||||
forceSetup: true, // ENFORCED — every user must set up TOTP; no opt-out
|
if (typeof totp !== 'function') {
|
||||||
totp: { issuer: tf.issuer },
|
|
||||||
})(config)
|
|
||||||
} catch (err) {
|
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'[ipal] 2FA is enforced but @clocklimited/payload-2fa is not installed. ' +
|
'[ipal] 2FA: expected payloadTotp (or totpPlugin) to be a function — check the ' +
|
||||||
'Run: pnpm add @clocklimited/payload-2fa — or set twoFactor: false to ' +
|
'injected `plugin` or the installed @clocklimited/payload-2fa version.',
|
||||||
`opt out (discouraged). Original error: ${String(err)}`,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
config = await totp({
|
||||||
|
collection: tf.collectionSlug ?? 'users',
|
||||||
|
forceSetup: true, // ENFORCED — every user must set up TOTP; no opt-out
|
||||||
|
totp: { issuer: tf.issuer },
|
||||||
|
})(config)
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- white-label admin branding ---
|
// --- white-label admin branding ---
|
||||||
@@ -139,9 +150,19 @@ export const ipalKit = (options: IpalOptions): Plugin => {
|
|||||||
},
|
},
|
||||||
...(creditOn
|
...(creditOn
|
||||||
? {
|
? {
|
||||||
|
afterLogin: [
|
||||||
|
...(config.admin?.components?.afterLogin ?? []),
|
||||||
|
{
|
||||||
|
path: '@intecion/ipal-kit/admin#IntecionCredit',
|
||||||
|
serverProps: { ...creditProps, variant: 'login' },
|
||||||
|
},
|
||||||
|
],
|
||||||
afterNavLinks: [
|
afterNavLinks: [
|
||||||
...(config.admin?.components?.afterNavLinks ?? []),
|
...(config.admin?.components?.afterNavLinks ?? []),
|
||||||
{ path: '@intecion/ipal-kit/admin#IntecionCredit', serverProps: creditProps },
|
{
|
||||||
|
path: '@intecion/ipal-kit/admin#IntecionCredit',
|
||||||
|
serverProps: { ...creditProps, variant: 'nav' },
|
||||||
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
: {}),
|
: {}),
|
||||||
|
|||||||
+22
-1
@@ -1,5 +1,14 @@
|
|||||||
import type { Field } from 'payload'
|
import type { Field, Plugin } from 'payload'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factory shape of @clocklimited/payload-2fa's `payloadTotp` export — injected
|
||||||
|
* so the plugin never imports the optional peer itself.
|
||||||
|
*/
|
||||||
|
export type TotpPluginFactory = (options: {
|
||||||
|
collection: string
|
||||||
|
forceSetup: boolean
|
||||||
|
totp: { issuer: string }
|
||||||
|
}) => Plugin
|
||||||
import type { AccessOption } from './modules/access/types.js'
|
import type { AccessOption } from './modules/access/types.js'
|
||||||
import type { ContentOption } from './modules/content/types.js'
|
import type { ContentOption } from './modules/content/types.js'
|
||||||
import type { FormsOption } from './modules/forms/types.js'
|
import type { FormsOption } from './modules/forms/types.js'
|
||||||
@@ -84,6 +93,18 @@ export type IpalOptions = {
|
|||||||
collectionSlug?: string
|
collectionSlug?: string
|
||||||
/** Name shown in the authenticator app (e.g. company/site name). */
|
/** Name shown in the authenticator app (e.g. company/site name). */
|
||||||
issuer: string
|
issuer: string
|
||||||
|
/**
|
||||||
|
* The 2FA plugin factory, INJECTED from the project:
|
||||||
|
* `import { payloadTotp } from '@clocklimited/payload-2fa'`. Strongly
|
||||||
|
* recommended — injecting it (the same pattern as NextResponse /
|
||||||
|
* revalidatePath) means the plugin never dynamically imports the
|
||||||
|
* optional peer, which Next can fail to bundle into the server chunks
|
||||||
|
* ("Cannot find module '@clocklimited/payload-2fa'" at runtime, even on
|
||||||
|
* public frontend pages). If omitted, the plugin falls back to a dynamic
|
||||||
|
* import and you MUST add '@clocklimited/payload-2fa' to
|
||||||
|
* serverExternalPackages in next.config. See docs/security.md.
|
||||||
|
*/
|
||||||
|
plugin?: TotpPluginFactory
|
||||||
}
|
}
|
||||||
| false
|
| false
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user