@brandlab-digital/site-core 4.4.0 → 4.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"page-titles.js","sourceRoot":"","sources":["../src/page-titles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,CAAA;AAE3C,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,MAAM;IACN,SAAS;IACT,QAAQ;IACR,QAAQ;IACR,gBAAgB;IAChB,mBAAmB;IACnB,YAAY;IACZ,SAAS;CACD,CAAA;AAqCV,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAA;AAC/G,qHAAqH;AACrH,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,KAAK,CAAU,CAAA;AAE3C,SAAS,KAAK,CAAC,KAAyB,EAAE,KAAa;IACrD,MAAM,IAAI,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IAC/E,IAAI,CAAC,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,0BAA0B,KAAK,mBAAmB,CAAC,CAAA;IAC9E,OAAO,IAAI,CAAA;AACb,CAAC;AAED,gHAAgH;AAChH,MAAM,UAAU,SAAS,CAAC,MAAc;IACtC,OAAO,MAAM;SACV,IAAI,EAAE;SACN,KAAK,CAAC,KAAK,CAAC;SACZ,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QACn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A;IAClH,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACrC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC;QAAE,OAAO,cAAc,KAAK,oBAAoB,IAAI,qBAAqB,CAAA;IAC5G,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,cAAc,KAAK,+BAA+B,CAAA;IACpG,IAAI,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,cAAc,KAAK,oEAAoE,CAAA;IAC7H,IAAI,KAAK,CAAC,MAAM,GAAG,yBAAyB,IAAI,KAAK,CAAC,WAAW,EAAE,KAAK,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;QAC3F,OAAO,cAAc,KAAK,QAAQ,KAAK,CAAC,MAAM,+FAA+F,CAAA;IAC/I,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["/**\n * Titles and H1s for new pages (Site System v2 §5.2; correction #27). Earning pages keep their recorded titles\n * (`docs/recorded-titles.json`, check E1); every other page takes its family's pattern:\n *\n * | Family | Title | H1 |\n * |---|---|---|\n * | Home | `{Home phrase} \\| {Brand}` | `{Home phrase}` |\n * | Service | `{Service phrase} \\| {Brand}` | `{Service phrase}` |\n * | Region, suburb | `{Main service} {Place} \\| {Brand}` | `{Main service} {Place}` |\n * | Service-region hub, service in suburb | `{Service} {Place} \\| {Brand}` | `{Service} {Place}` |\n * | Cost guide | `{Service} Cost {Area} {Year} \\| {Brand}` | `{Service} cost {area} ({year})` |\n * | Project | `{Service} {Suburb}: {Job} \\| {Brand}` | `{Job}, {Suburb}` |\n *\n * Titles keep the compact keyword form \"{Service} {Place}\" and are at most 60 characters: the short brand only when\n * needed, never a cut keyword. One pipe separates the brand. A title carries no price and no proof tail (4.4.0,\n * Romie's 20 November 2026 rulings): `proofTail` and `tier` are gone, and prices stay in the page body.\n *\n * A location page's on-page H1 may read naturally, \"{Service} in {Place}\" or \"{Service} on the {Place}\": pass the\n * place with its place word (`definePlaceNames(...).get(slug).withPlaceWord`) as `placeWithWord`. Without it the H1\n * is the compact form, as before. The title is compact either way.\n */\n\nexport const BRANDLAB_TITLE_MAX_LENGTH = 60\n\nexport const BRANDLAB_TITLE_FAMILIES = [\n 'home',\n 'service',\n 'region',\n 'suburb',\n 'service-region',\n 'service-in-suburb',\n 'cost-guide',\n 'project',\n] as const\nexport type BrandlabTitleFamily = (typeof BRANDLAB_TITLE_FAMILIES)[number]\n\nexport interface BrandlabPageTitleInput {\n readonly family: BrandlabTitleFamily\n /** The full brand, for example \"AA Tree Services Sydney\". */\n readonly brand: string\n /** The short brand used when the full one would push the title past 60 characters. */\n readonly shortBrand?: string\n /** Home and service pages: the owned phrase, for example \"tree removal sydney\". */\n readonly phrase?: string\n /** Location, cost-guide and project pages: the service (the main service on region and suburb pages). */\n readonly service?: string\n /** The place's display name, for example \"Ryde\" or \"Western Sydney\". */\n readonly place?: string\n /**\n * Region, suburb, hub and service-in-suburb pages: the place with its place word, for a natural H1 (\"in Ryde\",\n * \"on the Northern Beaches\"; `withPlaceWord` from site-core/place-names). The title stays \"{Service} {Place}\".\n */\n readonly placeWithWord?: string\n /** Cost guides. */\n readonly year?: number\n /** Projects: the job, for example \"Gum tree removal over a pool\". */\n readonly job?: string\n}\n\nexport interface BrandlabPageTitle {\n /** The full `<title>` (pass it with `titleMode: 'absolute'`). */\n readonly title: string\n readonly h1: string\n /** The title before its first pipe. */\n readonly heading: string\n readonly length: number\n /** True only when the heading alone is over 60 characters: it is kept whole rather than cut. */\n readonly overLength: boolean\n}\n\nconst SMALL_WORDS = new Set(['a', 'an', 'and', 'as', 'at', 'but', 'by', 'for', 'of', 'on', 'or', 'to', 'with'])\n/** Words a service phrase never carries: the place word belongs between the service and the place, not inside it. */\nconst BANNED_WORDS = ['in', 'the'] as const\n\nfunction clean(value: string | undefined, field: string): string {\n const text = typeof value === 'string' ? value.trim().replace(/\\s+/g, ' ') : ''\n if (!text) throw new Error(`buildPageTitle needs a ${field} for this family.`)\n return text\n}\n\n/** Title case: every word capitalised except short joining words after the first; words in capitals stay so. */\nexport function titleCase(phrase: string): string {\n return phrase\n .trim()\n .split(/\\s+/)\n .map((word, index) => {\n if (word.length > 1 && word === word.toUpperCase() && /[A-Z]/.test(word)) return word\n const lower = word.toLowerCase()\n if (index > 0 && SMALL_WORDS.has(lower)) return lower\n return lower.charAt(0).toUpperCase() + lower.slice(1)\n })\n .join(' ')\n}\n\nfunction sentenceCase(phrase: string): string {\n const words = phrase.trim().split(/\\s+/)\n return words.map((word, index) => (word.length > 1 && word === word.toUpperCase() && /[A-Z]/.test(word) ? word : index === 0 ? word.charAt(0).toUpperCase() + word.slice(1).toLowerCase() : word.toLowerCase())).join(' ')\n}\n\nfunction bannedWordIn(service: string): string | undefined {\n const words = service.toLowerCase().split(/\\s+/)\n return BANNED_WORDS.find((banned) => words.includes(banned))\n}\n\n/** \"{Service} {Place}\", the compact title form: the service in title case and the place as named. The service has no \"in\" and no \"the\". */\nexport function locationHeading(service: string, place: string): string {\n const name = clean(service, 'service')\n const banned = bannedWordIn(name)\n if (banned) throw new Error(`A location heading has no \"${banned}\": \"${name}\" is not the short exact phrase.`)\n return `${titleCase(name)} ${clean(place, 'place')}`\n}\n\n/** The place words a natural location H1 may join the service and the place with. */\nexport const BRANDLAB_PLACE_WORDS = ['in', 'on'] as const\n\n/** \"{Service} in {Place}\": the service in title case, then the place with its own place word (\"on the Northern Beaches\"). */\nexport function naturalLocationHeading(service: string, placeWithWord: string): string {\n const name = clean(service, 'service')\n const banned = bannedWordIn(name)\n if (banned) throw new Error(`A location heading's service has no \"${banned}\": \"${name}\" is not the short exact phrase.`)\n const place = clean(placeWithWord, 'placeWithWord')\n if (!BRANDLAB_PLACE_WORDS.some((word) => place.toLowerCase().startsWith(`${word} `))) {\n throw new Error(`placeWithWord starts with the place word (\"in Ryde\", \"on the Northern Beaches\"); got \"${place}\".`)\n }\n return `${titleCase(name)} ${place}`\n}\n\nfunction fit(heading: string, input: BrandlabPageTitleInput): string {\n const brand = clean(input.brand, 'brand')\n const short = input.shortBrand?.trim() || brand\n const candidates = [`${heading} | ${brand}`, `${heading} | ${short}`]\n return candidates.find((candidate) => candidate.length <= BRANDLAB_TITLE_MAX_LENGTH) ?? heading\n}\n\n/** The title and H1 a new page of `family` takes. */\nexport function buildPageTitle(input: BrandlabPageTitleInput): BrandlabPageTitle {\n if (!(BRANDLAB_TITLE_FAMILIES as readonly string[]).includes(input.family)) {\n throw new Error(`buildPageTitle does not know the family \"${String(input.family)}\".`)\n }\n if ((input as { proofTail?: unknown }).proofTail !== undefined) {\n throw new Error('buildPageTitle takes no proof tail from 4.4.0: a title carries no price or proof tail (prices stay in the page body).')\n }\n const locationFamily = input.family !== 'home' && input.family !== 'service' && input.family !== 'cost-guide' && input.family !== 'project'\n if (input.placeWithWord !== undefined && !locationFamily) {\n throw new Error('placeWithWord is for region, suburb, hub and service-in-suburb pages.')\n }\n let heading: string\n let h1: string\n switch (input.family) {\n case 'home':\n case 'service': {\n const phrase = clean(input.phrase, 'phrase')\n const banned = bannedWordIn(phrase)\n if (banned) throw new Error(`An H1 has no \"${banned}\": \"${phrase}\" is not the short exact phrase.`)\n heading = titleCase(phrase)\n h1 = heading\n break\n }\n case 'cost-guide': {\n const service = clean(input.service, 'service')\n const place = clean(input.place, 'place')\n if (!Number.isInteger(input.year) || (input.year as number) < 2000) throw new Error('buildPageTitle needs the year a cost guide is for.')\n heading = `${titleCase(service)} Cost ${place} ${input.year}`\n h1 = `${sentenceCase(service)} cost ${place} (${input.year})`\n break\n }\n case 'project': {\n const job = clean(input.job, 'job')\n const place = clean(input.place, 'place')\n heading = `${locationHeading(clean(input.service, 'service'), place)}: ${job}`\n h1 = `${job}, ${place}`\n break\n }\n default: {\n heading = locationHeading(clean(input.service, 'service'), clean(input.place, 'place'))\n h1 = input.placeWithWord === undefined ? heading : naturalLocationHeading(clean(input.service, 'service'), input.placeWithWord)\n }\n }\n const title = fit(heading, input)\n return { title, h1, heading, length: title.length, overLength: heading.length > BRANDLAB_TITLE_MAX_LENGTH }\n}\n\n/** What check E1-pattern compares on a location page. */\nexport interface BrandlabLocationHeadingSample {\n readonly h1: string\n readonly title: string\n /** The place the page is for, as named. */\n readonly place: string\n}\n\nconst JOINER = new RegExp(`\\\\s+(?:${BRANDLAB_PLACE_WORDS.join('|')})(?:\\\\s+the)?$`, 'i')\nconst DOLLAR_FIGURE = /\\$\\s?\\d/\n\n/**\n * Why a location page's H1 and title break the pattern, or null when they keep it (4.4.0):\n * - the H1 names the service, then the place: \"{Service} {Place}\", or the natural \"{Service} in {Place}\" /\n * \"{Service} on the {Place}\"; the service itself has no \"in\" and no \"the\";\n * - the title starts with the compact \"{Service} {Place}\" (or with the H1, letter case aside), has at most two\n * pipes, carries no dollar figure and is at most 60 characters.\n */\nexport function locationHeadingProblem(sample: BrandlabLocationHeadingSample): string | null {\n const h1 = sample.h1.trim().replace(/\\s+/g, ' ')\n const title = sample.title.trim().replace(/\\s+/g, ' ')\n const place = sample.place.trim().replace(/\\s+/g, ' ')\n const lowerH1 = h1.toLowerCase()\n const lowerPlace = place.toLowerCase()\n if (!lowerH1.endsWith(` ${lowerPlace}`) && lowerH1 !== lowerPlace) {\n return `the H1 \"${h1}\" is not \"{Service} {Place}\" or \"{Service} in {Place}\": it never ends with the place (\"${place}\").`\n }\n // \"Tree Removal in Ryde\" and \"Tree Removal on the Northern Beaches\" name the service before the place word.\n const service = h1.slice(0, h1.length - place.length).trim().replace(JOINER, '').trim()\n if (!service || (BRANDLAB_PLACE_WORDS as readonly string[]).includes(service.toLowerCase())) return `the H1 \"${h1}\" names the place without the service.`\n const words = service.toLowerCase().split(' ')\n if (words.includes('in')) return `the H1 \"${h1}\" has \"in\" inside the service; it reads \"{Service} {Place}\" or \"{Service} in {Place}\".`\n if (words.includes('the')) return `the H1 \"${h1}\" has \"the\" inside the service; it reads \"{Service} {Place}\" or \"{Service} in {Place}\".`\n const compact = `${service} ${place}`\n const lowerTitle = title.toLowerCase()\n const lead = [compact, h1].find((candidate) => lowerTitle.startsWith(candidate.toLowerCase()))\n if (lead === undefined) return `the title \"${title}\" never starts with \"${compact}\" (the H1's service and place).`\n const rest = title.slice(lead.length)\n if (rest && !rest.startsWith(' | ')) return `the title \"${title}\" adds words to \"${lead}\" before its brand.`\n if ((title.match(/\\|/g) ?? []).length > 2) return `the title \"${title}\" chains more than two pipes.`\n if (DOLLAR_FIGURE.test(title)) return `the title \"${title}\" carries a price; prices stay in the page body, never in a title.`\n if (title.length > BRANDLAB_TITLE_MAX_LENGTH && title.toLowerCase() !== lead.toLowerCase()) {\n return `the title \"${title}\" is ${title.length} characters; titles are at most 60 characters (drop or shorten the brand, never the keyword).`\n }\n return null\n}\n"]}
1
+ {"version":3,"file":"page-titles.js","sourceRoot":"","sources":["../src/page-titles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,CAAA;AAE3C,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,MAAM;IACN,SAAS;IACT,QAAQ;IACR,QAAQ;IACR,gBAAgB;IAChB,mBAAmB;IACnB,YAAY;IACZ,SAAS;CACD,CAAA;AAqCV,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAA;AAC/G,qHAAqH;AACrH,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,KAAK,CAAU,CAAA;AAE3C,SAAS,KAAK,CAAC,KAAyB,EAAE,KAAa;IACrD,MAAM,IAAI,GAAG,OAAO,KAA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 §5.2; correction #27). Earning pages keep their recorded titles\n * (`docs/recorded-titles.json`, check E1); every other page takes its family's pattern:\n *\n * | Family | Title | H1 |\n * |---|---|---|\n * | Home | `{Home phrase} \\| {Brand}` | `{Home phrase}` |\n * | Service | `{Service phrase} \\| {Brand}` | `{Service phrase}` |\n * | Region, suburb | `{Main service} {Place} \\| {Brand}` | `{Main service} {Place}` |\n * | Service-region hub, service in suburb | `{Service} {Place} \\| {Brand}` | `{Service} {Place}` |\n * | Cost guide | `{Service} Cost {Area} {Year} \\| {Brand}` | `{Service} cost {area} ({year})` |\n * | Project | `{Service} {Suburb}: {Job} \\| {Brand}` | `{Job}, {Suburb}` |\n *\n * Titles keep the compact keyword form \"{Service} {Place}\" and are at most 60 characters: the short brand only when\n * needed, never a cut keyword. One pipe separates the brand. A title carries no price and no proof tail (4.4.0,\n * Romie's 20 November 2026 rulings): `proofTail` and `tier` are gone, and prices stay in the page body.\n *\n * A location page's on-page H1 may read naturally, \"{Service} in {Place}\" or \"{Service} on the {Place}\": pass the\n * place with its place word (`definePlaceNames(...).get(slug).withPlaceWord`) as `placeWithWord`. Without it the H1\n * is the compact form, as before. The title is compact either way.\n */\n\nexport const BRANDLAB_TITLE_MAX_LENGTH = 60\n\nexport const BRANDLAB_TITLE_FAMILIES = [\n 'home',\n 'service',\n 'region',\n 'suburb',\n 'service-region',\n 'service-in-suburb',\n 'cost-guide',\n 'project',\n] as const\nexport type BrandlabTitleFamily = (typeof BRANDLAB_TITLE_FAMILIES)[number]\n\nexport interface BrandlabPageTitleInput {\n readonly family: BrandlabTitleFamily\n /** The full brand, for example \"AA Tree Services Sydney\". */\n readonly brand: string\n /** The short brand used when the full one would push the title past 60 characters. */\n readonly shortBrand?: string\n /** Home and service pages: the owned phrase, for example \"tree removal sydney\". */\n readonly phrase?: string\n /** Location, cost-guide and project pages: the service (the main service on region and suburb pages). */\n readonly service?: string\n /** The place's display name, for example \"Ryde\" or \"Western Sydney\". */\n readonly place?: string\n /**\n * Region, suburb, hub and service-in-suburb pages: the place with its place word, for a natural H1 (\"in Ryde\",\n * \"on the Northern Beaches\"; `withPlaceWord` from site-core/place-names). The title stays \"{Service} {Place}\".\n */\n readonly placeWithWord?: string\n /** Cost guides. */\n readonly year?: number\n /** Projects: the job, for example \"Gum tree removal over a pool\". */\n readonly job?: string\n}\n\nexport interface BrandlabPageTitle {\n /** The full `<title>` (pass it with `titleMode: 'absolute'`). */\n readonly title: string\n readonly h1: string\n /** The title before its first pipe. */\n readonly heading: string\n readonly length: number\n /** True only when the heading alone is over 60 characters: it is kept whole rather than cut. */\n readonly overLength: boolean\n}\n\nconst SMALL_WORDS = new Set(['a', 'an', 'and', 'as', 'at', 'but', 'by', 'for', 'of', 'on', 'or', 'to', 'with'])\n/** Words a service phrase never carries: the place word belongs between the service and the place, not inside it. */\nconst BANNED_WORDS = ['in', 'the'] as const\n\nfunction clean(value: string | undefined, field: string): string {\n const text = typeof value === 'string' ? value.trim().replace(/\\s+/g, ' ') : ''\n if (!text) throw new Error(`buildPageTitle needs a ${field} for this family.`)\n return text\n}\n\n/** Title case: every word capitalised except short joining words after the first; words in capitals stay so. */\nexport function titleCase(phrase: string): string {\n return phrase\n .trim()\n .split(/\\s+/)\n .map((word, index) => {\n if (word.length > 1 && word === word.toUpperCase() && /[A-Z]/.test(word)) return word\n const lower = word.toLowerCase()\n if (index > 0 && SMALL_WORDS.has(lower)) return lower\n return lower.charAt(0).toUpperCase() + lower.slice(1)\n })\n .join(' ')\n}\n\nfunction sentenceCase(phrase: string): string {\n const words = phrase.trim().split(/\\s+/)\n return words.map((word, index) => (word.length > 1 && word === word.toUpperCase() && /[A-Z]/.test(word) ? word : index === 0 ? word.charAt(0).toUpperCase() + word.slice(1).toLowerCase() : word.toLowerCase())).join(' ')\n}\n\nfunction bannedWordIn(service: string): string | undefined {\n const words = service.toLowerCase().split(/\\s+/)\n return BANNED_WORDS.find((banned) => words.includes(banned))\n}\n\n/** \"{Service} {Place}\", the compact title form: the service in title case and the place as named. The service has no \"in\" and no \"the\". */\nexport function locationHeading(service: string, place: string): string {\n const name = clean(service, 'service')\n const banned = bannedWordIn(name)\n if (banned) throw new Error(`A location heading has no \"${banned}\": \"${name}\" is not the short exact phrase.`)\n return `${titleCase(name)} ${clean(place, 'place')}`\n}\n\n/** The place words a natural location H1 may join the service and the place with. */\nexport const BRANDLAB_PLACE_WORDS = ['in', 'on'] as const\n\n/** \"{Service} in {Place}\": the service in title case, then the place with its own place word (\"on the Northern Beaches\"). */\nexport function naturalLocationHeading(service: string, placeWithWord: string): string {\n const name = clean(service, 'service')\n const banned = bannedWordIn(name)\n if (banned) throw new Error(`A location heading's service has no \"${banned}\": \"${name}\" is not the short exact phrase.`)\n const place = clean(placeWithWord, 'placeWithWord')\n if (!BRANDLAB_PLACE_WORDS.some((word) => place.toLowerCase().startsWith(`${word} `))) {\n throw new Error(`placeWithWord starts with the place word (\"in Ryde\", \"on the Northern Beaches\"); got \"${place}\".`)\n }\n return `${titleCase(name)} ${place}`\n}\n\nfunction fit(heading: string, input: BrandlabPageTitleInput): string {\n const brand = clean(input.brand, 'brand')\n const short = input.shortBrand?.trim() || brand\n const candidates = [`${heading} | ${brand}`, `${heading} | ${short}`]\n return candidates.find((candidate) => candidate.length <= BRANDLAB_TITLE_MAX_LENGTH) ?? heading\n}\n\n/** The title and H1 a new page of `family` takes. */\nexport function buildPageTitle(input: BrandlabPageTitleInput): BrandlabPageTitle {\n if (!(BRANDLAB_TITLE_FAMILIES as readonly string[]).includes(input.family)) {\n throw new Error(`buildPageTitle does not know the family \"${String(input.family)}\".`)\n }\n if ((input as { proofTail?: unknown }).proofTail !== undefined) {\n throw new Error('buildPageTitle takes no proof tail from 4.4.0: a title carries no price or proof tail (prices stay in the page body).')\n }\n const locationFamily = input.family !== 'home' && input.family !== 'service' && input.family !== 'cost-guide' && input.family !== 'project'\n if (input.placeWithWord !== undefined && !locationFamily) {\n throw new Error('placeWithWord is for region, suburb, hub and service-in-suburb pages.')\n }\n let heading: string\n let h1: string\n switch (input.family) {\n case 'home':\n case 'service': {\n const phrase = clean(input.phrase, 'phrase')\n const banned = bannedWordIn(phrase)\n if (banned) throw new Error(`An H1 has no \"${banned}\": \"${phrase}\" is not the short exact phrase.`)\n heading = titleCase(phrase)\n h1 = heading\n break\n }\n case 'cost-guide': {\n const service = clean(input.service, 'service')\n const place = clean(input.place, 'place')\n if (!Number.isInteger(input.year) || (input.year as number) < 2000) throw new Error('buildPageTitle needs the year a cost guide is for.')\n heading = `${titleCase(service)} Cost ${place} ${input.year}`\n h1 = `${sentenceCase(service)} cost ${place} (${input.year})`\n break\n }\n case 'project': {\n const job = clean(input.job, 'job')\n const place = clean(input.place, 'place')\n heading = `${locationHeading(clean(input.service, 'service'), place)}: ${job}`\n h1 = `${job}, ${place}`\n break\n }\n default: {\n heading = locationHeading(clean(input.service, 'service'), clean(input.place, 'place'))\n h1 = input.placeWithWord === undefined ? heading : naturalLocationHeading(clean(input.service, 'service'), input.placeWithWord)\n }\n }\n const title = fit(heading, input)\n return { title, h1, heading, length: title.length, overLength: heading.length > BRANDLAB_TITLE_MAX_LENGTH }\n}\n\n/** What check E1-pattern compares on a location page. */\nexport interface BrandlabLocationHeadingSample {\n readonly h1: string\n readonly title: string\n /** The place the page is for, as named. */\n readonly place: string\n}\n\nconst JOINER = new RegExp(`\\\\s+(?:${BRANDLAB_PLACE_WORDS.join('|')})(?:\\\\s+the)?$`, 'i')\nconst DOLLAR_FIGURE = /\\$\\s?\\d/\n\n/**\n * Why a location page's H1 and title break the pattern, or null when they keep it (4.4.0):\n * - the H1 names the service, then the place: \"{Service} {Place}\", or the natural \"{Service} in {Place}\" /\n * \"{Service} on the {Place}\"; the service itself has no \"in\" and no \"the\";\n * - the title starts with the compact \"{Service} {Place}\" (or with the H1, letter case aside), has at most two\n * pipes and carries no dollar figure. Length is advice, not a rule (4.4.1): see `locationTitleAdvice`.\n */\nexport function locationHeadingProblem(sample: BrandlabLocationHeadingSample): string | null {\n const h1 = sample.h1.trim().replace(/\\s+/g, ' ')\n const title = sample.title.trim().replace(/\\s+/g, ' ')\n const place = sample.place.trim().replace(/\\s+/g, ' ')\n const lowerH1 = h1.toLowerCase()\n const lowerPlace = place.toLowerCase()\n if (!lowerH1.endsWith(` ${lowerPlace}`) && lowerH1 !== lowerPlace) {\n return `the H1 \"${h1}\" is not \"{Service} {Place}\" or \"{Service} in {Place}\": it never ends with the place (\"${place}\").`\n }\n // \"Tree Removal in Ryde\" and \"Tree Removal on the Northern Beaches\" name the service before the place word.\n const service = h1.slice(0, h1.length - place.length).trim().replace(JOINER, '').trim()\n if (!service || (BRANDLAB_PLACE_WORDS as readonly string[]).includes(service.toLowerCase())) return `the H1 \"${h1}\" names the place without the service.`\n const words = service.toLowerCase().split(' ')\n if (words.includes('in')) return `the H1 \"${h1}\" has \"in\" inside the service; it reads \"{Service} {Place}\" or \"{Service} in {Place}\".`\n if (words.includes('the')) return `the H1 \"${h1}\" has \"the\" inside the service; it reads \"{Service} {Place}\" or \"{Service} in {Place}\".`\n const compact = `${service} ${place}`\n const lowerTitle = title.toLowerCase()\n const lead = [compact, h1].find((candidate) => lowerTitle.startsWith(candidate.toLowerCase()))\n if (lead === undefined) return `the title \"${title}\" never starts with \"${compact}\" (the H1's service and place).`\n const rest = title.slice(lead.length)\n if (rest && !rest.startsWith(' | ')) return `the title \"${title}\" adds words to \"${lead}\" before its brand.`\n if ((title.match(/\\|/g) ?? []).length > 2) return `the title \"${title}\" chains more than two pipes.`\n if (DOLLAR_FIGURE.test(title)) return `the title \"${title}\" carries a price; prices stay in the page body, never in a title.`\n return null\n}\n\n/**\n * Advice on a title's length, or null (4.4.1). About 60 characters is an editing aid, not a limit (seo/RULES.md):\n * a longer title is never a failure, and the keyword is never cut to fit.\n */\nexport function locationTitleAdvice(title: string): string | null {\n const text = title.trim().replace(/\\s+/g, ' ')\n if (text.length <= BRANDLAB_TITLE_MAX_LENGTH) return null\n return `the title \"${text}\" is ${text.length} characters; about ${BRANDLAB_TITLE_MAX_LENGTH} is the editing aid (shorten or drop the brand if it reads long, never the keyword).`\n}\n"]}
@@ -141,20 +141,30 @@ export type BrandlabSectionOrders = Readonly<Record<BrandlabPageFamily, Brandlab
141
141
  /**
142
142
  * Declares a site's section orders (`src/data/strategy.ts`): the defaults for every family, the trade's rules and any
143
143
  * recorded alternative orders. A recorded order keeps every required and conditional section, the first section
144
- * first, the CTA band last and the proof strip within the first five; the contact page can't be reordered.
144
+ * first, the CTA band last and the proof strip within the first five; the contact page takes its order from its brief instead.
145
145
  */
146
146
  export declare function defineSectionOrder(input?: BrandlabSectionOrderInput, tradeMap?: Readonly<Partial<Record<BrandlabTrade, BrandlabTradeSectionRules>>>): BrandlabSectionOrders;
147
147
  /** The sections a page may open with. */
148
148
  export declare const LEAD_SECTIONS: readonly BrandlabSectionId[];
149
+ /**
150
+ * The sections a briefed page may carry more than once (4.4.2), because briefs really do call for several of them: a
151
+ * guide's or policy's text under several headings (`article-body`), a second kind of job on a service page beside its
152
+ * methods (`service-detail`), a guide hub's groups of guide cards (`guides`) and an FAQ page's topic groups (`faqs`).
153
+ * Each repeat is its own section with its own H2. Every other section stays once a page.
154
+ */
155
+ export declare const REPEATABLE_SECTIONS: readonly BrandlabSectionId[];
149
156
  /**
150
157
  * The order one page's brief sets (4.4.0). The brief lists the page's sections in its own order; nothing is taken
151
158
  * from the family's default order except the cap and the signature limit. The only rules are structural:
152
159
  * - the page opens with its hero, page header or article header;
153
- * - the CTA band, when the brief has one, comes last (the contact page has none and keeps its own two sections);
160
+ * - the CTA band, when the brief has one, comes last;
154
161
  * - a suburb page keeps its area map (`area-map`), which carries the links to nearby suburbs;
155
- * - no section is listed twice.
156
- * The lead, the CTA band and a suburb page's area map are required; every other listed section is conditional: it
157
- * renders when its data exists and otherwise says what is missing. Pass the result to `planSectionSequence`.
162
+ * - the contact page (4.4.2) opens with its page header and carries the contact block (`contact`), which belongs to
163
+ * that page alone; its brief sets the rest (what happens next, a fallen-tree panel, other ways to reach the business);
164
+ * - no section is listed twice, except those in `REPEATABLE_SECTIONS` (4.4.2).
165
+ * The lead, the CTA band, a suburb page's area map and the contact page's contact block are required; every other
166
+ * listed section is conditional: it renders when its data exists and otherwise says what is missing. Pass the result
167
+ * to `planSectionSequence`, with one candidate per listed section in the same order.
158
168
  */
159
169
  export declare function briefSectionOrder(family: BrandlabPageFamily, sections: readonly BrandlabSectionId[]): BrandlabFamilyOrder;
160
170
  /** The reasons the sequencer itself skips a section. */
@@ -1 +1 @@
1
- {"version":3,"file":"section-order.d.ts","sourceRoot":"","sources":["../src/section-order.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,eAAO,MAAM,oBAAoB,0bAmCvB,CAAA;AACV,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAA;AAErE,eAAO,MAAM,sBAAsB,kPAoBzB,CAAA;AACV,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAA;AAExE,mHAAmH;AACnH,eAAO,MAAM,6BAA6B,iCAAkC,CAAA;AAC5E,MAAM,MAAM,0BAA0B,GAAG,CAAC,OAAO,6BAA6B,CAAC,CAAC,MAAM,CAAC,CAAA;AAEvF,mGAAmG;AACnG,eAAO,MAAM,sBAAsB,iDAAkD,CAAA;AACrF,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAA;AAEzE,uHAAuH;AACvH,MAAM,MAAM,0BAA0B,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;AAElE,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,EAAE,EAAE,iBAAiB,CAAA;IAC9B,QAAQ,CAAC,WAAW,EAAE,0BAA0B,CAAA;IAChD,4FAA4F;IAC5F,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAA;IACpD,qGAAqG;I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;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,mBAAmB,EAC1B,UAAU,EAAE,SAAS,yBAAyB,EAAE,EAChD,IAAI,CAAC,EAAE,MAAM,GACZ,oBAAoB,CAyItB"}
@@ -263,7 +263,7 @@ const DEFAULT_ROWS = {
263
263
  ['faqs', 'R'],
264
264
  ['cta', 'R'],
265
265
  ],
266
- // The contact page is the page header and the contact block, and nothing else (K12-contact).
266
+ // Without a brief the contact page is the page header and the contact block; its brief may add sections (4.4.2).
267
267
  contact: [
268
268
  ['page-header', 'R'],
269
269
  ['contact', 'R'],
@@ -443,7 +443,7 @@ function recordedOrder(base, recorded) {
443
443
  throw new Error(`Recorded section order for ${family}: ${detail}`);
444
444
  };
445
445
  if (family === 'contact')
446
- fail('the contact page is the page header and the contact block, and nothing else.');
446
+ fail("the contact page takes its order from its brief (briefSectionOrder), not a recorded family order; without one it is the page header and the contact block, and nothing else.");
447
447
  if (typeof recorded.decision !== 'string' || !recorded.decision.trim())
448
448
  fail('decision must say who decided and why.');
449
449
  if (typeof recorded.recordedOn !== 'string' || !ISO_DATE.test(recorded.recordedOn) || Number.isNaN(Date.parse(recorded.recordedOn))) {
@@ -484,7 +484,7 @@ function recordedOrder(base, recorded) {
484
484
  /**
485
485
  * Declares a site's section orders (`src/data/strategy.ts`): the defaults for every family, the trade's rules and any
486
486
  * recorded alternative orders. A recorded order keeps every required and conditional section, the first section
487
- * first, the CTA band last and the proof strip within the first five; the contact page can't be reordered.
487
+ * first, the CTA band last and the proof strip within the first five; the contact page takes its order from its brief instead.
488
488
  */
489
489
  export function defineSectionOrder(input = {}, tradeMap = SECTION_ORDER_TRADE_MAP) {
490
490
  if (input.trade !== undefined && !BRANDLAB_TRADES.includes(input.trade)) {
@@ -503,15 +503,25 @@ export function defineSectionOrder(input = {}, tradeMap = SECTION_ORDER_TRADE_MA
503
503
  }
504
504
  /** The sections a page may open with. */
505
505
  export const LEAD_SECTIONS = Object.freeze(['hero', 'page-header', 'article-header']);
506
+ /**
507
+ * The sections a briefed page may carry more than once (4.4.2), because briefs really do call for several of them: a
508
+ * guide's or policy's text under several headings (`article-body`), a second kind of job on a service page beside its
509
+ * methods (`service-detail`), a guide hub's groups of guide cards (`guides`) and an FAQ page's topic groups (`faqs`).
510
+ * Each repeat is its own section with its own H2. Every other section stays once a page.
511
+ */
512
+ export const REPEATABLE_SECTIONS = Object.freeze(['article-body', 'service-detail', 'guides', 'faqs']);
506
513
  /**
507
514
  * The order one page's brief sets (4.4.0). The brief lists the page's sections in its own order; nothing is taken
508
515
  * from the family's default order except the cap and the signature limit. The only rules are structural:
509
516
  * - the page opens with its hero, page header or article header;
510
- * - the CTA band, when the brief has one, comes last (the contact page has none and keeps its own two sections);
517
+ * - the CTA band, when the brief has one, comes last;
511
518
  * - a suburb page keeps its area map (`area-map`), which carries the links to nearby suburbs;
512
- * - no section is listed twice.
513
- * The lead, the CTA band and a suburb page's area map are required; every other listed section is conditional: it
514
- * renders when its data exists and otherwise says what is missing. Pass the result to `planSectionSequence`.
519
+ * - the contact page (4.4.2) opens with its page header and carries the contact block (`contact`), which belongs to
520
+ * that page alone; its brief sets the rest (what happens next, a fallen-tree panel, other ways to reach the business);
521
+ * - no section is listed twice, except those in `REPEATABLE_SECTIONS` (4.4.2).
522
+ * The lead, the CTA band, a suburb page's area map and the contact page's contact block are required; every other
523
+ * listed section is conditional: it renders when its data exists and otherwise says what is missing. Pass the result
524
+ * to `planSectionSequence`, with one candidate per listed section in the same order.
515
525
  */
516
526
  export function briefSectionOrder(family, sections) {
517
527
  const fail = (detail) => {
@@ -519,17 +529,15 @@ export function briefSectionOrder(family, sections) {
519
529
  };
520
530
  if (!BRANDLAB_PAGE_FAMILIES.includes(family))
521
531
  throw new Error(`Unknown page family "${String(family)}".`);
522
- if (family === 'contact')
523
- fail('the contact page is the page header and the contact block, and nothing else.');
524
532
  if (!Array.isArray(sections) || sections.length === 0)
525
533
  fail('list the sections the brief calls for.');
526
534
  const seen = new Set();
527
535
  for (const id of sections) {
528
536
  if (!BRANDLAB_SECTION_IDS.includes(id))
529
537
  fail(`"${String(id)}" is not a section.`);
530
- if (id === 'contact')
538
+ if (id === 'contact' && family !== 'contact')
531
539
  fail('the contact block belongs to the contact page.');
532
- if (seen.has(id) && id !== 'signature')
540
+ if (seen.has(id) && id !== 'signature' && !REPEATABLE_SECTIONS.includes(id))
533
541
  fail(`"${id}" appears twice.`);
534
542
  seen.add(id);
535
543
  }
@@ -541,11 +549,20 @@ export function briefSectionOrder(family, sections) {
541
549
  const cta = sections.indexOf('cta');
542
550
  if (cta !== -1 && cta !== sections.length - 1)
543
551
  fail('the CTA band comes last.');
552
+ if (family === 'contact' && first !== 'page-header')
553
+ fail('the contact page opens with its page header ("page-header").');
554
+ if (family === 'contact' && !seen.has('contact'))
555
+ fail('the contact page carries the contact block ("contact").');
544
556
  if (family === 'suburb' && !seen.has('area-map'))
545
557
  fail('a suburb page keeps its area map ("area-map"), which carries the links to nearby suburbs.');
546
558
  if (sections.filter((id) => id === 'signature').length > 1)
547
559
  fail('"signature" appears twice; list its place once.');
548
- const required = new Set([first, 'cta', ...(family === 'suburb' ? ['area-map'] : [])]);
560
+ const required = new Set([
561
+ first,
562
+ 'cta',
563
+ ...(family === 'suburb' ? ['area-map'] : []),
564
+ ...(family === 'contact' ? ['contact'] : []),
565
+ ]);
549
566
  return Object.freeze({
550
567
  family,
551
568
  cap: SECTION_CAPS[family],
@@ -648,8 +665,11 @@ export function planSectionSequence(order, candidates, page) {
648
665
  skipped.push({ id: entry.id, section: entry.id, requirement: entry.requirement, reason: 'not-provided' });
649
666
  continue;
650
667
  }
668
+ // A section the order lists more than once (4.4.2) takes one candidate per place, in the order they were given;
669
+ // the last place takes whatever is left, so a spare candidate still reads as a duplicate.
670
+ const laterPlaces = order.entries.slice(order.entries.indexOf(entry) + 1).some((later) => later.id === entry.id);
651
671
  let filled = false;
652
- for (const { candidate, index } of matches) {
672
+ for (const { candidate, index } of laterPlaces ? matches.slice(0, 1) : matches) {
653
673
  used.add(index);
654
674
  const ready = candidate.ready ?? SECTION_READY;
655
675
  if (filled)