Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4a46651839 | ||
|
|
e7f06548fb | ||
|
|
e2a703fc72 | ||
|
|
de75d8374d | ||
|
|
b807fbe69a | ||
|
|
827cd9bcbc | ||
|
|
fa2b607979 | ||
|
|
4fe690e1e2 |
Vendored
+4
-2
@@ -1,5 +1,7 @@
|
|||||||
export { MaskedField } from '../globals/SiteIntegrations/components/MaskedField.js';
|
export { MaskedField } from '../globals/SiteIntegrations/components/MaskedField.js';
|
||||||
export { TestEmailButton } from '../globals/SiteIntegrations/components/TestEmailButton.js';
|
export { TestEmailButton } from '../globals/SiteIntegrations/components/TestEmailButton.js';
|
||||||
|
export { AccessibilityProvider, AccessibilityWidget, useAccessibility, } from '../modules/accessibility/client.js';
|
||||||
|
export type { A11yClassNames, A11yState, A11yTexts } from '../modules/accessibility/client.js';
|
||||||
export { Analytics } from '../modules/analytics/client.js';
|
export { Analytics } from '../modules/analytics/client.js';
|
||||||
/**
|
/**
|
||||||
* Entry point: ipal-kit/client
|
* Entry point: ipal-kit/client
|
||||||
@@ -10,8 +12,8 @@ export { Analytics } from '../modules/analytics/client.js';
|
|||||||
*/
|
*/
|
||||||
export { ConsentProvider, CookieBanner, CookieButton, useConsent, useConsentContext, } from '../modules/consent/client.js';
|
export { ConsentProvider, CookieBanner, CookieButton, useConsent, useConsentContext, } from '../modules/consent/client.js';
|
||||||
export type { CookieBannerClassNames } from '../modules/consent/client.js';
|
export type { CookieBannerClassNames } from '../modules/consent/client.js';
|
||||||
export { resolveFormMessage } from '../modules/notifications/resolveFormMessage.js';
|
export { buildLocalizedPath, getLocaleCodes, getLocalizedSlugs, switchLocalePath, } from '../modules/i18n/index.js';
|
||||||
export type { FormNotificationTexts } from '../modules/notifications/types.js';
|
export type { I18nConfig, LocalizedSlugs } from '../modules/i18n/index.js';
|
||||||
export { Turnstile } from '../modules/turnstile/client.js';
|
export { Turnstile } from '../modules/turnstile/client.js';
|
||||||
export { TurnstileProvider, useTurnstile } from '../modules/turnstile/client.js';
|
export { TurnstileProvider, useTurnstile } from '../modules/turnstile/client.js';
|
||||||
export type { TurnstileProps } from '../modules/turnstile/client.js';
|
export type { TurnstileProps } from '../modules/turnstile/client.js';
|
||||||
|
|||||||
Vendored
+4
-1
@@ -1,6 +1,7 @@
|
|||||||
'use client';
|
'use client';
|
||||||
export { MaskedField } from '../globals/SiteIntegrations/components/MaskedField.js';
|
export { MaskedField } from '../globals/SiteIntegrations/components/MaskedField.js';
|
||||||
export { TestEmailButton } from '../globals/SiteIntegrations/components/TestEmailButton.js';
|
export { TestEmailButton } from '../globals/SiteIntegrations/components/TestEmailButton.js';
|
||||||
|
export { AccessibilityProvider, AccessibilityWidget, useAccessibility } from '../modules/accessibility/client.js';
|
||||||
export { Analytics } from '../modules/analytics/client.js';
|
export { Analytics } from '../modules/analytics/client.js';
|
||||||
/**
|
/**
|
||||||
* Entry point: ipal-kit/client
|
* Entry point: ipal-kit/client
|
||||||
@@ -9,7 +10,9 @@ export { Analytics } from '../modules/analytics/client.js';
|
|||||||
* components. Kept separate from the main entry so server bundles don't pull in
|
* components. Kept separate from the main entry so server bundles don't pull in
|
||||||
* client-only code.
|
* client-only code.
|
||||||
*/ export { ConsentProvider, CookieBanner, CookieButton, useConsent, useConsentContext } from '../modules/consent/client.js';
|
*/ export { ConsentProvider, CookieBanner, CookieButton, useConsent, useConsentContext } from '../modules/consent/client.js';
|
||||||
export { resolveFormMessage } from '../modules/notifications/resolveFormMessage.js';
|
// Pure i18n path helpers — no server/RSC deps, safe to import in client
|
||||||
|
// components (e.g. a LanguageSwitcher that computes locale URLs on the client).
|
||||||
|
export { buildLocalizedPath, getLocaleCodes, getLocalizedSlugs, switchLocalePath } from '../modules/i18n/index.js';
|
||||||
export { Turnstile } from '../modules/turnstile/client.js';
|
export { Turnstile } from '../modules/turnstile/client.js';
|
||||||
export { TurnstileProvider, useTurnstile } from '../modules/turnstile/client.js';
|
export { TurnstileProvider, useTurnstile } from '../modules/turnstile/client.js';
|
||||||
|
|
||||||
|
|||||||
Vendored
+1
-1
@@ -1 +1 @@
|
|||||||
{"version":3,"sources":["../../src/exports/client.ts"],"sourcesContent":["'use client'\nexport { MaskedField } from '../globals/SiteIntegrations/components/MaskedField.js'\nexport { TestEmailButton } from '../globals/SiteIntegrations/components/TestEmailButton.js'\nexport { Analytics } from '../modules/analytics/client.js'\n/**\n * Entry point: ipal-kit/client\n *\n * Client-side ('use client') exports — React hooks, providers, and UI\n * components. Kept separate from the main entry so server bundles don't pull in\n * client-only code.\n */\nexport {\n ConsentProvider,\n CookieBanner,\n CookieButton,\n useConsent,\n useConsentContext,\n} from '../modules/consent/client.js'\nexport type { CookieBannerClassNames } from '../modules/consent/client.js'\nexport { resolveFormMessage } from '../modules/notifications/resolveFormMessage.js'\nexport type { FormNotificationTexts } from '../modules/notifications/types.js'\nexport { Turnstile } from '../modules/turnstile/client.js'\nexport { TurnstileProvider, useTurnstile } from '../modules/turnstile/client.js'\nexport type { TurnstileProps } from '../modules/turnstile/client.js'\n"],"names":["MaskedField","TestEmailButton","Analytics","ConsentProvider","CookieBanner","CookieButton","useConsent","useConsentContext","resolveFormMessage","Turnstile","TurnstileProvider","useTurnstile"],"mappings":"AAAA;AACA,SAASA,WAAW,QAAQ,wDAAuD;AACnF,SAASC,eAAe,QAAQ,4DAA2D;AAC3F,SAASC,SAAS,QAAQ,iCAAgC;AAC1D;;;;;;CAMC,GACD,SACEC,eAAe,EACfC,YAAY,EACZC,YAAY,EACZC,UAAU,EACVC,iBAAiB,QACZ,+BAA8B;AAErC,SAASC,kBAAkB,QAAQ,iDAAgD;AAEnF,SAASC,SAAS,QAAQ,iCAAgC;AAC1D,SAASC,iBAAiB,EAAEC,YAAY,QAAQ,iCAAgC"}
|
{"version":3,"sources":["../../src/exports/client.ts"],"sourcesContent":["'use client'\nexport { MaskedField } from '../globals/SiteIntegrations/components/MaskedField.js'\nexport { TestEmailButton } from '../globals/SiteIntegrations/components/TestEmailButton.js'\nexport {\n AccessibilityProvider,\n AccessibilityWidget,\n useAccessibility,\n} from '../modules/accessibility/client.js'\nexport type { A11yClassNames, A11yState, A11yTexts } from '../modules/accessibility/client.js'\n\nexport { Analytics } from '../modules/analytics/client.js'\n/**\n * Entry point: ipal-kit/client\n *\n * Client-side ('use client') exports — React hooks, providers, and UI\n * components. Kept separate from the main entry so server bundles don't pull in\n * client-only code.\n */\nexport {\n ConsentProvider,\n CookieBanner,\n CookieButton,\n useConsent,\n useConsentContext,\n} from '../modules/consent/client.js'\nexport type { CookieBannerClassNames } from '../modules/consent/client.js'\n// Pure i18n path helpers — no server/RSC deps, safe to import in client\n// components (e.g. a LanguageSwitcher that computes locale URLs on the client).\nexport {\n buildLocalizedPath,\n getLocaleCodes,\n getLocalizedSlugs,\n switchLocalePath,\n} from '../modules/i18n/index.js'\nexport type { I18nConfig, LocalizedSlugs } from '../modules/i18n/index.js'\nexport { Turnstile } from '../modules/turnstile/client.js'\nexport { TurnstileProvider, useTurnstile } from '../modules/turnstile/client.js'\nexport type { TurnstileProps } from '../modules/turnstile/client.js'\n"],"names":["MaskedField","TestEmailButton","AccessibilityProvider","AccessibilityWidget","useAccessibility","Analytics","ConsentProvider","CookieBanner","CookieButton","useConsent","useConsentContext","buildLocalizedPath","getLocaleCodes","getLocalizedSlugs","switchLocalePath","Turnstile","TurnstileProvider","useTurnstile"],"mappings":"AAAA;AACA,SAASA,WAAW,QAAQ,wDAAuD;AACnF,SAASC,eAAe,QAAQ,4DAA2D;AAC3F,SACEC,qBAAqB,EACrBC,mBAAmB,EACnBC,gBAAgB,QACX,qCAAoC;AAG3C,SAASC,SAAS,QAAQ,iCAAgC;AAC1D;;;;;;CAMC,GACD,SACEC,eAAe,EACfC,YAAY,EACZC,YAAY,EACZC,UAAU,EACVC,iBAAiB,QACZ,+BAA8B;AAErC,wEAAwE;AACxE,gFAAgF;AAChF,SACEC,kBAAkB,EAClBC,cAAc,EACdC,iBAAiB,EACjBC,gBAAgB,QACX,2BAA0B;AAEjC,SAASC,SAAS,QAAQ,iCAAgC;AAC1D,SAASC,iBAAiB,EAAEC,YAAY,QAAQ,iCAAgC"}
|
||||||
Vendored
+2
@@ -1,5 +1,7 @@
|
|||||||
export type { AccessOption, Role } from './modules/access/index.js';
|
export type { AccessOption, Role } from './modules/access/index.js';
|
||||||
export { adminOnly, adminOnlyField, adminOrEditor, adminOrEditorField, adminOrSelf, authenticated, hasMinimumRole, isAdmin, isEditor, requireRole, requireRoleField, ROLE_HIERARCHY, } from './modules/access/index.js';
|
export { adminOnly, adminOnlyField, adminOrEditor, adminOrEditorField, adminOrSelf, authenticated, hasMinimumRole, isAdmin, isEditor, requireRole, requireRoleField, ROLE_HIERARCHY, } from './modules/access/index.js';
|
||||||
|
export { A11Y_COOKIE, A11Y_DEFAULT, a11yAttributes, parseA11y, serializeA11y, } from './modules/accessibility/index.js';
|
||||||
|
export type { A11yState } from './modules/accessibility/index.js';
|
||||||
export type { AnalyticsConfig } from './modules/analytics/index.js';
|
export type { AnalyticsConfig } from './modules/analytics/index.js';
|
||||||
export { getAnalyticsConfig } from './modules/analytics/index.js';
|
export { getAnalyticsConfig } from './modules/analytics/index.js';
|
||||||
export { ACCEPT_ALL_CONSENT, CONSENT_CATEGORIES, CONSENT_COOKIE, CONSENT_MAX_AGE, CONSENT_VERSION, DEFAULT_CONSENT, getConsentTexts, parseConsent, REJECT_ALL_CONSENT, serializeConsent, setDefaultConsent, updateConsent, } from './modules/consent/index.js';
|
export { ACCEPT_ALL_CONSENT, CONSENT_CATEGORIES, CONSENT_COOKIE, CONSENT_MAX_AGE, CONSENT_VERSION, DEFAULT_CONSENT, getConsentTexts, parseConsent, REJECT_ALL_CONSENT, serializeConsent, setDefaultConsent, updateConsent, } from './modules/consent/index.js';
|
||||||
|
|||||||
Vendored
+1
@@ -1,4 +1,5 @@
|
|||||||
export { adminOnly, adminOnlyField, adminOrEditor, adminOrEditorField, adminOrSelf, authenticated, hasMinimumRole, isAdmin, isEditor, requireRole, requireRoleField, ROLE_HIERARCHY } from './modules/access/index.js';
|
export { adminOnly, adminOnlyField, adminOrEditor, adminOrEditorField, adminOrSelf, authenticated, hasMinimumRole, isAdmin, isEditor, requireRole, requireRoleField, ROLE_HIERARCHY } from './modules/access/index.js';
|
||||||
|
export { A11Y_COOKIE, A11Y_DEFAULT, a11yAttributes, parseA11y, serializeA11y } from './modules/accessibility/index.js';
|
||||||
export { getAnalyticsConfig } from './modules/analytics/index.js';
|
export { getAnalyticsConfig } from './modules/analytics/index.js';
|
||||||
export { ACCEPT_ALL_CONSENT, CONSENT_CATEGORIES, CONSENT_COOKIE, CONSENT_MAX_AGE, CONSENT_VERSION, DEFAULT_CONSENT, getConsentTexts, parseConsent, REJECT_ALL_CONSENT, serializeConsent, setDefaultConsent, updateConsent } from './modules/consent/index.js';
|
export { ACCEPT_ALL_CONSENT, CONSENT_CATEGORIES, CONSENT_COOKIE, CONSENT_MAX_AGE, CONSENT_VERSION, DEFAULT_CONSENT, getConsentTexts, parseConsent, REJECT_ALL_CONSENT, serializeConsent, setDefaultConsent, updateConsent } from './modules/consent/index.js';
|
||||||
export { archiveFieldName, buildArchivePath, buildEntryPath, getArchiveEntries, parsePageParam, resolveRoute } from './modules/content/index.js';
|
export { archiveFieldName, buildArchivePath, buildEntryPath, getArchiveEntries, parsePageParam, resolveRoute } from './modules/content/index.js';
|
||||||
|
|||||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -0,0 +1,29 @@
|
|||||||
|
import { type A11yState } from './state.js';
|
||||||
|
type A11yContextValue = {
|
||||||
|
reset: () => void;
|
||||||
|
set: <K extends keyof A11yState>(key: K, value: A11yState[K]) => void;
|
||||||
|
state: A11yState;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Provides accessibility preferences, persists them in a cookie, and applies them
|
||||||
|
* as data-attributes on <html> so the project's CSS can react. Like
|
||||||
|
* ConsentProvider for cookies — wrap the app once; the widget/button consume it.
|
||||||
|
*
|
||||||
|
* The plugin ships NO styles: it only sets attributes (data-a11y-*). The project
|
||||||
|
* writes CSS for those it supports (see docs/accessibility.md). This keeps the
|
||||||
|
* design in the project's hands.
|
||||||
|
*
|
||||||
|
* // layout.tsx
|
||||||
|
* import { AccessibilityProvider } from '@intecion/ipal-kit/client'
|
||||||
|
* <AccessibilityProvider>{children}</AccessibilityProvider>
|
||||||
|
*
|
||||||
|
* To avoid a flash, the project can read the a11y-prefs cookie server-side and
|
||||||
|
* set the attributes on <html> during SSR (see docs). This provider re-applies
|
||||||
|
* on the client and keeps them in sync.
|
||||||
|
*/
|
||||||
|
export declare function AccessibilityProvider({ children }: {
|
||||||
|
children: React.ReactNode;
|
||||||
|
}): import("react/jsx-runtime").JSX.Element;
|
||||||
|
/** Access accessibility preferences + setters. Use inside AccessibilityProvider. */
|
||||||
|
export declare function useAccessibility(): A11yContextValue;
|
||||||
|
export {};
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
'use client';
|
||||||
|
import { jsx as _jsx } from "react/jsx-runtime";
|
||||||
|
import { createContext, use, useCallback, useEffect, useState } from 'react';
|
||||||
|
import { A11Y_COOKIE, A11Y_COOKIE_MAX_AGE, A11Y_DEFAULT, a11yAttributes, parseA11y, serializeA11y } from './state.js';
|
||||||
|
const A11yContext = /*#__PURE__*/ createContext(null);
|
||||||
|
function readCookie(name) {
|
||||||
|
if (typeof document === 'undefined') {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
const match = document.cookie.match(new RegExp(`(?:^|; )${name}=([^;]*)`));
|
||||||
|
return match ? decodeURIComponent(match[1]) : undefined;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Provides accessibility preferences, persists them in a cookie, and applies them
|
||||||
|
* as data-attributes on <html> so the project's CSS can react. Like
|
||||||
|
* ConsentProvider for cookies — wrap the app once; the widget/button consume it.
|
||||||
|
*
|
||||||
|
* The plugin ships NO styles: it only sets attributes (data-a11y-*). The project
|
||||||
|
* writes CSS for those it supports (see docs/accessibility.md). This keeps the
|
||||||
|
* design in the project's hands.
|
||||||
|
*
|
||||||
|
* // layout.tsx
|
||||||
|
* import { AccessibilityProvider } from '@intecion/ipal-kit/client'
|
||||||
|
* <AccessibilityProvider>{children}</AccessibilityProvider>
|
||||||
|
*
|
||||||
|
* To avoid a flash, the project can read the a11y-prefs cookie server-side and
|
||||||
|
* set the attributes on <html> during SSR (see docs). This provider re-applies
|
||||||
|
* on the client and keeps them in sync.
|
||||||
|
*/ export function AccessibilityProvider({ children }) {
|
||||||
|
const [state, setState] = useState(A11Y_DEFAULT);
|
||||||
|
// Hydrate from cookie on mount.
|
||||||
|
useEffect(()=>{
|
||||||
|
setState(parseA11y(readCookie(A11Y_COOKIE)));
|
||||||
|
}, []);
|
||||||
|
// Apply attributes to <html> whenever state changes.
|
||||||
|
useEffect(()=>{
|
||||||
|
const el = document.documentElement;
|
||||||
|
const attrs = a11yAttributes(state);
|
||||||
|
for (const [attr, value] of Object.entries(attrs)){
|
||||||
|
if (value === null) {
|
||||||
|
el.removeAttribute(attr);
|
||||||
|
} else {
|
||||||
|
el.setAttribute(attr, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [
|
||||||
|
state
|
||||||
|
]);
|
||||||
|
const persist = useCallback((next)=>{
|
||||||
|
document.cookie = `${A11Y_COOKIE}=${encodeURIComponent(serializeA11y(next))}; path=/; max-age=${A11Y_COOKIE_MAX_AGE}; samesite=lax`;
|
||||||
|
}, []);
|
||||||
|
const set = useCallback((key, value)=>{
|
||||||
|
setState((prev)=>{
|
||||||
|
const next = {
|
||||||
|
...prev,
|
||||||
|
[key]: value
|
||||||
|
};
|
||||||
|
persist(next);
|
||||||
|
return next;
|
||||||
|
});
|
||||||
|
}, [
|
||||||
|
persist
|
||||||
|
]);
|
||||||
|
const reset = useCallback(()=>{
|
||||||
|
setState(A11Y_DEFAULT);
|
||||||
|
persist(A11Y_DEFAULT);
|
||||||
|
}, [
|
||||||
|
persist
|
||||||
|
]);
|
||||||
|
return /*#__PURE__*/ _jsx(A11yContext, {
|
||||||
|
value: {
|
||||||
|
reset,
|
||||||
|
set,
|
||||||
|
state
|
||||||
|
},
|
||||||
|
children: children
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/** Access accessibility preferences + setters. Use inside AccessibilityProvider. */ export function useAccessibility() {
|
||||||
|
const ctx = use(A11yContext);
|
||||||
|
if (!ctx) {
|
||||||
|
throw new Error('useAccessibility must be used within <AccessibilityProvider>');
|
||||||
|
}
|
||||||
|
return ctx;
|
||||||
|
}
|
||||||
|
|
||||||
|
//# sourceMappingURL=AccessibilityProvider.js.map
|
||||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,41 @@
|
|||||||
|
export type A11yTexts = {
|
||||||
|
bigCursor?: string;
|
||||||
|
close?: string;
|
||||||
|
contrast?: string;
|
||||||
|
contrastHigh?: string;
|
||||||
|
contrastInverted?: string;
|
||||||
|
grayscale?: string;
|
||||||
|
lineHeight?: string;
|
||||||
|
open?: string;
|
||||||
|
readableFont?: string;
|
||||||
|
reduceMotion?: string;
|
||||||
|
reset?: string;
|
||||||
|
textSize?: string;
|
||||||
|
title?: string;
|
||||||
|
underlineLinks?: string;
|
||||||
|
};
|
||||||
|
export type A11yClassNames = {
|
||||||
|
active?: string;
|
||||||
|
button?: string;
|
||||||
|
closeButton?: string;
|
||||||
|
control?: string;
|
||||||
|
label?: string;
|
||||||
|
panel?: string;
|
||||||
|
resetButton?: string;
|
||||||
|
row?: string;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Accessibility toolbar: a floating button that opens a panel of options (text
|
||||||
|
* size, line height, contrast, grayscale, underline links, readable font, reduce
|
||||||
|
* motion, big cursor). Choices persist in a cookie and apply as data-attributes
|
||||||
|
* on <html> (the project's CSS styles them).
|
||||||
|
*
|
||||||
|
* Unstyled by default — pass classNames to match the project's design (like
|
||||||
|
* CookieBanner). Wrap the app in <AccessibilityProvider> first.
|
||||||
|
*
|
||||||
|
* <AccessibilityWidget classNames={{ button: 'a11y-btn', panel: 'a11y-panel' }} />
|
||||||
|
*/
|
||||||
|
export declare function AccessibilityWidget({ classNames, texts, }: {
|
||||||
|
classNames?: A11yClassNames;
|
||||||
|
texts?: A11yTexts;
|
||||||
|
}): import("react/jsx-runtime").JSX.Element;
|
||||||
+188
@@ -0,0 +1,188 @@
|
|||||||
|
'use client';
|
||||||
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
||||||
|
import { useState } from 'react';
|
||||||
|
import { useAccessibility } from './AccessibilityProvider.js';
|
||||||
|
const DEFAULT_TEXTS = {
|
||||||
|
bigCursor: 'Duży kursor',
|
||||||
|
close: 'Zamknij',
|
||||||
|
contrast: 'Kontrast',
|
||||||
|
contrastHigh: 'Wysoki',
|
||||||
|
contrastInverted: 'Odwrócony',
|
||||||
|
grayscale: 'Skala szarości',
|
||||||
|
lineHeight: 'Odstęp między liniami',
|
||||||
|
open: 'Otwórz panel dostępności',
|
||||||
|
readableFont: 'Czytelna czcionka',
|
||||||
|
reduceMotion: 'Wyłącz animacje',
|
||||||
|
reset: 'Resetuj',
|
||||||
|
textSize: 'Rozmiar tekstu',
|
||||||
|
title: 'Dostępność',
|
||||||
|
underlineLinks: 'Podkreśl linki'
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Accessibility toolbar: a floating button that opens a panel of options (text
|
||||||
|
* size, line height, contrast, grayscale, underline links, readable font, reduce
|
||||||
|
* motion, big cursor). Choices persist in a cookie and apply as data-attributes
|
||||||
|
* on <html> (the project's CSS styles them).
|
||||||
|
*
|
||||||
|
* Unstyled by default — pass classNames to match the project's design (like
|
||||||
|
* CookieBanner). Wrap the app in <AccessibilityProvider> first.
|
||||||
|
*
|
||||||
|
* <AccessibilityWidget classNames={{ button: 'a11y-btn', panel: 'a11y-panel' }} />
|
||||||
|
*/ export function AccessibilityWidget({ classNames, texts }) {
|
||||||
|
const { reset, set, state } = useAccessibility();
|
||||||
|
const [open, setOpen] = useState(false);
|
||||||
|
const t = {
|
||||||
|
...DEFAULT_TEXTS,
|
||||||
|
...texts
|
||||||
|
};
|
||||||
|
const cn = classNames ?? {};
|
||||||
|
const toggle = (key)=>set(key, !state[key]);
|
||||||
|
const isActive = (on)=>on ? cn.active ?? '' : '';
|
||||||
|
return /*#__PURE__*/ _jsxs(_Fragment, {
|
||||||
|
children: [
|
||||||
|
/*#__PURE__*/ _jsx("button", {
|
||||||
|
"aria-expanded": open,
|
||||||
|
"aria-label": t.open,
|
||||||
|
className: cn.button,
|
||||||
|
onClick: ()=>setOpen((o)=>!o),
|
||||||
|
type: "button",
|
||||||
|
children: /*#__PURE__*/ _jsx("span", {
|
||||||
|
"aria-hidden": "true",
|
||||||
|
children: "♿"
|
||||||
|
})
|
||||||
|
}),
|
||||||
|
open && /*#__PURE__*/ _jsxs("div", {
|
||||||
|
"aria-label": t.title,
|
||||||
|
className: cn.panel,
|
||||||
|
role: "dialog",
|
||||||
|
children: [
|
||||||
|
/*#__PURE__*/ _jsxs("div", {
|
||||||
|
className: cn.row,
|
||||||
|
children: [
|
||||||
|
/*#__PURE__*/ _jsx("span", {
|
||||||
|
className: cn.label,
|
||||||
|
children: t.textSize
|
||||||
|
}),
|
||||||
|
/*#__PURE__*/ _jsx("div", {
|
||||||
|
className: cn.control,
|
||||||
|
children: [
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
3
|
||||||
|
].map((n)=>/*#__PURE__*/ _jsxs("button", {
|
||||||
|
className: isActive(state.textSize === n),
|
||||||
|
onClick: ()=>set('textSize', n),
|
||||||
|
type: "button",
|
||||||
|
children: [
|
||||||
|
"A",
|
||||||
|
n > 0 ? '+'.repeat(n) : ''
|
||||||
|
]
|
||||||
|
}, n))
|
||||||
|
})
|
||||||
|
]
|
||||||
|
}),
|
||||||
|
/*#__PURE__*/ _jsxs("div", {
|
||||||
|
className: cn.row,
|
||||||
|
children: [
|
||||||
|
/*#__PURE__*/ _jsx("span", {
|
||||||
|
className: cn.label,
|
||||||
|
children: t.lineHeight
|
||||||
|
}),
|
||||||
|
/*#__PURE__*/ _jsx("div", {
|
||||||
|
className: cn.control,
|
||||||
|
children: [
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
2
|
||||||
|
].map((n)=>/*#__PURE__*/ _jsx("button", {
|
||||||
|
className: isActive(state.lineHeight === n),
|
||||||
|
onClick: ()=>set('lineHeight', n),
|
||||||
|
type: "button",
|
||||||
|
children: n === 0 ? '—' : '≡'.repeat(n)
|
||||||
|
}, n))
|
||||||
|
})
|
||||||
|
]
|
||||||
|
}),
|
||||||
|
/*#__PURE__*/ _jsxs("div", {
|
||||||
|
className: cn.row,
|
||||||
|
children: [
|
||||||
|
/*#__PURE__*/ _jsx("span", {
|
||||||
|
className: cn.label,
|
||||||
|
children: t.contrast
|
||||||
|
}),
|
||||||
|
/*#__PURE__*/ _jsxs("div", {
|
||||||
|
className: cn.control,
|
||||||
|
children: [
|
||||||
|
/*#__PURE__*/ _jsx("button", {
|
||||||
|
className: isActive(state.contrast === 'high'),
|
||||||
|
onClick: ()=>set('contrast', state.contrast === 'high' ? 'default' : 'high'),
|
||||||
|
type: "button",
|
||||||
|
children: t.contrastHigh
|
||||||
|
}),
|
||||||
|
/*#__PURE__*/ _jsx("button", {
|
||||||
|
className: isActive(state.contrast === 'inverted'),
|
||||||
|
onClick: ()=>set('contrast', state.contrast === 'inverted' ? 'default' : 'inverted'),
|
||||||
|
type: "button",
|
||||||
|
children: t.contrastInverted
|
||||||
|
})
|
||||||
|
]
|
||||||
|
})
|
||||||
|
]
|
||||||
|
}),
|
||||||
|
[
|
||||||
|
[
|
||||||
|
'grayscale',
|
||||||
|
t.grayscale
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'underlineLinks',
|
||||||
|
t.underlineLinks
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'readableFont',
|
||||||
|
t.readableFont
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'reduceMotion',
|
||||||
|
t.reduceMotion
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'bigCursor',
|
||||||
|
t.bigCursor
|
||||||
|
]
|
||||||
|
].map(([key, label])=>/*#__PURE__*/ _jsxs("div", {
|
||||||
|
className: cn.row,
|
||||||
|
children: [
|
||||||
|
/*#__PURE__*/ _jsx("span", {
|
||||||
|
className: cn.label,
|
||||||
|
children: label
|
||||||
|
}),
|
||||||
|
/*#__PURE__*/ _jsx("button", {
|
||||||
|
"aria-pressed": Boolean(state[key]),
|
||||||
|
className: `${cn.control ?? ''} ${isActive(Boolean(state[key]))}`,
|
||||||
|
onClick: ()=>toggle(key),
|
||||||
|
type: "button",
|
||||||
|
children: state[key] ? 'ON' : 'OFF'
|
||||||
|
})
|
||||||
|
]
|
||||||
|
}, key)),
|
||||||
|
/*#__PURE__*/ _jsx("button", {
|
||||||
|
className: cn.resetButton,
|
||||||
|
onClick: reset,
|
||||||
|
type: "button",
|
||||||
|
children: t.reset
|
||||||
|
}),
|
||||||
|
/*#__PURE__*/ _jsx("button", {
|
||||||
|
className: cn.closeButton,
|
||||||
|
onClick: ()=>setOpen(false),
|
||||||
|
type: "button",
|
||||||
|
children: t.close
|
||||||
|
})
|
||||||
|
]
|
||||||
|
})
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//# sourceMappingURL=AccessibilityWidget.js.map
|
||||||
File diff suppressed because one or more lines are too long
+5
@@ -0,0 +1,5 @@
|
|||||||
|
export { AccessibilityProvider, useAccessibility } from './AccessibilityProvider.js';
|
||||||
|
export { AccessibilityWidget } from './AccessibilityWidget.js';
|
||||||
|
export type { A11yClassNames, A11yTexts } from './AccessibilityWidget.js';
|
||||||
|
export type { A11yState } from './state.js';
|
||||||
|
export { A11Y_COOKIE, a11yAttributes, parseA11y } from './state.js';
|
||||||
Vendored
+6
@@ -0,0 +1,6 @@
|
|||||||
|
'use client';
|
||||||
|
export { AccessibilityProvider, useAccessibility } from './AccessibilityProvider.js';
|
||||||
|
export { AccessibilityWidget } from './AccessibilityWidget.js';
|
||||||
|
export { A11Y_COOKIE, a11yAttributes, parseA11y } from './state.js';
|
||||||
|
|
||||||
|
//# sourceMappingURL=client.js.map
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"sources":["../../../src/modules/accessibility/client.ts"],"sourcesContent":["'use client'\nexport { AccessibilityProvider, useAccessibility } from './AccessibilityProvider.js'\nexport { AccessibilityWidget } from './AccessibilityWidget.js'\nexport type { A11yClassNames, A11yTexts } from './AccessibilityWidget.js'\nexport type { A11yState } from './state.js'\nexport { A11Y_COOKIE, a11yAttributes, parseA11y } from './state.js'\n"],"names":["AccessibilityProvider","useAccessibility","AccessibilityWidget","A11Y_COOKIE","a11yAttributes","parseA11y"],"mappings":"AAAA;AACA,SAASA,qBAAqB,EAAEC,gBAAgB,QAAQ,6BAA4B;AACpF,SAASC,mBAAmB,QAAQ,2BAA0B;AAG9D,SAASC,WAAW,EAAEC,cAAc,EAAEC,SAAS,QAAQ,aAAY"}
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
export { AccessibilityProvider, useAccessibility } from './AccessibilityProvider.js';
|
||||||
|
export { AccessibilityWidget } from './AccessibilityWidget.js';
|
||||||
|
export type { A11yClassNames, A11yTexts } from './AccessibilityWidget.js';
|
||||||
|
export { A11Y_COOKIE, A11Y_COOKIE_MAX_AGE, A11Y_DEFAULT, a11yAttributes, parseA11y, serializeA11y, } from './state.js';
|
||||||
|
export type { A11yState } from './state.js';
|
||||||
Vendored
+5
@@ -0,0 +1,5 @@
|
|||||||
|
export { AccessibilityProvider, useAccessibility } from './AccessibilityProvider.js';
|
||||||
|
export { AccessibilityWidget } from './AccessibilityWidget.js';
|
||||||
|
export { A11Y_COOKIE, A11Y_COOKIE_MAX_AGE, A11Y_DEFAULT, a11yAttributes, parseA11y, serializeA11y } from './state.js';
|
||||||
|
|
||||||
|
//# sourceMappingURL=index.js.map
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"sources":["../../../src/modules/accessibility/index.ts"],"sourcesContent":["export { AccessibilityProvider, useAccessibility } from './AccessibilityProvider.js'\nexport { AccessibilityWidget } from './AccessibilityWidget.js'\nexport type { A11yClassNames, A11yTexts } from './AccessibilityWidget.js'\nexport {\n A11Y_COOKIE,\n A11Y_COOKIE_MAX_AGE,\n A11Y_DEFAULT,\n a11yAttributes,\n parseA11y,\n serializeA11y,\n} from './state.js'\nexport type { A11yState } from './state.js'\n"],"names":["AccessibilityProvider","useAccessibility","AccessibilityWidget","A11Y_COOKIE","A11Y_COOKIE_MAX_AGE","A11Y_DEFAULT","a11yAttributes","parseA11y","serializeA11y"],"mappings":"AAAA,SAASA,qBAAqB,EAAEC,gBAAgB,QAAQ,6BAA4B;AACpF,SAASC,mBAAmB,QAAQ,2BAA0B;AAE9D,SACEC,WAAW,EACXC,mBAAmB,EACnBC,YAAY,EACZC,cAAc,EACdC,SAAS,EACTC,aAAa,QACR,aAAY"}
|
||||||
+37
@@ -0,0 +1,37 @@
|
|||||||
|
/**
|
||||||
|
* Accessibility preferences state. Each option maps to a data-attribute on
|
||||||
|
* <html> (e.g. data-a11y-contrast="high"); the PROJECT's CSS reacts to those
|
||||||
|
* attributes. The plugin sets the attributes and persists the choice — it does
|
||||||
|
* NOT ship styles, so it never fights the project's design.
|
||||||
|
*/
|
||||||
|
export type A11yState = {
|
||||||
|
/** Larger cursor. */
|
||||||
|
bigCursor: boolean;
|
||||||
|
/** 'default' | 'high' (high contrast) | 'inverted' (dark-on-light flip). */
|
||||||
|
contrast: 'default' | 'high' | 'inverted';
|
||||||
|
/** Grayscale filter on the whole page. */
|
||||||
|
grayscale: boolean;
|
||||||
|
/** Line spacing: 0 = default, 1..2 = looser. */
|
||||||
|
lineHeight: 0 | 1 | 2;
|
||||||
|
/** Readable font (project maps this to a dyslexia-friendly / simple font). */
|
||||||
|
readableFont: boolean;
|
||||||
|
/** Stop animations / transitions (prefers-reduced-motion equivalent). */
|
||||||
|
reduceMotion: boolean;
|
||||||
|
/** Text size step: 0 = default, 1..3 = larger. */
|
||||||
|
textSize: 0 | 1 | 2 | 3;
|
||||||
|
/** Underline all links (WCAG: don't rely on color alone). */
|
||||||
|
underlineLinks: boolean;
|
||||||
|
};
|
||||||
|
export declare const A11Y_DEFAULT: A11yState;
|
||||||
|
export declare const A11Y_COOKIE = "a11y-prefs";
|
||||||
|
export declare const A11Y_COOKIE_MAX_AGE: number;
|
||||||
|
/** Serialize for the cookie (compact). */
|
||||||
|
export declare function serializeA11y(state: A11yState): string;
|
||||||
|
/** Parse from the cookie; falls back to defaults on any bad value. */
|
||||||
|
export declare function parseA11y(raw: null | string | undefined): A11yState;
|
||||||
|
/**
|
||||||
|
* Maps state → data-attributes to set on <html>. Returns { attr: value|null };
|
||||||
|
* null means remove the attribute (option is at default). The project's CSS
|
||||||
|
* targets these, e.g. `[data-a11y-contrast="high"] { … }`.
|
||||||
|
*/
|
||||||
|
export declare function a11yAttributes(state: A11yState): Record<string, null | string>;
|
||||||
Vendored
+53
@@ -0,0 +1,53 @@
|
|||||||
|
/**
|
||||||
|
* Accessibility preferences state. Each option maps to a data-attribute on
|
||||||
|
* <html> (e.g. data-a11y-contrast="high"); the PROJECT's CSS reacts to those
|
||||||
|
* attributes. The plugin sets the attributes and persists the choice — it does
|
||||||
|
* NOT ship styles, so it never fights the project's design.
|
||||||
|
*/ export const A11Y_DEFAULT = {
|
||||||
|
bigCursor: false,
|
||||||
|
contrast: 'default',
|
||||||
|
grayscale: false,
|
||||||
|
lineHeight: 0,
|
||||||
|
readableFont: false,
|
||||||
|
reduceMotion: false,
|
||||||
|
textSize: 0,
|
||||||
|
underlineLinks: false
|
||||||
|
};
|
||||||
|
export const A11Y_COOKIE = 'a11y-prefs';
|
||||||
|
export const A11Y_COOKIE_MAX_AGE = 60 * 60 * 24 * 365 // 1 year
|
||||||
|
;
|
||||||
|
/** Serialize for the cookie (compact). */ export function serializeA11y(state) {
|
||||||
|
return JSON.stringify(state);
|
||||||
|
}
|
||||||
|
/** Parse from the cookie; falls back to defaults on any bad value. */ export function parseA11y(raw) {
|
||||||
|
if (!raw) {
|
||||||
|
return A11Y_DEFAULT;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const parsed = JSON.parse(raw);
|
||||||
|
return {
|
||||||
|
...A11Y_DEFAULT,
|
||||||
|
...parsed
|
||||||
|
};
|
||||||
|
} catch {
|
||||||
|
return A11Y_DEFAULT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Maps state → data-attributes to set on <html>. Returns { attr: value|null };
|
||||||
|
* null means remove the attribute (option is at default). The project's CSS
|
||||||
|
* targets these, e.g. `[data-a11y-contrast="high"] { … }`.
|
||||||
|
*/ export function a11yAttributes(state) {
|
||||||
|
return {
|
||||||
|
'data-a11y-contrast': state.contrast !== 'default' ? state.contrast : null,
|
||||||
|
'data-a11y-cursor': state.bigCursor ? 'big' : null,
|
||||||
|
'data-a11y-font': state.readableFont ? 'readable' : null,
|
||||||
|
'data-a11y-grayscale': state.grayscale ? 'on' : null,
|
||||||
|
'data-a11y-line': state.lineHeight > 0 ? String(state.lineHeight) : null,
|
||||||
|
'data-a11y-motion': state.reduceMotion ? 'reduce' : null,
|
||||||
|
'data-a11y-text': state.textSize > 0 ? String(state.textSize) : null,
|
||||||
|
'data-a11y-underline': state.underlineLinks ? 'on' : null
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
//# sourceMappingURL=state.js.map
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"sources":["../../../src/modules/accessibility/state.ts"],"sourcesContent":["/**\n * Accessibility preferences state. Each option maps to a data-attribute on\n * <html> (e.g. data-a11y-contrast=\"high\"); the PROJECT's CSS reacts to those\n * attributes. The plugin sets the attributes and persists the choice — it does\n * NOT ship styles, so it never fights the project's design.\n */\nexport type A11yState = {\n /** Larger cursor. */\n bigCursor: boolean\n /** 'default' | 'high' (high contrast) | 'inverted' (dark-on-light flip). */\n contrast: 'default' | 'high' | 'inverted'\n /** Grayscale filter on the whole page. */\n grayscale: boolean\n /** Line spacing: 0 = default, 1..2 = looser. */\n lineHeight: 0 | 1 | 2\n /** Readable font (project maps this to a dyslexia-friendly / simple font). */\n readableFont: boolean\n /** Stop animations / transitions (prefers-reduced-motion equivalent). */\n reduceMotion: boolean\n /** Text size step: 0 = default, 1..3 = larger. */\n textSize: 0 | 1 | 2 | 3\n /** Underline all links (WCAG: don't rely on color alone). */\n underlineLinks: boolean\n}\n\nexport const A11Y_DEFAULT: A11yState = {\n bigCursor: false,\n contrast: 'default',\n grayscale: false,\n lineHeight: 0,\n readableFont: false,\n reduceMotion: false,\n textSize: 0,\n underlineLinks: false,\n}\n\nexport const A11Y_COOKIE = 'a11y-prefs'\nexport const A11Y_COOKIE_MAX_AGE = 60 * 60 * 24 * 365 // 1 year\n\n/** Serialize for the cookie (compact). */\nexport function serializeA11y(state: A11yState): string {\n return JSON.stringify(state)\n}\n\n/** Parse from the cookie; falls back to defaults on any bad value. */\nexport function parseA11y(raw: null | string | undefined): A11yState {\n if (!raw) {return A11Y_DEFAULT}\n try {\n const parsed = JSON.parse(raw) as Partial<A11yState>\n return { ...A11Y_DEFAULT, ...parsed }\n } catch {\n return A11Y_DEFAULT\n }\n}\n\n/**\n * Maps state → data-attributes to set on <html>. Returns { attr: value|null };\n * null means remove the attribute (option is at default). The project's CSS\n * targets these, e.g. `[data-a11y-contrast=\"high\"] { … }`.\n */\nexport function a11yAttributes(state: A11yState): Record<string, null | string> {\n return {\n 'data-a11y-contrast': state.contrast !== 'default' ? state.contrast : null,\n 'data-a11y-cursor': state.bigCursor ? 'big' : null,\n 'data-a11y-font': state.readableFont ? 'readable' : null,\n 'data-a11y-grayscale': state.grayscale ? 'on' : null,\n 'data-a11y-line': state.lineHeight > 0 ? String(state.lineHeight) : null,\n 'data-a11y-motion': state.reduceMotion ? 'reduce' : null,\n 'data-a11y-text': state.textSize > 0 ? String(state.textSize) : null,\n 'data-a11y-underline': state.underlineLinks ? 'on' : null,\n }\n}\n"],"names":["A11Y_DEFAULT","bigCursor","contrast","grayscale","lineHeight","readableFont","reduceMotion","textSize","underlineLinks","A11Y_COOKIE","A11Y_COOKIE_MAX_AGE","serializeA11y","state","JSON","stringify","parseA11y","raw","parsed","parse","a11yAttributes","String"],"mappings":"AAAA;;;;;CAKC,GAoBD,OAAO,MAAMA,eAA0B;IACrCC,WAAW;IACXC,UAAU;IACVC,WAAW;IACXC,YAAY;IACZC,cAAc;IACdC,cAAc;IACdC,UAAU;IACVC,gBAAgB;AAClB,EAAC;AAED,OAAO,MAAMC,cAAc,aAAY;AACvC,OAAO,MAAMC,sBAAsB,KAAK,KAAK,KAAK,IAAI,SAAS;CAAV;AAErD,wCAAwC,GACxC,OAAO,SAASC,cAAcC,KAAgB;IAC5C,OAAOC,KAAKC,SAAS,CAACF;AACxB;AAEA,oEAAoE,GACpE,OAAO,SAASG,UAAUC,GAA8B;IACtD,IAAI,CAACA,KAAK;QAAC,OAAOhB;IAAY;IAC9B,IAAI;QACF,MAAMiB,SAASJ,KAAKK,KAAK,CAACF;QAC1B,OAAO;YAAE,GAAGhB,YAAY;YAAE,GAAGiB,MAAM;QAAC;IACtC,EAAE,OAAM;QACN,OAAOjB;IACT;AACF;AAEA;;;;CAIC,GACD,OAAO,SAASmB,eAAeP,KAAgB;IAC7C,OAAO;QACL,sBAAsBA,MAAMV,QAAQ,KAAK,YAAYU,MAAMV,QAAQ,GAAG;QACtE,oBAAoBU,MAAMX,SAAS,GAAG,QAAQ;QAC9C,kBAAkBW,MAAMP,YAAY,GAAG,aAAa;QACpD,uBAAuBO,MAAMT,SAAS,GAAG,OAAO;QAChD,kBAAkBS,MAAMR,UAAU,GAAG,IAAIgB,OAAOR,MAAMR,UAAU,IAAI;QACpE,oBAAoBQ,MAAMN,YAAY,GAAG,WAAW;QACpD,kBAAkBM,MAAML,QAAQ,GAAG,IAAIa,OAAOR,MAAML,QAAQ,IAAI;QAChE,uBAAuBK,MAAMJ,cAAc,GAAG,OAAO;IACvD;AACF"}
|
||||||
+29
-17
@@ -1,33 +1,45 @@
|
|||||||
import type { SitemapEntry } from './buildSitemapEntries.js';
|
import type { SitemapEntry } from './buildSitemapEntries.js';
|
||||||
|
type BuildSitemapXmlOptions = {
|
||||||
|
/**
|
||||||
|
* URL of a CSS stylesheet to make the sitemap readable in the browser, e.g.
|
||||||
|
* '/sitemap.css'. Uses `type="text/css"` — the W3C "Associating Style Sheets
|
||||||
|
* with XML" mechanism, which is NOT deprecated (unlike XSLT / type="text/xsl",
|
||||||
|
* which Chrome/WebKit are removing). CSS on XML shows no warning, styles the
|
||||||
|
* raw tags directly (e.g. `url { display: block }` turns the wall of text into
|
||||||
|
* cards), and crawlers ignore the directive entirely.
|
||||||
|
*/
|
||||||
|
cssUrl?: string;
|
||||||
|
};
|
||||||
/**
|
/**
|
||||||
* Serializes sitemap entries to an XML STRING with an XSL stylesheet reference,
|
* Serializes sitemap entries to a clean, indented XML STRING — valid for crawlers
|
||||||
* so /sitemap.xml renders as a readable table in the browser (not raw XML) while
|
* and (with `cssUrl`) styled in the browser via plain CSS.
|
||||||
* staying a valid sitemap for crawlers.
|
|
||||||
*
|
*
|
||||||
* Why this exists alongside the Next MetadataRoute sitemap: Next's app/sitemap.ts
|
* Two viewing modes:
|
||||||
* (returning SitemapEntry[]) does NOT let you inject <?xml-stylesheet?>. To get
|
* - No cssUrl → the browser's native formatted XML tree (indented, collapsible).
|
||||||
* the styled table, serve a custom route that returns this string instead:
|
* - With cssUrl → a `<?xml-stylesheet type="text/css">` directive; the project's
|
||||||
|
* CSS styles the XML tags (cards, labels via ::before). NOT XSLT — that's being
|
||||||
|
* removed from browsers and shows a deprecation warning. CSS is safe and
|
||||||
|
* W3C-standard.
|
||||||
*
|
*
|
||||||
* // app/sitemap.xml/route.ts
|
* // app/sitemap.xml/route.ts
|
||||||
* import { buildSitemapXml } from '@intecion/ipal-kit'
|
* import { buildSitemapXml } from '@intecion/ipal-kit'
|
||||||
* import { sitemap } from '@/lib/content' // your entries source
|
* import { sitemap } from '@/lib/content'
|
||||||
* export const dynamic = 'force-dynamic'
|
* export const dynamic = 'force-dynamic'
|
||||||
* export async function GET() {
|
* export async function GET() {
|
||||||
* const entries = await sitemap()
|
* const entries = await sitemap()
|
||||||
* const xml = buildSitemapXml(entries, { stylesheetUrl: '/sitemap.xsl' })
|
* const xml = buildSitemapXml(entries, { cssUrl: '/sitemap.css' })
|
||||||
* return new Response(xml, {
|
* return new Response(xml, {
|
||||||
* headers: { 'Content-Type': 'application/xml; charset=utf-8' },
|
* headers: { 'Content-Type': 'application/xml; charset=utf-8' },
|
||||||
* })
|
* })
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* Put sitemap.xsl in the project's /public (copy from the plugin's assets, or
|
* Put sitemap.css in the project's /public and style the tags (see docs/seo.md
|
||||||
* serve it from a route). The <?xml-stylesheet?> points browsers at it; crawlers
|
* for a starter). Note: <loc> is an XML tag, not <a href> — CSS can't make it a
|
||||||
* ignore it and read the XML. Include hreflang alternates as <xhtml:link>.
|
* clickable link (some browsers auto-detect URLs); the win is readability, not
|
||||||
|
* clickability.
|
||||||
*
|
*
|
||||||
* NOTE: if you use this custom route, DON'T also keep app/sitemap.ts — pick one
|
* NOTE: if you use this custom route, DON'T also keep app/sitemap.ts — pick one.
|
||||||
* (the styled route OR the Next MetadataRoute). Two sitemaps at different paths
|
* Two sitemaps confuse crawlers.
|
||||||
* confuse crawlers.
|
|
||||||
*/
|
*/
|
||||||
export declare function buildSitemapXml(entries: SitemapEntry[], opts?: {
|
export declare function buildSitemapXml(entries: SitemapEntry[], opts?: BuildSitemapXmlOptions): string;
|
||||||
stylesheetUrl?: string;
|
export {};
|
||||||
}): string;
|
|
||||||
|
|||||||
Vendored
+18
-17
@@ -1,33 +1,35 @@
|
|||||||
/**
|
/**
|
||||||
* Serializes sitemap entries to an XML STRING with an XSL stylesheet reference,
|
* Serializes sitemap entries to a clean, indented XML STRING — valid for crawlers
|
||||||
* so /sitemap.xml renders as a readable table in the browser (not raw XML) while
|
* and (with `cssUrl`) styled in the browser via plain CSS.
|
||||||
* staying a valid sitemap for crawlers.
|
|
||||||
*
|
*
|
||||||
* Why this exists alongside the Next MetadataRoute sitemap: Next's app/sitemap.ts
|
* Two viewing modes:
|
||||||
* (returning SitemapEntry[]) does NOT let you inject <?xml-stylesheet?>. To get
|
* - No cssUrl → the browser's native formatted XML tree (indented, collapsible).
|
||||||
* the styled table, serve a custom route that returns this string instead:
|
* - With cssUrl → a `<?xml-stylesheet type="text/css">` directive; the project's
|
||||||
|
* CSS styles the XML tags (cards, labels via ::before). NOT XSLT — that's being
|
||||||
|
* removed from browsers and shows a deprecation warning. CSS is safe and
|
||||||
|
* W3C-standard.
|
||||||
*
|
*
|
||||||
* // app/sitemap.xml/route.ts
|
* // app/sitemap.xml/route.ts
|
||||||
* import { buildSitemapXml } from '@intecion/ipal-kit'
|
* import { buildSitemapXml } from '@intecion/ipal-kit'
|
||||||
* import { sitemap } from '@/lib/content' // your entries source
|
* import { sitemap } from '@/lib/content'
|
||||||
* export const dynamic = 'force-dynamic'
|
* export const dynamic = 'force-dynamic'
|
||||||
* export async function GET() {
|
* export async function GET() {
|
||||||
* const entries = await sitemap()
|
* const entries = await sitemap()
|
||||||
* const xml = buildSitemapXml(entries, { stylesheetUrl: '/sitemap.xsl' })
|
* const xml = buildSitemapXml(entries, { cssUrl: '/sitemap.css' })
|
||||||
* return new Response(xml, {
|
* return new Response(xml, {
|
||||||
* headers: { 'Content-Type': 'application/xml; charset=utf-8' },
|
* headers: { 'Content-Type': 'application/xml; charset=utf-8' },
|
||||||
* })
|
* })
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* Put sitemap.xsl in the project's /public (copy from the plugin's assets, or
|
* Put sitemap.css in the project's /public and style the tags (see docs/seo.md
|
||||||
* serve it from a route). The <?xml-stylesheet?> points browsers at it; crawlers
|
* for a starter). Note: <loc> is an XML tag, not <a href> — CSS can't make it a
|
||||||
* ignore it and read the XML. Include hreflang alternates as <xhtml:link>.
|
* clickable link (some browsers auto-detect URLs); the win is readability, not
|
||||||
|
* clickability.
|
||||||
*
|
*
|
||||||
* NOTE: if you use this custom route, DON'T also keep app/sitemap.ts — pick one
|
* NOTE: if you use this custom route, DON'T also keep app/sitemap.ts — pick one.
|
||||||
* (the styled route OR the Next MetadataRoute). Two sitemaps at different paths
|
* Two sitemaps confuse crawlers.
|
||||||
* confuse crawlers.
|
|
||||||
*/ export function buildSitemapXml(entries, opts = {}) {
|
*/ export function buildSitemapXml(entries, opts = {}) {
|
||||||
const { stylesheetUrl } = opts;
|
const { cssUrl } = opts;
|
||||||
const esc = (s)=>s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''');
|
const esc = (s)=>s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''');
|
||||||
const urls = entries.map((e)=>{
|
const urls = entries.map((e)=>{
|
||||||
const parts = [
|
const parts = [
|
||||||
@@ -39,7 +41,6 @@
|
|||||||
}
|
}
|
||||||
if (e.changeFrequency) parts.push(` <changefreq>${e.changeFrequency}</changefreq>`);
|
if (e.changeFrequency) parts.push(` <changefreq>${e.changeFrequency}</changefreq>`);
|
||||||
if (typeof e.priority === 'number') parts.push(` <priority>${e.priority}</priority>`);
|
if (typeof e.priority === 'number') parts.push(` <priority>${e.priority}</priority>`);
|
||||||
// hreflang alternates
|
|
||||||
const alternates = e.alternates?.languages;
|
const alternates = e.alternates?.languages;
|
||||||
if (alternates) {
|
if (alternates) {
|
||||||
for (const [lang, href] of Object.entries(alternates)){
|
for (const [lang, href] of Object.entries(alternates)){
|
||||||
@@ -50,7 +51,7 @@
|
|||||||
}
|
}
|
||||||
return ` <url>\n${parts.join('\n')}\n </url>`;
|
return ` <url>\n${parts.join('\n')}\n </url>`;
|
||||||
}).join('\n');
|
}).join('\n');
|
||||||
const stylesheet = stylesheetUrl ? `<?xml-stylesheet type="text/xsl" href="${esc(stylesheetUrl)}"?>\n` : '';
|
const stylesheet = cssUrl ? `<?xml-stylesheet type="text/css" href="${esc(cssUrl)}"?>\n` : '';
|
||||||
return `<?xml version="1.0" encoding="UTF-8"?>\n` + stylesheet + `<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" ` + `xmlns:xhtml="http://www.w3.org/1999/xhtml">\n` + urls + `\n</urlset>`;
|
return `<?xml version="1.0" encoding="UTF-8"?>\n` + stylesheet + `<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" ` + `xmlns:xhtml="http://www.w3.org/1999/xhtml">\n` + urls + `\n</urlset>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
@@ -0,0 +1,171 @@
|
|||||||
|
# Dostępność — widget a11y (WCAG)
|
||||||
|
|
||||||
|
Widget dostępności: pływający przycisk otwierający panel z opcjami dla osób z
|
||||||
|
niepełnosprawnościami (rozmiar tekstu, kontrast, skala szarości, podkreślone
|
||||||
|
linki, czytelna czcionka, wyłączenie animacji, duży kursor).
|
||||||
|
|
||||||
|
> **OPCJONALNY — nie dodawaj domyślnie.** Widget a11y jest wymagany prawnie
|
||||||
|
> TYLKO dla niektórych stron (podmioty publiczne, część e-commerce/usług objętych
|
||||||
|
> European Accessibility Act). Dla większości stron komercyjnych to OPCJA, nie
|
||||||
|
> obowiązek. Dodawaj GDY klient/projekt tego wymaga — nie na każdej stronie z
|
||||||
|
> automatu. W razie wątpliwości: zapytaj, czy strona podlega wymogom dostępności.
|
||||||
|
|
||||||
|
Wzorzec jak CookieBanner: provider + widget, wpinasz raz. Preferencje w cookie
|
||||||
|
(bez flash), stosowane jako atrybuty `data-a11y-*` na `<html>`.
|
||||||
|
|
||||||
|
> **Granica plugin/projekt:** plugin dostarcza MECHANIZM (widget, stan, cookie,
|
||||||
|
> atrybuty na html). Projekt dostarcza CSS reagujący na atrybuty — bo style
|
||||||
|
> zależą od designu projektu (kolory, czcionki, Tailwind). Plugin NIE narzuca
|
||||||
|
> stylów, żeby nie kolidować. Gotowy CSS do skopiowania niżej.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 1. Wpięcie — Provider + Widget
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
// app/(frontend)/[locale]/layout.tsx
|
||||||
|
import { AccessibilityProvider, AccessibilityWidget } from '@intecion/ipal-kit/client'
|
||||||
|
|
||||||
|
<AccessibilityProvider>
|
||||||
|
<body>
|
||||||
|
{children}
|
||||||
|
<AccessibilityWidget
|
||||||
|
classNames={{
|
||||||
|
button: 'a11y-button',
|
||||||
|
panel: 'a11y-panel',
|
||||||
|
row: 'a11y-row',
|
||||||
|
label: 'a11y-label',
|
||||||
|
control: 'a11y-control',
|
||||||
|
active: 'a11y-active',
|
||||||
|
resetButton: 'a11y-reset',
|
||||||
|
closeButton: 'a11y-close',
|
||||||
|
}}
|
||||||
|
texts={{ title: 'Dostępność', reset: 'Resetuj' }} // opcjonalne, PL domyślnie
|
||||||
|
/>
|
||||||
|
</body>
|
||||||
|
</AccessibilityProvider>
|
||||||
|
```
|
||||||
|
|
||||||
|
Widget jest bez stylów (jak CookieBanner) — classNames dopasowujesz do designu.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 2. CSS reagujący na atrybuty (OBOWIĄZKOWE — projekt)
|
||||||
|
|
||||||
|
Widget ustawia atrybuty na `<html>`. Bez tego CSS nic się nie dzieje. Skopiuj do
|
||||||
|
globalnego CSS projektu (dostosuj do designu):
|
||||||
|
|
||||||
|
```css
|
||||||
|
/* Rozmiar tekstu */
|
||||||
|
html[data-a11y-text="1"] { font-size: 112.5%; }
|
||||||
|
html[data-a11y-text="2"] { font-size: 125%; }
|
||||||
|
html[data-a11y-text="3"] { font-size: 150%; }
|
||||||
|
|
||||||
|
/* Odstęp między liniami */
|
||||||
|
html[data-a11y-line="1"] * { line-height: 1.8 !important; }
|
||||||
|
html[data-a11y-line="2"] * { line-height: 2.2 !important; }
|
||||||
|
|
||||||
|
/* Kontrast wysoki */
|
||||||
|
html[data-a11y-contrast="high"] {
|
||||||
|
filter: contrast(1.4);
|
||||||
|
}
|
||||||
|
/* Kontrast odwrócony */
|
||||||
|
html[data-a11y-contrast="inverted"] {
|
||||||
|
filter: invert(1) hue-rotate(180deg);
|
||||||
|
}
|
||||||
|
html[data-a11y-contrast="inverted"] img,
|
||||||
|
html[data-a11y-contrast="inverted"] video {
|
||||||
|
filter: invert(1) hue-rotate(180deg); /* przywróć media */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Skala szarości */
|
||||||
|
html[data-a11y-grayscale="on"] { filter: grayscale(1); }
|
||||||
|
/* Uwaga: filter na html nie kumuluje się — jeśli łączysz kontrast+szarość,
|
||||||
|
zastosuj na body albo połącz w jednej regule. */
|
||||||
|
|
||||||
|
/* Podkreślone linki */
|
||||||
|
html[data-a11y-underline="on"] a { text-decoration: underline !important; }
|
||||||
|
|
||||||
|
/* Czytelna czcionka (podmień na swoją dyslexia-friendly / prostą) */
|
||||||
|
html[data-a11y-font="readable"] * {
|
||||||
|
font-family: Verdana, Tahoma, sans-serif !important;
|
||||||
|
letter-spacing: 0.02em;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Wyłączenie animacji */
|
||||||
|
html[data-a11y-motion="reduce"] *,
|
||||||
|
html[data-a11y-motion="reduce"] *::before,
|
||||||
|
html[data-a11y-motion="reduce"] *::after {
|
||||||
|
animation-duration: 0.001ms !important;
|
||||||
|
transition-duration: 0.001ms !important;
|
||||||
|
scroll-behavior: auto !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Duży kursor */
|
||||||
|
html[data-a11y-cursor="big"] * {
|
||||||
|
cursor: url('/cursors/big.svg') 4 4, auto !important;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Dostosuj wartości do projektu (kolory kontrastu, czcionka, kursor). To Twój CSS —
|
||||||
|
plugin tylko ustawia atrybuty.
|
||||||
|
|
||||||
|
> **Kontrast + filter:** wiele opcji używa `filter` na `<html>`. CSS `filter` na
|
||||||
|
> jednym elemencie NIE kumuluje wielu wartości z różnych reguł — ostatnia wygrywa.
|
||||||
|
> Jeśli chcesz łączyć (np. szarość + kontrast), zastosuj filtry na `body` z
|
||||||
|
> pełną wartością, albo zbuduj reguły kombinowane. Dla pojedynczych opcji działa
|
||||||
|
> bez problemu.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 3. Bez flash (SSR) — opcjonalne
|
||||||
|
|
||||||
|
Domyślnie widget stosuje atrybuty po hydratacji (krótki flash przy ładowaniu,
|
||||||
|
jeśli użytkownik miał ustawienia). Żeby tego uniknąć, odczytaj cookie server-side
|
||||||
|
i ustaw atrybuty na `<html>` w SSR:
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
// layout.tsx (server) — odczytaj cookie i ustaw atrybuty od razu
|
||||||
|
import { cookies } from 'next/headers'
|
||||||
|
import { A11Y_COOKIE, parseA11y, a11yAttributes } from '@intecion/ipal-kit'
|
||||||
|
|
||||||
|
const raw = (await cookies()).get(A11Y_COOKIE)?.value
|
||||||
|
const attrs = a11yAttributes(parseA11y(raw))
|
||||||
|
const htmlAttrs = Object.fromEntries(
|
||||||
|
Object.entries(attrs).filter(([, v]) => v !== null),
|
||||||
|
)
|
||||||
|
|
||||||
|
return <html lang={locale} {...htmlAttrs}>...</html>
|
||||||
|
```
|
||||||
|
|
||||||
|
Provider i tak re-aplikuje na kliencie i synchronizuje. To tylko eliminuje flash.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 4. Osobny przycisk otwierający (opcjonalnie)
|
||||||
|
|
||||||
|
Widget ma wbudowany pływający przycisk. Jeśli chcesz otwierać panel z innego
|
||||||
|
miejsca (np. stopka „Dostępność"), użyj hooka:
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
'use client'
|
||||||
|
import { useAccessibility } from '@intecion/ipal-kit/client'
|
||||||
|
// stan otwarcia trzymaj sam, albo rozbuduj widget — hook daje state/set/reset
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 5. Compliance — kiedy dostępność jest wymagana
|
||||||
|
|
||||||
|
Dostępność (WCAG) jest wymagana prawnie TYLKO dla części stron:
|
||||||
|
- **Podmioty publiczne** (urzędy, szkoły, instytucje) — ustawa o dostępności cyfrowej
|
||||||
|
- **Duże e-commerce / usługi** objęte European Accessibility Act (2019/882, od 2025)
|
||||||
|
- Strony, gdzie klient sam tego wymaga (polityka firmy, przetarg)
|
||||||
|
|
||||||
|
Dla **większości stron komercyjnych** (wizytówka, mała firma, katalog) widget a11y
|
||||||
|
to **opcja, nie obowiązek** — dodawaj gdy klient wymaga, nie z automatu.
|
||||||
|
|
||||||
|
Gdy dodajesz: widget sam w sobie NIE czyni strony w pełni dostępną — to pomoc dla
|
||||||
|
użytkownika. Pełna dostępność to też semantyczny HTML, alt teksty, nawigacja
|
||||||
|
klawiaturą, kontrast bazowy. Widget uzupełnia, nie zastępuje. Nie sprzedawaj
|
||||||
|
klientowi „mamy widget = jesteśmy zgodni z WCAG". Patrz wymagania-prawne.md.
|
||||||
+188
-139
@@ -19,14 +19,14 @@ admina i bez importMap się nie wyrenderują.
|
|||||||
|
|
||||||
```ts
|
```ts
|
||||||
ipalKit({
|
ipalKit({
|
||||||
seo: {
|
seo: {
|
||||||
collections: ['pages', 'posts'], // które kolekcje dostają meta
|
collections: ['pages', 'posts'], // które kolekcje dostają meta
|
||||||
// generateTitle: ({ doc }) => `${doc.title}`, // opcjonalne
|
// generateTitle: ({ doc }) => `${doc.title}`, // opcjonalne
|
||||||
// generateDescription: ({ doc }) => doc.excerpt ?? '',
|
// generateDescription: ({ doc }) => doc.excerpt ?? '',
|
||||||
// fields: [...], // extra pola w grupie SEO
|
// fields: [...], // extra pola w grupie SEO
|
||||||
// autoFill: { title: 'title', description: 'excerpt' }, // mapowanie auto-fill
|
// autoFill: { title: 'title', description: 'excerpt' }, // mapowanie auto-fill
|
||||||
// autoFill: false, // wyłącz auto-fill
|
// autoFill: false, // wyłącz auto-fill
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -89,16 +89,16 @@ import { createPageMetadata } from '@intecion/ipal-kit'
|
|||||||
import { i18nConfig } from '@/i18n.config'
|
import { i18nConfig } from '@/i18n.config'
|
||||||
|
|
||||||
const pageMetadata = createPageMetadata({
|
const pageMetadata = createPageMetadata({
|
||||||
config: i18nConfig,
|
config: i18nConfig,
|
||||||
baseUrl: process.env.NEXT_PUBLIC_SERVER_URL,
|
baseUrl: process.env.NEXT_PUBLIC_SERVER_URL,
|
||||||
// collection: 'pages', // domyślne
|
// collection: 'pages', // domyślne
|
||||||
// settingsSlug: 'site-settings', // domyślne
|
// settingsSlug: 'site-settings', // domyślne
|
||||||
// siteNameField: 'siteName', // domyślne
|
// siteNameField: 'siteName', // domyślne
|
||||||
})
|
})
|
||||||
|
|
||||||
export async function generateMetadata({ params }): Promise<Metadata> {
|
export async function generateMetadata({ params }): Promise<Metadata> {
|
||||||
const { locale, slug } = await params
|
const { locale, slug } = await params
|
||||||
return pageMetadata({ payload: await getPayload({ config }), locale, slug })
|
return pageMetadata({ payload: await getPayload({ config }), locale, slug })
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -121,43 +121,43 @@ global. Klient dostarcza resolvery.
|
|||||||
import { createMetadataGenerator } from '@intecion/ipal-kit'
|
import { createMetadataGenerator } from '@intecion/ipal-kit'
|
||||||
|
|
||||||
const generate = createMetadataGenerator({
|
const generate = createMetadataGenerator({
|
||||||
config: i18nConfig,
|
config: i18nConfig,
|
||||||
baseUrl: process.env.NEXT_PUBLIC_SERVER_URL,
|
baseUrl: process.env.NEXT_PUBLIC_SERVER_URL,
|
||||||
homeSlug: 'homepage',
|
homeSlug: 'homepage',
|
||||||
|
|
||||||
resolveDocument: async ({ payload, params, locale }) => {
|
resolveDocument: async ({ payload, params, locale }) => {
|
||||||
const slug = (params.slug as string[])?.join('/')
|
const slug = (params.slug as string[])?.join('/')
|
||||||
|
|
||||||
// meta MUSI przyjść w konkretnym locale (stringi), a slug jako mapa
|
// meta MUSI przyjść w konkretnym locale (stringi), a slug jako mapa
|
||||||
// locale→wartość (hreflang) — to dwa różne odczyty.
|
// locale→wartość (hreflang) — to dwa różne odczyty.
|
||||||
const found = await payload.find({
|
const found = await payload.find({
|
||||||
collection: 'posts',
|
collection: 'posts',
|
||||||
where: { slug: { equals: slug } },
|
where: { slug: { equals: slug } },
|
||||||
locale,
|
locale,
|
||||||
depth: 1,
|
depth: 1,
|
||||||
limit: 1,
|
limit: 1,
|
||||||
})
|
})
|
||||||
const doc = found.docs[0]
|
const doc = found.docs[0]
|
||||||
if (!doc) return null
|
if (!doc) return null
|
||||||
|
|
||||||
const allLocales = await payload.findByID({
|
const allLocales = await payload.findByID({
|
||||||
collection: 'posts',
|
collection: 'posts',
|
||||||
id: doc.id,
|
id: doc.id,
|
||||||
locale: 'all',
|
locale: 'all',
|
||||||
depth: 0,
|
depth: 0,
|
||||||
})
|
})
|
||||||
|
|
||||||
return { ...doc, slug: allLocales.slug }
|
return { ...doc, slug: allLocales.slug }
|
||||||
},
|
},
|
||||||
|
|
||||||
resolveSiteName: async ({ payload, locale }) =>
|
resolveSiteName: async ({ payload, locale }) =>
|
||||||
(await getSiteSettings(payload, { locale })).siteName ?? null,
|
(await getSiteSettings(payload, { locale })).siteName ?? null,
|
||||||
resolveImageUrl: async ({ doc }) => doc.meta?.image?.url ?? null,
|
resolveImageUrl: async ({ doc }) => doc.meta?.image?.url ?? null,
|
||||||
})
|
})
|
||||||
|
|
||||||
export async function generateMetadata({ params }) {
|
export async function generateMetadata({ params }) {
|
||||||
const { locale, slug } = await params
|
const { locale, slug } = await params
|
||||||
return generate({ payload: await getPayload({ config }), params: { slug }, locale })
|
return generate({ payload: await getPayload({ config }), params: { slug }, locale })
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -176,16 +176,16 @@ Gdy chcesz pełną kontrolę:
|
|||||||
import { buildMetadata, getLocalizedSlugs } from '@intecion/ipal-kit'
|
import { buildMetadata, getLocalizedSlugs } from '@intecion/ipal-kit'
|
||||||
|
|
||||||
return buildMetadata({
|
return buildMetadata({
|
||||||
meta: doc.meta, // z plugin-seo
|
meta: doc.meta, // z plugin-seo
|
||||||
siteName: settings.siteName,
|
siteName: settings.siteName,
|
||||||
imageUrl: '/og.png',
|
imageUrl: '/og.png',
|
||||||
locale: 'pl',
|
locale: 'pl',
|
||||||
slugs: getLocalizedSlugs({ slugField: docAllLocales.slug, config }),
|
slugs: getLocalizedSlugs({ slugField: docAllLocales.slug, config }),
|
||||||
config,
|
config,
|
||||||
baseUrl: 'https://example.com',
|
baseUrl: 'https://example.com',
|
||||||
separator: ' – ', // opcjonalne
|
separator: ' – ', // opcjonalne
|
||||||
order: 'site-first', // opcjonalne
|
order: 'site-first', // opcjonalne
|
||||||
homeSlug: 'homepage',
|
homeSlug: 'homepage',
|
||||||
})
|
})
|
||||||
// → { title, description, openGraph, alternates: { canonical, languages } }
|
// → { title, description, openGraph, alternates: { canonical, languages } }
|
||||||
```
|
```
|
||||||
@@ -232,10 +232,10 @@ nie rozjedzie się z tym, co strony serwują. Handlery są gotowe w
|
|||||||
```ts
|
```ts
|
||||||
// src/lib/content.ts
|
// src/lib/content.ts
|
||||||
export const { /* ... */, sitemap, robots } = createContentHelpers({
|
export const { /* ... */, sitemap, robots } = createContentHelpers({
|
||||||
config,
|
config,
|
||||||
content: contentConfig,
|
content: contentConfig,
|
||||||
i18n: i18nConfig, // wymagane dla sitemap (hreflang)
|
i18n: i18nConfig, // wymagane dla sitemap (hreflang)
|
||||||
baseUrl: process.env.NEXT_PUBLIC_SERVER_URL,
|
baseUrl: process.env.NEXT_PUBLIC_SERVER_URL,
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -278,7 +278,7 @@ Niskopoziomowo (własna trasa zamiast handlera z fabryki):
|
|||||||
import { buildSitemapEntries, buildRobots } from '@intecion/ipal-kit'
|
import { buildSitemapEntries, buildRobots } from '@intecion/ipal-kit'
|
||||||
|
|
||||||
const entries = await buildSitemapEntries({
|
const entries = await buildSitemapEntries({
|
||||||
payload, config: i18nConfig, baseUrl, content: contentConfig,
|
payload, config: i18nConfig, baseUrl, content: contentConfig,
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -321,9 +321,9 @@ import { buildIconsMetadata } from '@intecion/ipal-kit'
|
|||||||
import { getSettings } from '@/lib/payload'
|
import { getSettings } from '@/lib/payload'
|
||||||
|
|
||||||
export async function generateMetadata({ params }): Promise<Metadata> {
|
export async function generateMetadata({ params }): Promise<Metadata> {
|
||||||
const { locale } = await params
|
const { locale } = await params
|
||||||
const settings = await getSettings(locale)
|
const settings = await getSettings(locale)
|
||||||
return buildIconsMetadata(settings.favicon) // z pola favicon (panel)
|
return buildIconsMetadata(settings.favicon) // z pola favicon (panel)
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -346,16 +346,16 @@ wynikach, logo w knowledge panel.
|
|||||||
import { buildOrganizationJsonLd } from '@intecion/ipal-kit'
|
import { buildOrganizationJsonLd } from '@intecion/ipal-kit'
|
||||||
|
|
||||||
const jsonLd = buildOrganizationJsonLd({
|
const jsonLd = buildOrganizationJsonLd({
|
||||||
name: settings.siteName,
|
name: settings.siteName,
|
||||||
url: process.env.NEXT_PUBLIC_SERVER_URL!,
|
url: process.env.NEXT_PUBLIC_SERVER_URL!,
|
||||||
logo: settings.logo,
|
logo: settings.logo,
|
||||||
sameAs: settings.socialLinks, // opcjonalne: profile społecznościowe
|
sameAs: settings.socialLinks, // opcjonalne: profile społecznościowe
|
||||||
})
|
})
|
||||||
|
|
||||||
// w JSX layoutu:
|
// w JSX layoutu:
|
||||||
<script
|
<script
|
||||||
type="application/ld+json"
|
type="application/ld+json"
|
||||||
dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }}
|
dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }}
|
||||||
/>
|
/>
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -403,42 +403,42 @@ import { i18nConfig } from '@/i18n.config'
|
|||||||
import type { SiteSetting } from '@/payload-types'
|
import type { SiteSetting } from '@/payload-types'
|
||||||
|
|
||||||
export default async function manifest(): Promise<MetadataRoute.Manifest> {
|
export default async function manifest(): Promise<MetadataRoute.Manifest> {
|
||||||
const payload = await getCachedPayload()
|
const payload = await getCachedPayload()
|
||||||
const settings = await getSiteSettings<SiteSetting>(payload, {
|
const settings = await getSiteSettings<SiteSetting>(payload, {
|
||||||
locale: i18nConfig.defaultLocale as never,
|
locale: i18nConfig.defaultLocale as never,
|
||||||
})
|
})
|
||||||
|
|
||||||
const siteName = settings?.siteName?.trim()
|
const siteName = settings?.siteName?.trim()
|
||||||
|
|
||||||
// Ikona z panelu (favicon → logo). Dla PNG podaj KONKRETNY rozmiar z media
|
// Ikona z panelu (favicon → logo). Dla PNG podaj KONKRETNY rozmiar z media
|
||||||
// (nie 'any' — 'any' jest tylko dla SVG). Bez ikony → pomiń pole icons.
|
// (nie 'any' — 'any' jest tylko dla SVG). Bez ikony → pomiń pole icons.
|
||||||
const icon = settings?.favicon ?? settings?.logo
|
const icon = settings?.favicon ?? settings?.logo
|
||||||
const iconEntry =
|
const iconEntry =
|
||||||
typeof icon === 'object' && icon?.url
|
typeof icon === 'object' && icon?.url
|
||||||
? (() => {
|
? (() => {
|
||||||
const isSvg = icon.mimeType === 'image/svg+xml' || icon.url.endsWith('.svg')
|
const isSvg = icon.mimeType === 'image/svg+xml' || icon.url.endsWith('.svg')
|
||||||
const size =
|
const size =
|
||||||
typeof icon.width === 'number' && typeof icon.height === 'number'
|
typeof icon.width === 'number' && typeof icon.height === 'number'
|
||||||
? `${Math.min(icon.width, icon.height)}x${Math.min(icon.width, icon.height)}`
|
? `${Math.min(icon.width, icon.height)}x${Math.min(icon.width, icon.height)}`
|
||||||
: '512x512'
|
: '512x512'
|
||||||
return {
|
return {
|
||||||
src: icon.url,
|
src: icon.url,
|
||||||
type: icon.mimeType ?? 'image/png',
|
type: icon.mimeType ?? 'image/png',
|
||||||
sizes: isSvg ? 'any' : size, // 'any' tylko dla SVG
|
sizes: isSvg ? 'any' : size, // 'any' tylko dla SVG
|
||||||
}
|
}
|
||||||
})()
|
})()
|
||||||
: undefined
|
: undefined
|
||||||
|
|
||||||
// Buduj TYLKO z tego, co jest. Brak pola → nie ma go w manifeście (zamiast
|
// Buduj TYLKO z tego, co jest. Brak pola → nie ma go w manifeście (zamiast
|
||||||
// zaszytego fallbacku). start_url z configu, nie zaszyte '/pl'.
|
// zaszytego fallbacku). start_url z configu, nie zaszyte '/pl'.
|
||||||
return {
|
return {
|
||||||
...(siteName ? { name: siteName, short_name: siteName } : {}),
|
...(siteName ? { name: siteName, short_name: siteName } : {}),
|
||||||
start_url: `/${i18nConfig.defaultLocale}`,
|
start_url: `/${i18nConfig.defaultLocale}`,
|
||||||
display: 'standalone',
|
display: 'standalone',
|
||||||
...(iconEntry ? { icons: [iconEntry] } : {}),
|
...(iconEntry ? { icons: [iconEntry] } : {}),
|
||||||
// theme_color / background_color / description — TYLKO jeśli dodasz pola w
|
// theme_color / background_color / description — TYLKO jeśli dodasz pola w
|
||||||
// panelu i je odczytasz. NIE zaszywaj '#0e1e24' ani opisu klienta.
|
// panelu i je odczytasz. NIE zaszywaj '#0e1e24' ani opisu klienta.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -522,16 +522,16 @@ zanim strona wygeneruje metadane. To pcha metadata do body. NIE deklaruj `<head>
|
|||||||
```tsx
|
```tsx
|
||||||
// ŹLE — jawny <head> zamyka head za wcześnie
|
// ŹLE — jawny <head> zamyka head za wcześnie
|
||||||
<html lang={locale}>
|
<html lang={locale}>
|
||||||
<head><MediaPreconnect /></head>
|
<head><MediaPreconnect /></head>
|
||||||
<body>{children}</body>
|
<body>{children}</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
// DOBRZE — MediaPreconnect w body, React 19 hoistuje link do head
|
// DOBRZE — MediaPreconnect w body, React 19 hoistuje link do head
|
||||||
<html lang={locale}>
|
<html lang={locale}>
|
||||||
<body>
|
<body>
|
||||||
<MediaPreconnect />
|
<MediaPreconnect />
|
||||||
{children}
|
{children}
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -546,8 +546,8 @@ z jakiegoś powodu nie może być ISR):
|
|||||||
```ts
|
```ts
|
||||||
// next.config.ts
|
// next.config.ts
|
||||||
const nextConfig: NextConfig = {
|
const nextConfig: NextConfig = {
|
||||||
htmlLimitedBots:
|
htmlLimitedBots:
|
||||||
/Googlebot|Google-InspectionTool|Storebot-Google|Bingbot|Yandex|DuckDuckBot|Baiduspider|Screaming Frog|AhrefsBot|SemrushBot/i,
|
/Googlebot|Google-InspectionTool|Storebot-Google|Bingbot|Yandex|DuckDuckBot|Baiduspider|Screaming Frog|AhrefsBot|SemrushBot/i,
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -652,10 +652,10 @@ searchbox (pole wyszukiwania pod wynikiem marki). RAZ w root layout:
|
|||||||
```tsx
|
```tsx
|
||||||
import { buildWebSiteJsonLd } from '@intecion/ipal-kit'
|
import { buildWebSiteJsonLd } from '@intecion/ipal-kit'
|
||||||
const jsonLd = buildWebSiteJsonLd({
|
const jsonLd = buildWebSiteJsonLd({
|
||||||
name: settings.siteName,
|
name: settings.siteName,
|
||||||
url: baseUrl,
|
url: baseUrl,
|
||||||
// TYLKO jeśli masz działającą stronę wyszukiwania:
|
// TYLKO jeśli masz działającą stronę wyszukiwania:
|
||||||
search: { target: `${baseUrl}/szukaj?q={search_term_string}` },
|
search: { target: `${baseUrl}/szukaj?q={search_term_string}` },
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
Pomiń `search`, jeśli nie ma realnej wyszukiwarki — SearchAction wskazujący na
|
Pomiń `search`, jeśli nie ma realnej wyszukiwarki — SearchAction wskazujący na
|
||||||
@@ -666,9 +666,9 @@ Detailing) + Google rozumie hierarchię. PER STRONA, z pozycji strony:
|
|||||||
```tsx
|
```tsx
|
||||||
import { buildBreadcrumbJsonLd } from '@intecion/ipal-kit'
|
import { buildBreadcrumbJsonLd } from '@intecion/ipal-kit'
|
||||||
const jsonLd = buildBreadcrumbJsonLd([
|
const jsonLd = buildBreadcrumbJsonLd([
|
||||||
{ name: 'Strona główna', url: `${base}/pl` },
|
{ name: 'Strona główna', url: `${base}/pl` },
|
||||||
{ name: 'Usługi', url: `${base}/pl/uslugi` },
|
{ name: 'Usługi', url: `${base}/pl/uslugi` },
|
||||||
{ name: 'Detailing', url: `${base}/pl/uslugi/detailing` },
|
{ name: 'Detailing', url: `${base}/pl/uslugi/detailing` },
|
||||||
])
|
])
|
||||||
```
|
```
|
||||||
Okruszki buduj z RZECZYWISTEJ pozycji strony (resolveRoute / ścieżka URL), NIE z
|
Okruszki buduj z RZECZYWISTEJ pozycji strony (resolveRoute / ścieżka URL), NIE z
|
||||||
@@ -679,7 +679,7 @@ samych pozycji co menu w headerze:
|
|||||||
```tsx
|
```tsx
|
||||||
import { buildSiteNavigationJsonLd } from '@intecion/ipal-kit'
|
import { buildSiteNavigationJsonLd } from '@intecion/ipal-kit'
|
||||||
const jsonLd = buildSiteNavigationJsonLd(
|
const jsonLd = buildSiteNavigationJsonLd(
|
||||||
navItems.map(i => ({ name: i.label, url: `${base}${i.href}` }))
|
navItems.map(i => ({ name: i.label, url: `${base}${i.href}` }))
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
Dane z tego samego źródła co widoczne menu — nie osobna zaszyta lista.
|
Dane z tego samego źródła co widoczne menu — nie osobna zaszyta lista.
|
||||||
@@ -886,17 +886,17 @@ Generative Engine Optimization) i audytach „Agentic Browsing”.
|
|||||||
Wymaga wypełnionego siteDescription i sensownych meta.description stron
|
Wymaga wypełnionego siteDescription i sensownych meta.description stron
|
||||||
(inaczej llms.txt będzie ubogi).
|
(inaczej llms.txt będzie ubogi).
|
||||||
|
|
||||||
## Sitemap jako czytelna tabela (XSL stylesheet)
|
## Sitemap czytelny w przeglądarce (czysty XML)
|
||||||
|
|
||||||
Domyślny `/sitemap.xml` to surowy XML — Google go czyta, ale człowiek widzi
|
Domyślny `/sitemap.xml` (Next MetadataRoute) działa dla Google, ale w przeglądarce
|
||||||
„ścianę tagów". Można ostylować przez XSL (przeglądarka renderuje tabelę),
|
bywa nieczytelny. Możesz serwować go jako **czysty, sformatowany XML** przez
|
||||||
zachowując poprawność dla crawlerów.
|
`buildSitemapXml` — przeglądarka pokaże wbudowane drzewo XML (wcięcia, zwijanie,
|
||||||
|
kolorowanie składni), bez żadnej transformacji.
|
||||||
|
|
||||||
### Ograniczenie Next
|
> **NIE używaj XSLT.** Przeglądarki (Chrome i in.) WYCOFUJĄ XSLT — arkusz
|
||||||
|
> `<?xml-stylesheet?>` pokazuje ostrzeżenie i wkrótce przestanie działać.
|
||||||
Standardowy `app/sitemap.ts` (Next MetadataRoute) **nie pozwala** wstrzyknąć
|
> Rozwiązanie: serwuj czysty XML z poprawnym Content-Type; przeglądarka
|
||||||
`<?xml-stylesheet?>`. Żeby mieć styl, serwuj sitemap własnym route przez
|
> renderuje swój natywny widok drzewa XML sama.
|
||||||
`buildSitemapXml` (string XML z odwołaniem do XSL):
|
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
// app/sitemap.xml/route.ts (zamiast app/sitemap.ts)
|
// app/sitemap.xml/route.ts (zamiast app/sitemap.ts)
|
||||||
@@ -907,24 +907,73 @@ export const dynamic = 'force-dynamic'
|
|||||||
|
|
||||||
export async function GET() {
|
export async function GET() {
|
||||||
const entries = await sitemap()
|
const entries = await sitemap()
|
||||||
const xml = buildSitemapXml(entries, { stylesheetUrl: '/sitemap.xsl' })
|
const xml = buildSitemapXml(entries)
|
||||||
return new Response(xml, {
|
return new Response(xml, {
|
||||||
headers: { 'Content-Type': 'application/xml; charset=utf-8' },
|
headers: { 'Content-Type': 'application/xml; charset=utf-8' },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Plik XSL w /public
|
`buildSitemapXml` zwraca wcięty XML. Dwa tryby wyświetlania:
|
||||||
|
|
||||||
Skopiuj `sitemap.xsl` (z pluginu: `node_modules/@intecion/ipal-kit/dist/modules/seo/assets/sitemap.xsl`)
|
**Bez `cssUrl`** → przeglądarka pokazuje natywny widok drzewa XML (wcięcia, zwijanie).
|
||||||
do `public/sitemap.xsl` w projekcie. Zawiera responsywną tabelę (numer, URL,
|
|
||||||
data, języki) z dark mode. `stylesheetUrl: '/sitemap.xsl'` wskazuje na niego.
|
**Z `cssUrl`** → stylujesz XML własnym CSS (kafelki, etykiety). To W3C standard
|
||||||
|
„Associating Style Sheets with XML" — `type="text/css"`, NIE wycofywane (w
|
||||||
|
przeciwieństwie do XSLT/`text/xsl`). Zero ostrzeżenia, ładny wygląd, bezpieczne
|
||||||
|
dla Google (crawlery ignorują dyrektywę).
|
||||||
|
|
||||||
|
```ts
|
||||||
|
const xml = buildSitemapXml(entries, { cssUrl: '/sitemap.css' })
|
||||||
|
```
|
||||||
|
|
||||||
|
### Starter CSS (public/sitemap.css)
|
||||||
|
|
||||||
|
Skopiuj do `public/sitemap.css` w projekcie, dostosuj do designu. Selektory to
|
||||||
|
bezpośrednio nazwy tagów XML:
|
||||||
|
|
||||||
|
```css
|
||||||
|
/* public/sitemap.css */
|
||||||
|
urlset {
|
||||||
|
display: block;
|
||||||
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
||||||
|
background: #090d16; color: #f1f5f9;
|
||||||
|
padding: 2rem 1.5rem; max-width: 1200px; margin: 0 auto;
|
||||||
|
}
|
||||||
|
url { /* każdy adres jako kafelek */
|
||||||
|
display: block;
|
||||||
|
background: #111827; border: 1px solid #1e293b; border-radius: 8px;
|
||||||
|
padding: 1rem 1.25rem; margin-bottom: 0.75rem;
|
||||||
|
}
|
||||||
|
loc { /* adres URL */
|
||||||
|
display: block; font-size: 0.95rem; font-weight: 600;
|
||||||
|
color: #f97316; margin-bottom: 0.5rem; word-break: break-all;
|
||||||
|
}
|
||||||
|
lastmod, changefreq, priority {
|
||||||
|
display: inline-block; font-size: 0.8rem; color: #94a3b8; margin-right: 1.5rem;
|
||||||
|
}
|
||||||
|
lastmod::before { content: 'Ostatnia modyfikacja: '; color: #64748b; }
|
||||||
|
changefreq::before { content: 'Częstotliwość: '; color: #64748b; }
|
||||||
|
priority::before { content: 'Priorytet: '; color: #64748b; }
|
||||||
|
link { /* tagi hreflang */
|
||||||
|
display: inline-block; font-size: 0.75rem;
|
||||||
|
background: #1e293b; color: #38bdf8; border: 1px solid #334155;
|
||||||
|
padding: 0.15rem 0.45rem; border-radius: 4px; margin: 0.4rem 0.35rem 0 0;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Kluczowe: `display: block` na `<url>`/`<loc>` zamienia „ścianę tekstu" w kafelki.
|
||||||
|
Etykiety („Ostatnia modyfikacja:") przez `::before`. Dostosuj kolory do projektu.
|
||||||
|
|
||||||
|
**Ograniczenie:** `<loc>` to tag XML, nie `<a href>` — CSS nie zrobi z niego
|
||||||
|
klikalnego linku (niektóre przeglądarki autodetektują URL). Zysk to czytelność
|
||||||
|
i organizacja, nie klikalność. Dla sitemap (głównie dla robotów) to akceptowalne.
|
||||||
|
|
||||||
### WAŻNE — jeden sitemap, nie dwa
|
### WAŻNE — jeden sitemap, nie dwa
|
||||||
|
|
||||||
Jeśli używasz route `app/sitemap.xml/route.ts` (styled), **USUŃ** `app/sitemap.ts`
|
Jeśli używasz `app/sitemap.xml/route.ts`, USUŃ `app/sitemap.ts` (MetadataRoute).
|
||||||
(MetadataRoute). Dwa sitemapy pod różnymi ścieżkami mylą crawlery. Wybierz jeden:
|
Dwa sitemapy pod różnymi ścieżkami mylą crawlery. Wybierz jeden:
|
||||||
- **styled** (`sitemap.xml/route.ts` + buildSitemapXml + XSL) — ładna tabela
|
- **route.ts + buildSitemapXml** — czytelny XML w przeglądarce
|
||||||
- **prosty** (`sitemap.ts` + reeksport z lib/content) — bez stylu, mniej kodu
|
- **sitemap.ts** (reeksport z lib/content) — mniej kodu, mniej czytelny w przeglądarce
|
||||||
|
|
||||||
Styl to kosmetyka (Google czyta oba tak samo) — rób, jeśli klient/audyt tego chce.
|
Oba tak samo dobre dla Google — to kwestia czytelności dla człowieka, nie SEO.
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@intecion/ipal-kit",
|
"name": "@intecion/ipal-kit",
|
||||||
"version": "1.3.1",
|
"version": "1.4.2",
|
||||||
"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": {
|
||||||
|
|||||||
+16
-2
@@ -1,6 +1,13 @@
|
|||||||
'use client'
|
'use client'
|
||||||
export { MaskedField } from '../globals/SiteIntegrations/components/MaskedField.js'
|
export { MaskedField } from '../globals/SiteIntegrations/components/MaskedField.js'
|
||||||
export { TestEmailButton } from '../globals/SiteIntegrations/components/TestEmailButton.js'
|
export { TestEmailButton } from '../globals/SiteIntegrations/components/TestEmailButton.js'
|
||||||
|
export {
|
||||||
|
AccessibilityProvider,
|
||||||
|
AccessibilityWidget,
|
||||||
|
useAccessibility,
|
||||||
|
} from '../modules/accessibility/client.js'
|
||||||
|
export type { A11yClassNames, A11yState, A11yTexts } from '../modules/accessibility/client.js'
|
||||||
|
|
||||||
export { Analytics } from '../modules/analytics/client.js'
|
export { Analytics } from '../modules/analytics/client.js'
|
||||||
/**
|
/**
|
||||||
* Entry point: ipal-kit/client
|
* Entry point: ipal-kit/client
|
||||||
@@ -17,8 +24,15 @@ export {
|
|||||||
useConsentContext,
|
useConsentContext,
|
||||||
} from '../modules/consent/client.js'
|
} from '../modules/consent/client.js'
|
||||||
export type { CookieBannerClassNames } from '../modules/consent/client.js'
|
export type { CookieBannerClassNames } from '../modules/consent/client.js'
|
||||||
export { resolveFormMessage } from '../modules/notifications/resolveFormMessage.js'
|
// Pure i18n path helpers — no server/RSC deps, safe to import in client
|
||||||
export type { FormNotificationTexts } from '../modules/notifications/types.js'
|
// components (e.g. a LanguageSwitcher that computes locale URLs on the client).
|
||||||
|
export {
|
||||||
|
buildLocalizedPath,
|
||||||
|
getLocaleCodes,
|
||||||
|
getLocalizedSlugs,
|
||||||
|
switchLocalePath,
|
||||||
|
} from '../modules/i18n/index.js'
|
||||||
|
export type { I18nConfig, LocalizedSlugs } from '../modules/i18n/index.js'
|
||||||
export { Turnstile } from '../modules/turnstile/client.js'
|
export { Turnstile } from '../modules/turnstile/client.js'
|
||||||
export { TurnstileProvider, useTurnstile } from '../modules/turnstile/client.js'
|
export { TurnstileProvider, useTurnstile } from '../modules/turnstile/client.js'
|
||||||
export type { TurnstileProps } from '../modules/turnstile/client.js'
|
export type { TurnstileProps } from '../modules/turnstile/client.js'
|
||||||
|
|||||||
@@ -13,6 +13,14 @@ export {
|
|||||||
requireRoleField,
|
requireRoleField,
|
||||||
ROLE_HIERARCHY,
|
ROLE_HIERARCHY,
|
||||||
} from './modules/access/index.js'
|
} from './modules/access/index.js'
|
||||||
|
export {
|
||||||
|
A11Y_COOKIE,
|
||||||
|
A11Y_DEFAULT,
|
||||||
|
a11yAttributes,
|
||||||
|
parseA11y,
|
||||||
|
serializeA11y,
|
||||||
|
} from './modules/accessibility/index.js'
|
||||||
|
export type { A11yState } from './modules/accessibility/index.js'
|
||||||
export type { AnalyticsConfig } from './modules/analytics/index.js'
|
export type { AnalyticsConfig } from './modules/analytics/index.js'
|
||||||
export { getAnalyticsConfig } from './modules/analytics/index.js'
|
export { getAnalyticsConfig } from './modules/analytics/index.js'
|
||||||
export {
|
export {
|
||||||
|
|||||||
@@ -0,0 +1,94 @@
|
|||||||
|
'use client'
|
||||||
|
|
||||||
|
import { createContext, use, useCallback, useEffect, useState } from 'react'
|
||||||
|
|
||||||
|
import {
|
||||||
|
A11Y_COOKIE,
|
||||||
|
A11Y_COOKIE_MAX_AGE,
|
||||||
|
A11Y_DEFAULT,
|
||||||
|
a11yAttributes,
|
||||||
|
type A11yState,
|
||||||
|
parseA11y,
|
||||||
|
serializeA11y,
|
||||||
|
} from './state.js'
|
||||||
|
|
||||||
|
type A11yContextValue = {
|
||||||
|
reset: () => void
|
||||||
|
set: <K extends keyof A11yState>(key: K, value: A11yState[K]) => void
|
||||||
|
state: A11yState
|
||||||
|
}
|
||||||
|
|
||||||
|
const A11yContext = createContext<A11yContextValue | null>(null)
|
||||||
|
|
||||||
|
function readCookie(name: string): string | undefined {
|
||||||
|
if (typeof document === 'undefined') {return undefined}
|
||||||
|
const match = document.cookie.match(new RegExp(`(?:^|; )${name}=([^;]*)`))
|
||||||
|
return match ? decodeURIComponent(match[1]) : undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides accessibility preferences, persists them in a cookie, and applies them
|
||||||
|
* as data-attributes on <html> so the project's CSS can react. Like
|
||||||
|
* ConsentProvider for cookies — wrap the app once; the widget/button consume it.
|
||||||
|
*
|
||||||
|
* The plugin ships NO styles: it only sets attributes (data-a11y-*). The project
|
||||||
|
* writes CSS for those it supports (see docs/accessibility.md). This keeps the
|
||||||
|
* design in the project's hands.
|
||||||
|
*
|
||||||
|
* // layout.tsx
|
||||||
|
* import { AccessibilityProvider } from '@intecion/ipal-kit/client'
|
||||||
|
* <AccessibilityProvider>{children}</AccessibilityProvider>
|
||||||
|
*
|
||||||
|
* To avoid a flash, the project can read the a11y-prefs cookie server-side and
|
||||||
|
* set the attributes on <html> during SSR (see docs). This provider re-applies
|
||||||
|
* on the client and keeps them in sync.
|
||||||
|
*/
|
||||||
|
export function AccessibilityProvider({ children }: { children: React.ReactNode }) {
|
||||||
|
const [state, setState] = useState<A11yState>(A11Y_DEFAULT)
|
||||||
|
|
||||||
|
// Hydrate from cookie on mount.
|
||||||
|
useEffect(() => {
|
||||||
|
setState(parseA11y(readCookie(A11Y_COOKIE)))
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
// Apply attributes to <html> whenever state changes.
|
||||||
|
useEffect(() => {
|
||||||
|
const el = document.documentElement
|
||||||
|
const attrs = a11yAttributes(state)
|
||||||
|
for (const [attr, value] of Object.entries(attrs)) {
|
||||||
|
if (value === null) {el.removeAttribute(attr)}
|
||||||
|
else {el.setAttribute(attr, value)}
|
||||||
|
}
|
||||||
|
}, [state])
|
||||||
|
|
||||||
|
const persist = useCallback((next: A11yState) => {
|
||||||
|
document.cookie = `${A11Y_COOKIE}=${encodeURIComponent(
|
||||||
|
serializeA11y(next),
|
||||||
|
)}; path=/; max-age=${A11Y_COOKIE_MAX_AGE}; samesite=lax`
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
const set = useCallback(
|
||||||
|
<K extends keyof A11yState>(key: K, value: A11yState[K]) => {
|
||||||
|
setState((prev) => {
|
||||||
|
const next = { ...prev, [key]: value }
|
||||||
|
persist(next)
|
||||||
|
return next
|
||||||
|
})
|
||||||
|
},
|
||||||
|
[persist],
|
||||||
|
)
|
||||||
|
|
||||||
|
const reset = useCallback(() => {
|
||||||
|
setState(A11Y_DEFAULT)
|
||||||
|
persist(A11Y_DEFAULT)
|
||||||
|
}, [persist])
|
||||||
|
|
||||||
|
return <A11yContext value={{ reset, set, state }}>{children}</A11yContext>
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Access accessibility preferences + setters. Use inside AccessibilityProvider. */
|
||||||
|
export function useAccessibility(): A11yContextValue {
|
||||||
|
const ctx = use(A11yContext)
|
||||||
|
if (!ctx) {throw new Error('useAccessibility must be used within <AccessibilityProvider>')}
|
||||||
|
return ctx
|
||||||
|
}
|
||||||
@@ -0,0 +1,182 @@
|
|||||||
|
'use client'
|
||||||
|
|
||||||
|
import { useState } from 'react'
|
||||||
|
|
||||||
|
import type { A11yState } from './state.js'
|
||||||
|
|
||||||
|
import { useAccessibility } from './AccessibilityProvider.js'
|
||||||
|
|
||||||
|
export type A11yTexts = {
|
||||||
|
bigCursor?: string
|
||||||
|
close?: string
|
||||||
|
contrast?: string
|
||||||
|
contrastHigh?: string
|
||||||
|
contrastInverted?: string
|
||||||
|
grayscale?: string
|
||||||
|
lineHeight?: string
|
||||||
|
open?: string
|
||||||
|
readableFont?: string
|
||||||
|
reduceMotion?: string
|
||||||
|
reset?: string
|
||||||
|
textSize?: string
|
||||||
|
title?: string
|
||||||
|
underlineLinks?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
const DEFAULT_TEXTS: Required<A11yTexts> = {
|
||||||
|
bigCursor: 'Duży kursor',
|
||||||
|
close: 'Zamknij',
|
||||||
|
contrast: 'Kontrast',
|
||||||
|
contrastHigh: 'Wysoki',
|
||||||
|
contrastInverted: 'Odwrócony',
|
||||||
|
grayscale: 'Skala szarości',
|
||||||
|
lineHeight: 'Odstęp między liniami',
|
||||||
|
open: 'Otwórz panel dostępności',
|
||||||
|
readableFont: 'Czytelna czcionka',
|
||||||
|
reduceMotion: 'Wyłącz animacje',
|
||||||
|
reset: 'Resetuj',
|
||||||
|
textSize: 'Rozmiar tekstu',
|
||||||
|
title: 'Dostępność',
|
||||||
|
underlineLinks: 'Podkreśl linki',
|
||||||
|
}
|
||||||
|
|
||||||
|
export type A11yClassNames = {
|
||||||
|
active?: string
|
||||||
|
button?: string
|
||||||
|
closeButton?: string
|
||||||
|
control?: string
|
||||||
|
label?: string
|
||||||
|
panel?: string
|
||||||
|
resetButton?: string
|
||||||
|
row?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Accessibility toolbar: a floating button that opens a panel of options (text
|
||||||
|
* size, line height, contrast, grayscale, underline links, readable font, reduce
|
||||||
|
* motion, big cursor). Choices persist in a cookie and apply as data-attributes
|
||||||
|
* on <html> (the project's CSS styles them).
|
||||||
|
*
|
||||||
|
* Unstyled by default — pass classNames to match the project's design (like
|
||||||
|
* CookieBanner). Wrap the app in <AccessibilityProvider> first.
|
||||||
|
*
|
||||||
|
* <AccessibilityWidget classNames={{ button: 'a11y-btn', panel: 'a11y-panel' }} />
|
||||||
|
*/
|
||||||
|
export function AccessibilityWidget({
|
||||||
|
classNames,
|
||||||
|
texts,
|
||||||
|
}: {
|
||||||
|
classNames?: A11yClassNames
|
||||||
|
texts?: A11yTexts
|
||||||
|
}) {
|
||||||
|
const { reset, set, state } = useAccessibility()
|
||||||
|
const [open, setOpen] = useState(false)
|
||||||
|
const t = { ...DEFAULT_TEXTS, ...texts }
|
||||||
|
const cn = classNames ?? {}
|
||||||
|
|
||||||
|
const toggle = <K extends keyof A11yState>(key: K) => set(key, !state[key] as A11yState[K])
|
||||||
|
|
||||||
|
const isActive = (on: boolean) => (on ? (cn.active ?? '') : '')
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<button
|
||||||
|
aria-expanded={open}
|
||||||
|
aria-label={t.open}
|
||||||
|
className={cn.button}
|
||||||
|
onClick={() => setOpen((o) => !o)}
|
||||||
|
type="button"
|
||||||
|
>
|
||||||
|
{/* Project can style/replace via CSS; simple glyph fallback. */}
|
||||||
|
<span aria-hidden="true">♿</span>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
{open && (
|
||||||
|
<div aria-label={t.title} className={cn.panel} role="dialog">
|
||||||
|
<div className={cn.row}>
|
||||||
|
<span className={cn.label}>{t.textSize}</span>
|
||||||
|
<div className={cn.control}>
|
||||||
|
{[0, 1, 2, 3].map((n) => (
|
||||||
|
<button
|
||||||
|
className={isActive(state.textSize === n)}
|
||||||
|
key={n}
|
||||||
|
onClick={() => set('textSize', n as A11yState['textSize'])}
|
||||||
|
type="button"
|
||||||
|
>
|
||||||
|
A{n > 0 ? '+'.repeat(n) : ''}
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={cn.row}>
|
||||||
|
<span className={cn.label}>{t.lineHeight}</span>
|
||||||
|
<div className={cn.control}>
|
||||||
|
{[0, 1, 2].map((n) => (
|
||||||
|
<button
|
||||||
|
className={isActive(state.lineHeight === n)}
|
||||||
|
key={n}
|
||||||
|
onClick={() => set('lineHeight', n as A11yState['lineHeight'])}
|
||||||
|
type="button"
|
||||||
|
>
|
||||||
|
{n === 0 ? '—' : '≡'.repeat(n)}
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={cn.row}>
|
||||||
|
<span className={cn.label}>{t.contrast}</span>
|
||||||
|
<div className={cn.control}>
|
||||||
|
<button
|
||||||
|
className={isActive(state.contrast === 'high')}
|
||||||
|
onClick={() => set('contrast', state.contrast === 'high' ? 'default' : 'high')}
|
||||||
|
type="button"
|
||||||
|
>
|
||||||
|
{t.contrastHigh}
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
className={isActive(state.contrast === 'inverted')}
|
||||||
|
onClick={() =>
|
||||||
|
set('contrast', state.contrast === 'inverted' ? 'default' : 'inverted')
|
||||||
|
}
|
||||||
|
type="button"
|
||||||
|
>
|
||||||
|
{t.contrastInverted}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{(
|
||||||
|
[
|
||||||
|
['grayscale', t.grayscale],
|
||||||
|
['underlineLinks', t.underlineLinks],
|
||||||
|
['readableFont', t.readableFont],
|
||||||
|
['reduceMotion', t.reduceMotion],
|
||||||
|
['bigCursor', t.bigCursor],
|
||||||
|
] as Array<[keyof A11yState, string]>
|
||||||
|
).map(([key, label]) => (
|
||||||
|
<div className={cn.row} key={key}>
|
||||||
|
<span className={cn.label}>{label}</span>
|
||||||
|
<button
|
||||||
|
aria-pressed={Boolean(state[key])}
|
||||||
|
className={`${cn.control ?? ''} ${isActive(Boolean(state[key]))}`}
|
||||||
|
onClick={() => toggle(key)}
|
||||||
|
type="button"
|
||||||
|
>
|
||||||
|
{state[key] ? 'ON' : 'OFF'}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
|
||||||
|
<button className={cn.resetButton} onClick={reset} type="button">
|
||||||
|
{t.reset}
|
||||||
|
</button>
|
||||||
|
<button className={cn.closeButton} onClick={() => setOpen(false)} type="button">
|
||||||
|
{t.close}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
'use client'
|
||||||
|
export { AccessibilityProvider, useAccessibility } from './AccessibilityProvider.js'
|
||||||
|
export { AccessibilityWidget } from './AccessibilityWidget.js'
|
||||||
|
export type { A11yClassNames, A11yTexts } from './AccessibilityWidget.js'
|
||||||
|
export type { A11yState } from './state.js'
|
||||||
|
export { A11Y_COOKIE, a11yAttributes, parseA11y } from './state.js'
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
export { AccessibilityProvider, useAccessibility } from './AccessibilityProvider.js'
|
||||||
|
export { AccessibilityWidget } from './AccessibilityWidget.js'
|
||||||
|
export type { A11yClassNames, A11yTexts } from './AccessibilityWidget.js'
|
||||||
|
export {
|
||||||
|
A11Y_COOKIE,
|
||||||
|
A11Y_COOKIE_MAX_AGE,
|
||||||
|
A11Y_DEFAULT,
|
||||||
|
a11yAttributes,
|
||||||
|
parseA11y,
|
||||||
|
serializeA11y,
|
||||||
|
} from './state.js'
|
||||||
|
export type { A11yState } from './state.js'
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
/**
|
||||||
|
* Accessibility preferences state. Each option maps to a data-attribute on
|
||||||
|
* <html> (e.g. data-a11y-contrast="high"); the PROJECT's CSS reacts to those
|
||||||
|
* attributes. The plugin sets the attributes and persists the choice — it does
|
||||||
|
* NOT ship styles, so it never fights the project's design.
|
||||||
|
*/
|
||||||
|
export type A11yState = {
|
||||||
|
/** Larger cursor. */
|
||||||
|
bigCursor: boolean
|
||||||
|
/** 'default' | 'high' (high contrast) | 'inverted' (dark-on-light flip). */
|
||||||
|
contrast: 'default' | 'high' | 'inverted'
|
||||||
|
/** Grayscale filter on the whole page. */
|
||||||
|
grayscale: boolean
|
||||||
|
/** Line spacing: 0 = default, 1..2 = looser. */
|
||||||
|
lineHeight: 0 | 1 | 2
|
||||||
|
/** Readable font (project maps this to a dyslexia-friendly / simple font). */
|
||||||
|
readableFont: boolean
|
||||||
|
/** Stop animations / transitions (prefers-reduced-motion equivalent). */
|
||||||
|
reduceMotion: boolean
|
||||||
|
/** Text size step: 0 = default, 1..3 = larger. */
|
||||||
|
textSize: 0 | 1 | 2 | 3
|
||||||
|
/** Underline all links (WCAG: don't rely on color alone). */
|
||||||
|
underlineLinks: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
export const A11Y_DEFAULT: A11yState = {
|
||||||
|
bigCursor: false,
|
||||||
|
contrast: 'default',
|
||||||
|
grayscale: false,
|
||||||
|
lineHeight: 0,
|
||||||
|
readableFont: false,
|
||||||
|
reduceMotion: false,
|
||||||
|
textSize: 0,
|
||||||
|
underlineLinks: false,
|
||||||
|
}
|
||||||
|
|
||||||
|
export const A11Y_COOKIE = 'a11y-prefs'
|
||||||
|
export const A11Y_COOKIE_MAX_AGE = 60 * 60 * 24 * 365 // 1 year
|
||||||
|
|
||||||
|
/** Serialize for the cookie (compact). */
|
||||||
|
export function serializeA11y(state: A11yState): string {
|
||||||
|
return JSON.stringify(state)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Parse from the cookie; falls back to defaults on any bad value. */
|
||||||
|
export function parseA11y(raw: null | string | undefined): A11yState {
|
||||||
|
if (!raw) {return A11Y_DEFAULT}
|
||||||
|
try {
|
||||||
|
const parsed = JSON.parse(raw) as Partial<A11yState>
|
||||||
|
return { ...A11Y_DEFAULT, ...parsed }
|
||||||
|
} catch {
|
||||||
|
return A11Y_DEFAULT
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maps state → data-attributes to set on <html>. Returns { attr: value|null };
|
||||||
|
* null means remove the attribute (option is at default). The project's CSS
|
||||||
|
* targets these, e.g. `[data-a11y-contrast="high"] { … }`.
|
||||||
|
*/
|
||||||
|
export function a11yAttributes(state: A11yState): Record<string, null | string> {
|
||||||
|
return {
|
||||||
|
'data-a11y-contrast': state.contrast !== 'default' ? state.contrast : null,
|
||||||
|
'data-a11y-cursor': state.bigCursor ? 'big' : null,
|
||||||
|
'data-a11y-font': state.readableFont ? 'readable' : null,
|
||||||
|
'data-a11y-grayscale': state.grayscale ? 'on' : null,
|
||||||
|
'data-a11y-line': state.lineHeight > 0 ? String(state.lineHeight) : null,
|
||||||
|
'data-a11y-motion': state.reduceMotion ? 'reduce' : null,
|
||||||
|
'data-a11y-text': state.textSize > 0 ? String(state.textSize) : null,
|
||||||
|
'data-a11y-underline': state.underlineLinks ? 'on' : null,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,85 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<xsl:stylesheet version="1.0"
|
|
||||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
|
||||||
xmlns:s="http://www.sitemaps.org/schemas/sitemap/0.9"
|
|
||||||
xmlns:xhtml="http://www.w3.org/1999/xhtml">
|
|
||||||
<xsl:output method="html" encoding="UTF-8" indent="yes"/>
|
|
||||||
<xsl:template match="/">
|
|
||||||
<html lang="pl">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8"/>
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
||||||
<title>Sitemap</title>
|
|
||||||
<style>
|
|
||||||
:root { color-scheme: light dark; }
|
|
||||||
* { box-sizing: border-box; }
|
|
||||||
body {
|
|
||||||
font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
|
|
||||||
margin: 0; padding: 2rem 1rem; line-height: 1.5;
|
|
||||||
color: #1a1a1a; background: #f7f7f8;
|
|
||||||
}
|
|
||||||
.wrap { max-width: 1100px; margin: 0 auto; }
|
|
||||||
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
|
|
||||||
.meta { color: #666; font-size: .9rem; margin-bottom: 1.5rem; }
|
|
||||||
.count { font-weight: 600; }
|
|
||||||
table { width: 100%; border-collapse: collapse; background: #fff;
|
|
||||||
border-radius: .5rem; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
|
|
||||||
th, td { text-align: left; padding: .65rem .9rem; border-bottom: 1px solid #eee;
|
|
||||||
font-size: .9rem; }
|
|
||||||
th { background: #fafafa; font-weight: 600; color: #444;
|
|
||||||
position: sticky; top: 0; }
|
|
||||||
tr:last-child td { border-bottom: none; }
|
|
||||||
tr:hover td { background: #f5f8ff; }
|
|
||||||
a { color: #2563eb; text-decoration: none; word-break: break-all; }
|
|
||||||
a:hover { text-decoration: underline; }
|
|
||||||
.num { color: #999; width: 3rem; text-align: right; font-variant-numeric: tabular-nums; }
|
|
||||||
.langs { color: #666; font-size: .8rem; }
|
|
||||||
@media (prefers-color-scheme: dark) {
|
|
||||||
body { color: #e5e5e5; background: #18181b; }
|
|
||||||
table { background: #232327; box-shadow: none; }
|
|
||||||
th { background: #27272a; color: #ccc; }
|
|
||||||
th, td { border-color: #333; }
|
|
||||||
tr:hover td { background: #1e293b; }
|
|
||||||
.meta, .num, .langs { color: #888; }
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="wrap">
|
|
||||||
<h1>Mapa witryny (Sitemap)</h1>
|
|
||||||
<p class="meta">
|
|
||||||
Ten plik jest odczytywany przez wyszukiwarki.
|
|
||||||
Adresów: <span class="count"><xsl:value-of select="count(s:urlset/s:url)"/></span>
|
|
||||||
</p>
|
|
||||||
<table>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th class="num">#</th>
|
|
||||||
<th>Adres URL</th>
|
|
||||||
<th>Ostatnia zmiana</th>
|
|
||||||
<th>Języki</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<xsl:for-each select="s:urlset/s:url">
|
|
||||||
<tr>
|
|
||||||
<td class="num"><xsl:value-of select="position()"/></td>
|
|
||||||
<td>
|
|
||||||
<a href="{s:loc}"><xsl:value-of select="s:loc"/></a>
|
|
||||||
</td>
|
|
||||||
<td><xsl:value-of select="s:lastmod"/></td>
|
|
||||||
<td class="langs">
|
|
||||||
<xsl:for-each select="xhtml:link">
|
|
||||||
<xsl:value-of select="@hreflang"/>
|
|
||||||
<xsl:if test="position() != last()"><xsl:text>, </xsl:text></xsl:if>
|
|
||||||
</xsl:for-each>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</xsl:for-each>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
</xsl:template>
|
|
||||||
</xsl:stylesheet>
|
|
||||||
@@ -1,39 +1,53 @@
|
|||||||
import type { SitemapEntry } from './buildSitemapEntries.js'
|
import type { SitemapEntry } from './buildSitemapEntries.js'
|
||||||
|
|
||||||
|
type BuildSitemapXmlOptions = {
|
||||||
|
/**
|
||||||
|
* URL of a CSS stylesheet to make the sitemap readable in the browser, e.g.
|
||||||
|
* '/sitemap.css'. Uses `type="text/css"` — the W3C "Associating Style Sheets
|
||||||
|
* with XML" mechanism, which is NOT deprecated (unlike XSLT / type="text/xsl",
|
||||||
|
* which Chrome/WebKit are removing). CSS on XML shows no warning, styles the
|
||||||
|
* raw tags directly (e.g. `url { display: block }` turns the wall of text into
|
||||||
|
* cards), and crawlers ignore the directive entirely.
|
||||||
|
*/
|
||||||
|
cssUrl?: string
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Serializes sitemap entries to an XML STRING with an XSL stylesheet reference,
|
* Serializes sitemap entries to a clean, indented XML STRING — valid for crawlers
|
||||||
* so /sitemap.xml renders as a readable table in the browser (not raw XML) while
|
* and (with `cssUrl`) styled in the browser via plain CSS.
|
||||||
* staying a valid sitemap for crawlers.
|
|
||||||
*
|
*
|
||||||
* Why this exists alongside the Next MetadataRoute sitemap: Next's app/sitemap.ts
|
* Two viewing modes:
|
||||||
* (returning SitemapEntry[]) does NOT let you inject <?xml-stylesheet?>. To get
|
* - No cssUrl → the browser's native formatted XML tree (indented, collapsible).
|
||||||
* the styled table, serve a custom route that returns this string instead:
|
* - With cssUrl → a `<?xml-stylesheet type="text/css">` directive; the project's
|
||||||
|
* CSS styles the XML tags (cards, labels via ::before). NOT XSLT — that's being
|
||||||
|
* removed from browsers and shows a deprecation warning. CSS is safe and
|
||||||
|
* W3C-standard.
|
||||||
*
|
*
|
||||||
* // app/sitemap.xml/route.ts
|
* // app/sitemap.xml/route.ts
|
||||||
* import { buildSitemapXml } from '@intecion/ipal-kit'
|
* import { buildSitemapXml } from '@intecion/ipal-kit'
|
||||||
* import { sitemap } from '@/lib/content' // your entries source
|
* import { sitemap } from '@/lib/content'
|
||||||
* export const dynamic = 'force-dynamic'
|
* export const dynamic = 'force-dynamic'
|
||||||
* export async function GET() {
|
* export async function GET() {
|
||||||
* const entries = await sitemap()
|
* const entries = await sitemap()
|
||||||
* const xml = buildSitemapXml(entries, { stylesheetUrl: '/sitemap.xsl' })
|
* const xml = buildSitemapXml(entries, { cssUrl: '/sitemap.css' })
|
||||||
* return new Response(xml, {
|
* return new Response(xml, {
|
||||||
* headers: { 'Content-Type': 'application/xml; charset=utf-8' },
|
* headers: { 'Content-Type': 'application/xml; charset=utf-8' },
|
||||||
* })
|
* })
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* Put sitemap.xsl in the project's /public (copy from the plugin's assets, or
|
* Put sitemap.css in the project's /public and style the tags (see docs/seo.md
|
||||||
* serve it from a route). The <?xml-stylesheet?> points browsers at it; crawlers
|
* for a starter). Note: <loc> is an XML tag, not <a href> — CSS can't make it a
|
||||||
* ignore it and read the XML. Include hreflang alternates as <xhtml:link>.
|
* clickable link (some browsers auto-detect URLs); the win is readability, not
|
||||||
|
* clickability.
|
||||||
*
|
*
|
||||||
* NOTE: if you use this custom route, DON'T also keep app/sitemap.ts — pick one
|
* NOTE: if you use this custom route, DON'T also keep app/sitemap.ts — pick one.
|
||||||
* (the styled route OR the Next MetadataRoute). Two sitemaps at different paths
|
* Two sitemaps confuse crawlers.
|
||||||
* confuse crawlers.
|
|
||||||
*/
|
*/
|
||||||
export function buildSitemapXml(
|
export function buildSitemapXml(
|
||||||
entries: SitemapEntry[],
|
entries: SitemapEntry[],
|
||||||
opts: { stylesheetUrl?: string } = {},
|
opts: BuildSitemapXmlOptions = {},
|
||||||
): string {
|
): string {
|
||||||
const { stylesheetUrl } = opts
|
const { cssUrl } = opts
|
||||||
|
|
||||||
const esc = (s: string): string =>
|
const esc = (s: string): string =>
|
||||||
s
|
s
|
||||||
@@ -53,7 +67,6 @@ export function buildSitemapXml(
|
|||||||
}
|
}
|
||||||
if (e.changeFrequency) parts.push(` <changefreq>${e.changeFrequency}</changefreq>`)
|
if (e.changeFrequency) parts.push(` <changefreq>${e.changeFrequency}</changefreq>`)
|
||||||
if (typeof e.priority === 'number') parts.push(` <priority>${e.priority}</priority>`)
|
if (typeof e.priority === 'number') parts.push(` <priority>${e.priority}</priority>`)
|
||||||
// hreflang alternates
|
|
||||||
const alternates = e.alternates?.languages
|
const alternates = e.alternates?.languages
|
||||||
if (alternates) {
|
if (alternates) {
|
||||||
for (const [lang, href] of Object.entries(alternates)) {
|
for (const [lang, href] of Object.entries(alternates)) {
|
||||||
@@ -68,9 +81,7 @@ export function buildSitemapXml(
|
|||||||
})
|
})
|
||||||
.join('\n')
|
.join('\n')
|
||||||
|
|
||||||
const stylesheet = stylesheetUrl
|
const stylesheet = cssUrl ? `<?xml-stylesheet type="text/css" href="${esc(cssUrl)}"?>\n` : ''
|
||||||
? `<?xml-stylesheet type="text/xsl" href="${esc(stylesheetUrl)}"?>\n`
|
|
||||||
: ''
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
`<?xml version="1.0" encoding="UTF-8"?>\n` +
|
`<?xml version="1.0" encoding="UTF-8"?>\n` +
|
||||||
|
|||||||
Reference in New Issue
Block a user