From 5af503314806bd4a110ac953b494bdf092d0700a Mon Sep 17 00:00:00 2001 From: rasm-its Date: Tue, 13 Oct 2026 23:51:08 +0200 Subject: [PATCH] import fix in buildLinkField --- dist/modules/links/buildLinkField.js | 4 ++-- dist/modules/links/buildLinkField.js.map | 2 +- dist/modules/seo/sitemapStyle.js | 2 +- dist/modules/seo/sitemapStyle.js.map | 2 +- src/modules/links/buildLinkField.ts | 4 ++-- src/modules/seo/sitemapStyle.ts | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/dist/modules/links/buildLinkField.js b/dist/modules/links/buildLinkField.js index d3be51f..37694de 100644 --- a/dist/modules/links/buildLinkField.js +++ b/dist/modules/links/buildLinkField.js @@ -1,5 +1,5 @@ -import { rowLabel } from 'src/modules/admin-ui/rowLabel.js'; -const URL_PATTERN = /^(https?:\/\/|mailto:|tel:|#)/; +import { rowLabel } from '../admin-ui/rowLabel.js'; +const URL_PATTERN = /^(?:https?:\/\/|mailto:|tel:|#)/; /** * The ONE link shape for a project: a page, an external URL (also mailto:, * tel:, #anchor) or an uploaded file — plus label, new-tab flag and visual diff --git a/dist/modules/links/buildLinkField.js.map b/dist/modules/links/buildLinkField.js.map index b978d89..60b9079 100644 --- a/dist/modules/links/buildLinkField.js.map +++ b/dist/modules/links/buildLinkField.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../../src/modules/links/buildLinkField.ts"],"sourcesContent":["import type { ArrayField, Field, GroupField } from 'payload'\n\nimport { rowLabel } from 'src/modules/admin-ui/rowLabel.js'\n\nexport type LinkAppearance = 'link' | 'primary' | 'secondary'\n\nexport type BuildLinkFieldOptions = {\n /** Visual styles the editor may pick. `false` → no appearance select. Default all three. */\n appearances?: false | LinkAppearance[]\n /** Hide the label — for links that wrap something (a whole card, an image). */\n disableLabel?: boolean\n /** Field name. Default 'link'. */\n name?: string\n /** Collection the \"Page\" option points at. Default 'pages'. */\n relationTo?: string\n required?: boolean\n /** Upload collection for \"File\" links (PDF, documents). Default 'media'. */\n uploadTo?: string\n}\n\nconst URL_PATTERN = /^(https?:\\/\\/|mailto:|tel:|#)/\n\ntype SiblingWithType = { type?: string } | undefined\n\n/**\n * The ONE link shape for a project: a page, an external URL (also mailto:,\n * tel:, #anchor) or an uploaded file — plus label, new-tab flag and visual\n * style. Every CTA, card link and download in every block uses this field, so\n * there is no zoo of ctaLabel / buttonUrl / pdfUrl fields and one renderer\n * (resolveLinkHref + the project's CMSLink) handles them all.\n *\n * Generates a named TypeScript type `CmsLink` in payload-types.ts.\n *\n * fields: [buildLinkField()] // single link\n * fields: [buildLinkField({ disableLabel: true, appearances: false })] // clickable card\n */\nexport function buildLinkField({\n name = 'link',\n appearances = ['primary', 'secondary', 'link'],\n disableLabel = false,\n relationTo = 'pages',\n required = false,\n uploadTo = 'media',\n}: BuildLinkFieldOptions = {}): GroupField {\n const fields: Field[] = [\n {\n type: 'row',\n fields: [\n {\n name: 'type',\n type: 'radio',\n admin: { layout: 'horizontal', width: '50%' },\n defaultValue: 'internal',\n options: [\n { label: 'Page', value: 'internal' },\n { label: 'URL', value: 'external' },\n { label: 'File', value: 'file' },\n ],\n },\n {\n name: 'newTab',\n type: 'checkbox',\n admin: { style: { alignSelf: 'flex-end' }, width: '50%' },\n label: 'Open in new tab',\n },\n ],\n },\n {\n name: 'page',\n type: 'relationship',\n admin: { condition: (_: unknown, s: SiblingWithType) => s?.type === 'internal' },\n relationTo,\n required,\n },\n {\n name: 'url',\n type: 'text',\n admin: {\n condition: (_: unknown, s: SiblingWithType) => s?.type === 'external',\n description: 'Full URL (https://…), mailto:, tel: or #section-anchor.',\n },\n required,\n validate: (v: null | string | undefined) =>\n !v || URL_PATTERN.test(v) || 'Use https://…, mailto:, tel: or #anchor',\n },\n {\n name: 'file',\n type: 'upload',\n admin: {\n condition: (_: unknown, s: SiblingWithType) => s?.type === 'file',\n description: 'Upload a PDF / document / image. Never paste a file URL.',\n },\n relationTo: uploadTo,\n required,\n },\n ]\n\n if (!disableLabel) {\n fields.push({ name: 'label', type: 'text', localized: true, required })\n }\n\n if (appearances && appearances.length) {\n fields.push({\n name: 'appearance',\n type: 'select',\n defaultValue: appearances[0],\n options: appearances.map((a) => ({ label: a, value: a })),\n })\n }\n\n return {\n name,\n type: 'group',\n admin: { hideGutter: true },\n fields,\n interfaceName: 'CmsLink',\n }\n}\n\nexport type BuildLinksFieldOptions = {\n /**\n * What one row is called in the panel — the add button reads \"Add \".\n * Default { singular: 'Button', plural: 'Buttons' }; e.g. { singular: 'Link', plural: 'Links' } for a link list.\n */\n labels?: { plural: string; singular: string }\n /** Max number of buttons. Default 2. */\n maxRows?: number\n /** Field name. Default 'links'. */\n name?: string\n} & Omit\n\n/**\n * 0..N buttons — use for every \"CTA(s)\" of a section. Each row holds one\n * `link` (buildLinkField). Render: `links.map(({ id, link }) => )`.\n */\nexport function buildLinksField({\n name = 'links',\n labels = { plural: 'Buttons', singular: 'Button' },\n maxRows = 2,\n ...linkOptions\n}: BuildLinksFieldOptions = {}): ArrayField {\n return {\n name,\n type: 'array',\n admin: {\n initCollapsed: true,\n // Rows read \"Contact us\" / \"Download catalogue\", not \"Button 01\". Needs the importMap entry.\n components: rowLabel(['link.label', 'link.url'], labels.singular),\n },\n fields: [buildLinkField(linkOptions)],\n label: labels.plural,\n labels,\n maxRows,\n }\n}\n"],"names":["rowLabel","URL_PATTERN","buildLinkField","name","appearances","disableLabel","relationTo","required","uploadTo","fields","type","admin","layout","width","defaultValue","options","label","value","style","alignSelf","condition","_","s","description","validate","v","test","push","localized","length","map","a","hideGutter","interfaceName","buildLinksField","labels","plural","singular","maxRows","linkOptions","initCollapsed","components"],"mappings":"AAEA,SAASA,QAAQ,QAAQ,mCAAkC;AAkB3D,MAAMC,cAAc;AAIpB;;;;;;;;;;;CAWC,GACD,OAAO,SAASC,eAAe,EAC7BC,OAAO,MAAM,EACbC,cAAc;IAAC;IAAW;IAAa;CAAO,EAC9CC,eAAe,KAAK,EACpBC,aAAa,OAAO,EACpBC,WAAW,KAAK,E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oBAAGd,OAAOc;gBAAE,CAAA;QACxD;IACF;IAEA,OAAO;QACL5B;QACAO,MAAM;QACNC,OAAO;YAAEqB,YAAY;QAAK;QAC1BvB;QACAwB,eAAe;IACjB;AACF;AAcA;;;CAGC,GACD,OAAO,SAASC,gBAAgB,EAC9B/B,OAAO,OAAO,EACdgC,SAAS;IAAEC,QAAQ;IAAWC,UAAU;AAAS,CAAC,EAClDC,UAAU,CAAC,EACX,GAAGC,aACoB,GAAG,CAAC,CAAC;IAC5B,OAAO;QACLpC;QACAO,MAAM;QACNC,OAAO;YACL6B,eAAe;YACf,6FAA6F;YAC7FC,YAAYzC,SAAS;gBAAC;gBAAc;aAAW,EAAEmC,OAAOE,QAAQ;QAClE;QACA5B,QAAQ;YAACP,eAAeqC;SAAa;QACrCvB,OAAOmB,OAAOC,MAAM;QACpBD;QACAG;IACF;AACF"} \ No newline at end of file +{"version":3,"sources":["../../../src/modules/links/buildLinkField.ts"],"sourcesContent":["import type { ArrayField, Field, GroupField } from 'payload'\n\nimport { rowLabel } from '../admin-ui/rowLabel.js'\n\nexport type LinkAppearance = 'link' | 'primary' | 'secondary'\n\nexport type BuildLinkFieldOptions = {\n /** Visual styles the editor may pick. `false` → no appearance select. Default all three. */\n appearances?: false | LinkAppearance[]\n /** Hide the label — for links that wrap something (a whole card, an image). */\n disableLabel?: boolean\n /** Field name. Default 'link'. */\n name?: string\n /** Collection the \"Page\" option points at. Default 'pages'. */\n relationTo?: string\n required?: boolean\n /** Upload collection for \"File\" links (PDF, documents). Default 'media'. */\n uploadTo?: string\n}\n\nconst URL_PATTERN = /^(?:https?:\\/\\/|mailto:|tel:|#)/\n\ntype SiblingWithType = { type?: string } | undefined\n\n/**\n * The ONE link shape for a project: a page, an external URL (also mailto:,\n * tel:, #anchor) or an uploaded file — plus label, new-tab flag and visual\n * style. Every CTA, card link and download in every block uses this field, so\n * there is no zoo of ctaLabel / buttonUrl / pdfUrl fields and one renderer\n * (resolveLinkHref + the project's CMSLink) handles them all.\n *\n * Generates a named TypeScript type `CmsLink` in payload-types.ts.\n *\n * fields: [buildLinkField()] // single link\n * fields: [buildLinkField({ disableLabel: true, appearances: false })] // clickable card\n */\nexport function buildLinkField({\n name = 'link',\n appearances = ['primary', 'secondary', 'link'],\n disableLabel = false,\n relationTo = 'pages',\n required = false,\n uploadTo = 'media',\n}: BuildLinkFieldOptions = {}): GroupField {\n const fields: Field[] = [\n {\n type: 'row',\n fields: [\n {\n name: 'type',\n type: 'radio',\n admin: { layout: 'horizontal', width: '50%' },\n defaultValue: 'internal',\n options: [\n { label: 'Page', value: 'internal' },\n { label: 'URL', value: 'external' },\n { label: 'File', value: 'file' },\n ],\n },\n {\n name: 'newTab',\n type: 'checkbox',\n admin: { style: { alignSelf: 'flex-end' }, width: '50%' },\n label: 'Open in new tab',\n },\n ],\n },\n {\n name: 'page',\n type: 'relationship',\n admin: { condition: (_: unknown, s: SiblingWithType) => s?.type === 'internal' },\n relationTo,\n required,\n },\n {\n name: 'url',\n type: 'text',\n admin: {\n condition: (_: unknown, s: SiblingWithType) => s?.type === 'external',\n description: 'Full URL (https://…), mailto:, tel: or #section-anchor.',\n },\n required,\n validate: (v: null | string | undefined) =>\n !v || URL_PATTERN.test(v) || 'Use https://…, mailto:, tel: or #anchor',\n },\n {\n name: 'file',\n type: 'upload',\n admin: {\n condition: (_: unknown, s: SiblingWithType) => s?.type === 'file',\n description: 'Upload a PDF / document / image. Never paste a file URL.',\n },\n relationTo: uploadTo,\n required,\n },\n ]\n\n if (!disableLabel) {\n fields.push({ name: 'label', type: 'text', localized: true, required })\n }\n\n if (appearances && appearances.length) {\n fields.push({\n name: 'appearance',\n type: 'select',\n defaultValue: appearances[0],\n options: appearances.map((a) => ({ label: a, value: a })),\n })\n }\n\n return {\n name,\n type: 'group',\n admin: { hideGutter: true },\n fields,\n interfaceName: 'CmsLink',\n }\n}\n\nexport type BuildLinksFieldOptions = {\n /**\n * What one row is called in the panel — the add button reads \"Add \".\n * Default { singular: 'Button', plural: 'Buttons' }; e.g. { singular: 'Link', plural: 'Links' } for a link list.\n */\n labels?: { plural: string; singular: string }\n /** Max number of buttons. Default 2. */\n maxRows?: number\n /** Field name. Default 'links'. */\n name?: string\n} & Omit\n\n/**\n * 0..N buttons — use for every \"CTA(s)\" of a section. Each row holds one\n * `link` (buildLinkField). Render: `links.map(({ id, link }) => )`.\n */\nexport function buildLinksField({\n name = 'links',\n labels = { plural: 'Buttons', singular: 'Button' },\n maxRows = 2,\n ...linkOptions\n}: BuildLinksFieldOptions = {}): ArrayField {\n return {\n name,\n type: 'array',\n admin: {\n initCollapsed: true,\n // Rows read \"Contact us\" / \"Download catalogue\", not \"Button 01\". Needs the importMap entry.\n components: rowLabel(['link.label', 'link.url'], labels.singular),\n },\n fields: [buildLinkField(linkOptions)],\n label: labels.plural,\n labels,\n maxRows,\n }\n}\n"],"names":["rowLabel","URL_PATTERN","buildLinkField","name","appearances","disableLabel","relationTo","required","uploadTo","fields","type","admin","layout","width","defaultValue","options","label","value","style","alignSelf","condition","_","s","description","validate","v","test","push","localized","length","map","a","hideGutter","interfaceName","buildLinksField","labels","plural","singular","maxRows","linkOptions","initCollapsed","components"],"mappings":"AAEA,SAASA,QAAQ,QAAQ,0BAAyB;AAkBlD,MAAMC,cAAc;AAIpB;;;;;;;;;;;CAWC,GACD,OAAO,SAASC,eAAe,EAC7BC,OAAO,MAAM,EACbC,cAAc;IAAC;IAAW;IAAa;CAAO,EAC9CC,eAAe,KAAK,EACpBC,aAAa,OAAO,EACpBC,WAAW,KAAK,EAChBC,WAAW,OAAO,EACI,GAAG,CAAC,CAAC;IAC3B,MAAMC,SAAkB;QACtB;YACEC,MAAM;YACND,QAAQ;gBACN;oBACEN,MAAM;oBACNO,MAAM;oBACNC,OAAO;wBAAEC,QAAQ;wBAAcC,OAAO;oBAAM;oBAC5CC,cAAc;oBACdC,SAAS;wBACP;4BAAEC,OAAO;4BAAQC,OAAO;wBAAW;wBACnC;4BAAED,OAAO;4BAAOC,OAA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GC,aACoB,GAAG,CAAC,CAAC;IAC5B,OAAO;QACLpC;QACAO,MAAM;QACNC,OAAO;YACL6B,eAAe;YACf,6FAA6F;YAC7FC,YAAYzC,SAAS;gBAAC;gBAAc;aAAW,EAAEmC,OAAOE,QAAQ;QAClE;QACA5B,QAAQ;YAACP,eAAeqC;SAAa;QACrCvB,OAAOmB,OAAOC,MAAM;QACpBD;QACAG;IACF;AACF"} \ No newline at end of file diff --git a/dist/modules/seo/sitemapStyle.js b/dist/modules/seo/sitemapStyle.js index 8e57880..d4a46dd 100644 --- a/dist/modules/seo/sitemapStyle.js +++ b/dist/modules/seo/sitemapStyle.js @@ -6,7 +6,7 @@ */ /** Query parameter on the sitemap URL that returns the stylesheet instead of XML. */ export const SITEMAP_STYLE_PARAM = 'style'; export const DEFAULT_SITEMAP_CREDIT = 'Technology by Intecion.com'; /** CSS `content: "…"` value — escapes backslashes, quotes and newlines. */ const cssString = (s)=>`"${s.replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/[\r\n]+/g, ' ')}"`; -/** Only plain colour values — the option ends up inside a stylesheet. */ const safeColor = (c, fallback)=>c && /^(#[0-9a-f]{3,8}|[a-z]+|(rgb|hsl|oklch)a?\([\d\s.,%/-]+\))$/i.test(c.trim()) ? c.trim() : fallback; +/** Only plain colour values — the option ends up inside a stylesheet. */ const safeColor = (c, fallback)=>c && /^(?:#[0-9a-f]{3,8}|[a-z]+|(?:rgb|hsl|oklch)a?\([\d\s.,%/-]+\))$/i.test(c.trim()) ? c.trim() : fallback; export function buildSitemapCss({ accent, credit, title } = {}) { const heading = title?.trim() || 'XML Sitemap'; const note = credit === false ? '' : (credit ?? DEFAULT_SITEMAP_CREDIT).trim(); diff --git a/dist/modules/seo/sitemapStyle.js.map b/dist/modules/seo/sitemapStyle.js.map index 66c7b25..5898931 100644 --- a/dist/modules/seo/sitemapStyle.js.map +++ b/dist/modules/seo/sitemapStyle.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../../src/modules/seo/sitemapStyle.ts"],"sourcesContent":["/**\n * Built-in look of /sitemap.xml in a browser — served by the sitemap route itself\n * (`/sitemap.xml?style`), so projects ship NO sitemap.css and copy nothing.\n * Plain CSS on XML (W3C \"Associating Style Sheets with XML\", type=\"text/css\") —\n * not XSLT, which browsers are removing. Crawlers ignore it.\n */\n\nexport type SitemapStyleOptions = {\n /** Accent colour (card hover). Default '#027bd0'. Any plain CSS colour. */\n accent?: string\n /**\n * Line under the header — the technology provider. Default\n * \"Technology by Intecion.com\". `false` hides it.\n */\n credit?: false | string\n /** Header line. Default: the site name from Site Settings (sitemapRoute), else \"XML Sitemap\". */\n title?: string\n}\n\n/** Query parameter on the sitemap URL that returns the stylesheet instead of XML. */\nexport const SITEMAP_STYLE_PARAM = 'style'\nexport const DEFAULT_SITEMAP_CREDIT = 'Technology by Intecion.com'\n\n/** CSS `content: \"…\"` value — escapes backslashes, quotes and newlines. */\nconst cssString = (s: string) => `\"${s.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"').replace(/[\\r\\n]+/g, ' ')}\"`\n\n/** Only plain colour values — the option ends up inside a stylesheet. */\nconst safeColor = (c: string | undefined, fallback: string) =>\n c && /^(#[0-9a-f]{3,8}|[a-z]+|(rgb|hsl|oklch)a?\\([\\d\\s.,%/-]+\\))$/i.test(c.trim()) ? c.trim() : fallback\n\nexport function buildSitemapCss({ accent, credit, title }: SitemapStyleOptions = {}): string {\n const heading = title?.trim() || 'XML Sitemap'\n const note = credit === false ? '' : (credit ?? DEFAULT_SITEMAP_CREDIT).trim()\n const acc = safeColor(accent, '#027bd0')\n const divider = 'padding-bottom: 1.25rem; margin-bottom: 1.5rem; border-bottom: 1px solid var(--border);'\n\n return `:root {\n --bg: #fafafa; --card: #ffffff; --border: #e5e7eb; --border-hover: #d1d5db;\n --text-main: #111827; --text-secondary: #4b5563; --text-muted: #9ca3af; --url-color: #1e293b;\n --badge-bg: #f3f4f6; --badge-border: #e5e7eb; --badge-text: #4b5563; --accent: ${acc};\n}\n@media (prefers-color-scheme: dark) {\n :root {\n --bg: #090a0f; --card: #12131a; --border: #1e202e; --border-hover: #2e3247;\n --text-main: #f9fafb; --text-secondary: #9ca3af; --text-muted: #6b7280; --url-color: #f3f4f6;\n --badge-bg: #1a1c26; --badge-border: #282b3d; --badge-text: #9ca3af;\n }\n}\nurlset {\n display: flex; flex-direction: column; box-sizing: border-box; min-height: 100vh;\n max-width: 1040px; margin: 0 auto; padding: 3rem 1.5rem; line-height: 1.5;\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Inter, Helvetica, Arial, sans-serif;\n background-color: var(--bg); color: var(--text-main);\n}\nurlset::before {\n content: ${cssString(heading)};\n display: block; order: -2; font-size: 1.35rem; font-weight: 600; letter-spacing: -0.02em;\n color: var(--text-main); ${note ? 'padding-bottom: 0.4rem;' : divider}\n}\n${note ? `urlset::after {\n content: ${cssString(note)};\n display: block; order: -1; font-size: 0.8rem; color: var(--text-muted); ${divider}\n}\n` : ''}url {\n display: block; width: 100%; order: 0; box-sizing: border-box;\n background-color: var(--card); border: 1px solid var(--border); border-radius: 8px;\n padding: 1rem 1.25rem; margin-bottom: 0.65rem;\n transition: border-color 0.15s ease, box-shadow 0.15s ease;\n}\nurl:hover { border-color: var(--accent); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03); }\nloc {\n display: block; margin-bottom: 0.45rem; word-break: break-all; line-height: 1.45;\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", monospace;\n font-size: 0.875rem; font-weight: 500; color: var(--url-color);\n}\nlastmod, changefreq, priority {\n display: inline-block; font-size: 0.775rem; color: var(--text-secondary);\n margin-right: 1.25rem; margin-top: 0.15rem;\n}\nlastmod::before { content: \"Updated: \"; color: var(--text-muted); }\nchangefreq::before { content: \"Frequency: \"; color: var(--text-muted); }\npriority::before { content: \"Priority: \"; color: var(--text-muted); }\nlink {\n display: inline-block; font-size: 0.7rem; font-weight: 600; text-transform: uppercase;\n background-color: var(--badge-bg); border: 1px solid var(--badge-border); color: var(--badge-text);\n padding: 0.1rem 0.45rem; border-radius: 4px; margin-right: 0.3rem; margin-top: 0.35rem;\n}\nlink::before { content: attr(hreflang); }\n`\n}\n"],"names":["SITEMAP_STYLE_PARAM","DEFAULT_SITEMAP_CREDIT","cssString","s","replace","safeColor","c","fallback","test","trim","buildSitemapCss","accent","credit","title","heading","note","acc","divider"],"mappings":"AAAA;;;;;CAKC,GAcD,mFAAmF,GACnF,OAAO,MAAMA,sBAAsB,QAAO;AAC1C,OAAO,MAAMC,yBAAyB,6BAA4B;AAElE,yEAAyE,GACzE,MAAMC,YAAY,CAACC,IAAc,CAAC,CAAC,EAAEA,EAAEC,OAAO,CAAC,OAAO,QAAQA,OAAO,CAAC,MAAM,OAAOA,OAAO,CAAC,YAAY,KAAK,CAAC,CAAC;AAE9G,uEAAuE,GACvE,MAAMC,YAAY,CAACC,GAAuBC,WACxCD,KAAK,+DAA+DE,IAAI,CAACF,EAAEG,IAAI,MAAMH,EAAEG,IAAI,KAAKF;AAElG,OAAO,SAASG,gBAAgB,EAAEC,MAAM,EAAEC,MAAM,EAAEC,KAAK,EAAuB,GAAG,CAAC,CAAC;IACjF,MAAMC,UAAUD,OAAOJ,UAAU;IACjC,MAAMM,OAAOH,WAAW,QAAQ,KAAK,AAACA,CAAAA,UAAUX,sBAAqB,EAAGQ,IAAI;IAC5E,MAAMO,MAAMX,UAAUM,QAAQ;IAC9B,MAAMM,UAAU;IAEhB,OAAO,CAAC;;;iFAGuE,EAAED,IAAI;;;;;;;;;;;;;;;;WAgB5E,EAAEd,UAAUY,SAAS;;2BAEL,EAAEC,OAAO,4BAA4BE,QAAQ;;AAExE,EAAEF,OAAO,CAAC;WACC,EAAEb,UAAUa,MAAM;0EAC6C,EAAEE,QAAQ;;AAEpF,CAAC,GAAG,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;AAyBP,CAAC;AACD"} \ No newline at end of file +{"version":3,"sources":["../../../src/modules/seo/sitemapStyle.ts"],"sourcesContent":["/**\n * Built-in look of /sitemap.xml in a browser — served by the sitemap route itself\n * (`/sitemap.xml?style`), so projects ship NO sitemap.css and copy nothing.\n * Plain CSS on XML (W3C \"Associating Style Sheets with XML\", type=\"text/css\") —\n * not XSLT, which browsers are removing. Crawlers ignore it.\n */\n\nexport type SitemapStyleOptions = {\n /** Accent colour (card hover). Default '#027bd0'. Any plain CSS colour. */\n accent?: string\n /**\n * Line under the header — the technology provider. Default\n * \"Technology by Intecion.com\". `false` hides it.\n */\n credit?: false | string\n /** Header line. Default: the site name from Site Settings (sitemapRoute), else \"XML Sitemap\". */\n title?: string\n}\n\n/** Query parameter on the sitemap URL that returns the stylesheet instead of XML. */\nexport const SITEMAP_STYLE_PARAM = 'style'\nexport const DEFAULT_SITEMAP_CREDIT = 'Technology by Intecion.com'\n\n/** CSS `content: \"…\"` value — escapes backslashes, quotes and newlines. */\nconst cssString = (s: string) => `\"${s.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"').replace(/[\\r\\n]+/g, ' ')}\"`\n\n/** Only plain colour values — the option ends up inside a stylesheet. */\nconst safeColor = (c: string | undefined, fallback: string) =>\n c && /^(?:#[0-9a-f]{3,8}|[a-z]+|(?:rgb|hsl|oklch)a?\\([\\d\\s.,%/-]+\\))$/i.test(c.trim()) ? c.trim() : fallback\n\nexport function buildSitemapCss({ accent, credit, title }: SitemapStyleOptions = {}): string {\n const heading = title?.trim() || 'XML Sitemap'\n const note = credit === false ? '' : (credit ?? DEFAULT_SITEMAP_CREDIT).trim()\n const acc = safeColor(accent, '#027bd0')\n const divider = 'padding-bottom: 1.25rem; margin-bottom: 1.5rem; border-bottom: 1px solid var(--border);'\n\n return `:root {\n --bg: #fafafa; --card: #ffffff; --border: #e5e7eb; --border-hover: #d1d5db;\n --text-main: #111827; --text-secondary: #4b5563; --text-muted: #9ca3af; --url-color: #1e293b;\n --badge-bg: #f3f4f6; --badge-border: #e5e7eb; --badge-text: #4b5563; --accent: ${acc};\n}\n@media (prefers-color-scheme: dark) {\n :root {\n --bg: #090a0f; --card: #12131a; --border: #1e202e; --border-hover: #2e3247;\n --text-main: #f9fafb; --text-secondary: #9ca3af; --text-muted: #6b7280; --url-color: #f3f4f6;\n --badge-bg: #1a1c26; --badge-border: #282b3d; --badge-text: #9ca3af;\n }\n}\nurlset {\n display: flex; flex-direction: column; box-sizing: border-box; min-height: 100vh;\n max-width: 1040px; margin: 0 auto; padding: 3rem 1.5rem; line-height: 1.5;\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Inter, Helvetica, Arial, sans-serif;\n background-color: var(--bg); color: var(--text-main);\n}\nurlset::before {\n content: ${cssString(heading)};\n display: block; order: -2; font-size: 1.35rem; font-weight: 600; letter-spacing: -0.02em;\n color: var(--text-main); ${note ? 'padding-bottom: 0.4rem;' : divider}\n}\n${note ? `urlset::after {\n content: ${cssString(note)};\n display: block; order: -1; font-size: 0.8rem; color: var(--text-muted); ${divider}\n}\n` : ''}url {\n display: block; width: 100%; order: 0; box-sizing: border-box;\n background-color: var(--card); border: 1px solid var(--border); border-radius: 8px;\n padding: 1rem 1.25rem; margin-bottom: 0.65rem;\n transition: border-color 0.15s ease, box-shadow 0.15s ease;\n}\nurl:hover { border-color: var(--accent); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03); }\nloc {\n display: block; margin-bottom: 0.45rem; word-break: break-all; line-height: 1.45;\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", monospace;\n font-size: 0.875rem; font-weight: 500; color: var(--url-color);\n}\nlastmod, changefreq, priority {\n display: inline-block; font-size: 0.775rem; color: var(--text-secondary);\n margin-right: 1.25rem; margin-top: 0.15rem;\n}\nlastmod::before { content: \"Updated: \"; color: var(--text-muted); }\nchangefreq::before { content: \"Frequency: \"; color: var(--text-muted); }\npriority::before { content: \"Priority: \"; color: var(--text-muted); }\nlink {\n display: inline-block; font-size: 0.7rem; font-weight: 600; text-transform: uppercase;\n background-color: var(--badge-bg); border: 1px solid var(--badge-border); color: var(--badge-text);\n padding: 0.1rem 0.45rem; border-radius: 4px; margin-right: 0.3rem; margin-top: 0.35rem;\n}\nlink::before { content: attr(hreflang); }\n`\n}\n"],"names":["SITEMAP_STYLE_PARAM","DEFAULT_SITEMAP_CREDIT","cssString","s","replace","safeColor","c","fallback","test","trim","buildSitemapCss","accent","credit","title","heading","note","acc","divider"],"mappings":"AAAA;;;;;CAKC,GAcD,mFAAmF,GACnF,OAAO,MAAMA,sBAAsB,QAAO;AAC1C,OAAO,MAAMC,yBAAyB,6BAA4B;AAElE,yEAAyE,GACzE,MAAMC,YAAY,CAACC,IAAc,CAAC,CAAC,EAAEA,EAAEC,OAAO,CAAC,OAAO,QAAQA,OAAO,CAAC,MAAM,OAAOA,OAAO,CAAC,YAAY,KAAK,CAAC,CAAC;AAE9G,uEAAuE,GACvE,MAAMC,YAAY,CAACC,GAAuBC,WACxCD,KAAK,mEAAmEE,IAAI,CAACF,EAAEG,IAAI,MAAMH,EAAEG,IAAI,KAAKF;AAEtG,OAAO,SAASG,gBAAgB,EAAEC,MAAM,EAAEC,MAAM,EAAEC,KAAK,EAAuB,GAAG,CAAC,CAAC;IACjF,MAAMC,UAAUD,OAAOJ,UAAU;IACjC,MAAMM,OAAOH,WAAW,QAAQ,KAAK,AAACA,CAAAA,UAAUX,sBAAqB,EAAGQ,IAAI;IAC5E,MAAMO,MAAMX,UAAUM,QAAQ;IAC9B,MAAMM,UAAU;IAEhB,OAAO,CAAC;;;iFAGuE,EAAED,IAAI;;;;;;;;;;;;;;;;WAgB5E,EAAEd,UAAUY,SAAS;;2BAEL,EAAEC,OAAO,4BAA4BE,QAAQ;;AAExE,EAAEF,OAAO,CAAC;WACC,EAAEb,UAAUa,MAAM;0EAC6C,EAAEE,QAAQ;;AAEpF,CAAC,GAAG,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;AAyBP,CAAC;AACD"} \ No newline at end of file diff --git a/src/modules/links/buildLinkField.ts b/src/modules/links/buildLinkField.ts index 21adc76..2e67b90 100644 --- a/src/modules/links/buildLinkField.ts +++ b/src/modules/links/buildLinkField.ts @@ -1,6 +1,6 @@ import type { ArrayField, Field, GroupField } from 'payload' -import { rowLabel } from 'src/modules/admin-ui/rowLabel.js' +import { rowLabel } from '../admin-ui/rowLabel.js' export type LinkAppearance = 'link' | 'primary' | 'secondary' @@ -18,7 +18,7 @@ export type BuildLinkFieldOptions = { uploadTo?: string } -const URL_PATTERN = /^(https?:\/\/|mailto:|tel:|#)/ +const URL_PATTERN = /^(?:https?:\/\/|mailto:|tel:|#)/ type SiblingWithType = { type?: string } | undefined diff --git a/src/modules/seo/sitemapStyle.ts b/src/modules/seo/sitemapStyle.ts index 209a40d..ba45b98 100644 --- a/src/modules/seo/sitemapStyle.ts +++ b/src/modules/seo/sitemapStyle.ts @@ -26,7 +26,7 @@ const cssString = (s: string) => `"${s.replace(/\\/g, '\\\\').replace(/"/g, '\\" /** Only plain colour values — the option ends up inside a stylesheet. */ const safeColor = (c: string | undefined, fallback: string) => - c && /^(#[0-9a-f]{3,8}|[a-z]+|(rgb|hsl|oklch)a?\([\d\s.,%/-]+\))$/i.test(c.trim()) ? c.trim() : fallback + c && /^(?:#[0-9a-f]{3,8}|[a-z]+|(?:rgb|hsl|oklch)a?\([\d\s.,%/-]+\))$/i.test(c.trim()) ? c.trim() : fallback export function buildSitemapCss({ accent, credit, title }: SitemapStyleOptions = {}): string { const heading = title?.trim() || 'XML Sitemap'