@brandlab-digital/site-core 4.3.0 → 4.4.0
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.
- package/README.md +31 -5
- package/dist/page-titles.d.ts +22 -11
- package/dist/page-titles.d.ts.map +1 -1
- package/dist/page-titles.js +55 -30
- package/dist/page-titles.js.map +1 -1
- package/dist/project.d.ts +15 -0
- package/dist/project.d.ts.map +1 -1
- package/dist/project.js +22 -1
- package/dist/project.js.map +1 -1
- package/dist/section-order.d.ts +20 -2
- package/dist/section-order.d.ts.map +1 -1
- package/dist/section-order.js +56 -0
- package/dist/section-order.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -194,11 +194,37 @@ Pass `{ ...siteStrategy, on }` for the options.
|
|
|
194
194
|
|
|
195
195
|
### Titles and H1s (`./page-titles`)
|
|
196
196
|
|
|
197
|
-
`buildPageTitle({ family, brand, shortBrand?, phrase?, service?, place?,
|
|
198
|
-
v2 §5.2's patterns: "{Service} {Place}" for region, suburb, service-region and service-in-suburb
|
|
199
|
-
|
|
200
|
-
brand, then dropping the brand, never cutting the keyword.
|
|
201
|
-
|
|
197
|
+
`buildPageTitle({ family, brand, shortBrand?, phrase?, service?, place?, placeWithWord?, year?, job? })` writes
|
|
198
|
+
v2 §5.2's patterns: the compact "{Service} {Place}" title for region, suburb, service-region and service-in-suburb
|
|
199
|
+
pages, the home and service phrases, cost guides and projects; titles stay within 60 characters by using the short
|
|
200
|
+
brand, then dropping the brand, never cutting the keyword. From 4.4.0 a title carries no price or proof tail
|
|
201
|
+
(`proofTail` and `tier` are removed; passing `proofTail` throws). A location page's on-page H1 may read naturally:
|
|
202
|
+
pass `placeWithWord` (`definePlaceNames(...).get(slug).withPlaceWord`, "in Ryde", "on the Northern Beaches") and the
|
|
203
|
+
H1 is "Tree Removal in Ryde" while the title stays "Tree Removal Ryde | Brand". Without it the H1 is the compact form.
|
|
204
|
+
Pass the `title` with `titleMode: 'absolute'`. `locationHeadingProblem` is the rule check E1-pattern applies; it
|
|
205
|
+
accepts both H1 forms.
|
|
206
|
+
|
|
207
|
+
### A page's own section order (`briefSectionOrder` in `./section-order`, from 4.4.0)
|
|
208
|
+
|
|
209
|
+
Each page's search brief sets its section order. `briefSectionOrder(family, sections)` turns the brief's list into
|
|
210
|
+
the order `planSectionSequence` takes, and the manifest then says `order: 'brief'`:
|
|
211
|
+
|
|
212
|
+
```ts
|
|
213
|
+
const order = briefSectionOrder('suburb', ['hero', 'area-map', 'reviews', 'services', 'local-facts', 'cta'])
|
|
214
|
+
const plan = planSectionSequence(order, candidates, path)
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
Only structure is enforced: the page opens with its hero, page header or article header; the CTA band, when listed,
|
|
218
|
+
is last; a suburb page keeps its `area-map`; nothing is listed twice. Every other listed section is conditional
|
|
219
|
+
(it renders when its data exists and otherwise names what is missing). The family defaults (`defaultSectionOrder`,
|
|
220
|
+
`defineSectionOrder`) are unchanged and remain the order for a page without a brief.
|
|
221
|
+
|
|
222
|
+
### The site's kit tones (`siteSystem.kit` in `./project`, from 4.4.0)
|
|
223
|
+
|
|
224
|
+
`siteSystem: { tier, kit: { tones: { band: 2, 'ink-panel': 1 } } }` records the section tones the site's own design
|
|
225
|
+
kit limits, by the `data-tone` name its sections carry, and how many sections of each a page may carry (1 to 12). The
|
|
226
|
+
ready gate's K8 reads it. A tone that is not listed has no limit; a site that declares no kit keeps one `band` section
|
|
227
|
+
a page.
|
|
202
228
|
|
|
203
229
|
### Trade map (`./section-order`)
|
|
204
230
|
|
package/dist/page-titles.d.ts
CHANGED
|
@@ -11,9 +11,13 @@
|
|
|
11
11
|
* | Cost guide | `{Service} Cost {Area} {Year} \| {Brand}` | `{Service} cost {area} ({year})` |
|
|
12
12
|
* | Project | `{Service} {Suburb}: {Job} \| {Brand}` | `{Job}, {Suburb}` |
|
|
13
13
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
14
|
+
* Titles keep the compact keyword form "{Service} {Place}" and are at most 60 characters: the short brand only when
|
|
15
|
+
* needed, never a cut keyword. One pipe separates the brand. A title carries no price and no proof tail (4.4.0,
|
|
16
|
+
* Romie's 20 November 2026 rulings): `proofTail` and `tier` are gone, and prices stay in the page body.
|
|
17
|
+
*
|
|
18
|
+
* A location page's on-page H1 may read naturally, "{Service} in {Place}" or "{Service} on the {Place}": pass the
|
|
19
|
+
* place with its place word (`definePlaceNames(...).get(slug).withPlaceWord`) as `placeWithWord`. Without it the H1
|
|
20
|
+
* is the compact form, as before. The title is compact either way.
|
|
17
21
|
*/
|
|
18
22
|
export declare const BRANDLAB_TITLE_MAX_LENGTH = 60;
|
|
19
23
|
export declare const BRANDLAB_TITLE_FAMILIES: readonly ["home", "service", "region", "suburb", "service-region", "service-in-suburb", "cost-guide", "project"];
|
|
@@ -30,10 +34,11 @@ export interface BrandlabPageTitleInput {
|
|
|
30
34
|
readonly service?: string;
|
|
31
35
|
/** The place's display name, for example "Ryde" or "Western Sydney". */
|
|
32
36
|
readonly place?: string;
|
|
33
|
-
/**
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Region, suburb, hub and service-in-suburb pages: the place with its place word, for a natural H1 ("in Ryde",
|
|
39
|
+
* "on the Northern Beaches"; `withPlaceWord` from site-core/place-names). The title stays "{Service} {Place}".
|
|
40
|
+
*/
|
|
41
|
+
readonly placeWithWord?: string;
|
|
37
42
|
/** Cost guides. */
|
|
38
43
|
readonly year?: number;
|
|
39
44
|
/** Projects: the job, for example "Gum tree removal over a pool". */
|
|
@@ -51,8 +56,12 @@ export interface BrandlabPageTitle {
|
|
|
51
56
|
}
|
|
52
57
|
/** Title case: every word capitalised except short joining words after the first; words in capitals stay so. */
|
|
53
58
|
export declare function titleCase(phrase: string): string;
|
|
54
|
-
/** "{Service} {Place}": the service in title case and the place as named. The service has no "in" and no "the". */
|
|
59
|
+
/** "{Service} {Place}", the compact title form: the service in title case and the place as named. The service has no "in" and no "the". */
|
|
55
60
|
export declare function locationHeading(service: string, place: string): string;
|
|
61
|
+
/** The place words a natural location H1 may join the service and the place with. */
|
|
62
|
+
export declare const BRANDLAB_PLACE_WORDS: readonly ["in", "on"];
|
|
63
|
+
/** "{Service} in {Place}": the service in title case, then the place with its own place word ("on the Northern Beaches"). */
|
|
64
|
+
export declare function naturalLocationHeading(service: string, placeWithWord: string): string;
|
|
56
65
|
/** The title and H1 a new page of `family` takes. */
|
|
57
66
|
export declare function buildPageTitle(input: BrandlabPageTitleInput): BrandlabPageTitle;
|
|
58
67
|
/** What check E1-pattern compares on a location page. */
|
|
@@ -63,9 +72,11 @@ export interface BrandlabLocationHeadingSample {
|
|
|
63
72
|
readonly place: string;
|
|
64
73
|
}
|
|
65
74
|
/**
|
|
66
|
-
* Why a location page's H1 and title break
|
|
67
|
-
*
|
|
68
|
-
*
|
|
75
|
+
* Why a location page's H1 and title break the pattern, or null when they keep it (4.4.0):
|
|
76
|
+
* - the H1 names the service, then the place: "{Service} {Place}", or the natural "{Service} in {Place}" /
|
|
77
|
+
* "{Service} on the {Place}"; the service itself has no "in" and no "the";
|
|
78
|
+
* - the title starts with the compact "{Service} {Place}" (or with the H1, letter case aside), has at most two
|
|
79
|
+
* pipes, carries no dollar figure and is at most 60 characters.
|
|
69
80
|
*/
|
|
70
81
|
export declare function locationHeadingProblem(sample: BrandlabLocationHeadingSample): string | null;
|
|
71
82
|
//# sourceMappingURL=page-titles.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page-titles.d.ts","sourceRoot":"","sources":["../src/page-titles.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"page-titles.d.ts","sourceRoot":"","sources":["../src/page-titles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,eAAO,MAAM,yBAAyB,KAAK,CAAA;AAE3C,eAAO,MAAM,uBAAuB,kHAS1B,CAAA;AACV,M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AC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CASrF;AASD,qDAAqD;AACrD,wBAAgB,cAAc,CAAC,KAAK,EAAE,sBAAsB,GAAG,iBAAiB,CA6C/E;AAED,yDAAyD;AACzD,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,2CAA2C;IAC3C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CACvB;AAKD;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,6BAA6B,GAAG,MAAM,GAAG,IAAI,CA2B3F"}
|
package/dist/page-titles.js
CHANGED
|
@@ -11,9 +11,13 @@
|
|
|
11
11
|
* | Cost guide | `{Service} Cost {Area} {Year} \| {Brand}` | `{Service} cost {area} ({year})` |
|
|
12
12
|
* | Project | `{Service} {Suburb}: {Job} \| {Brand}` | `{Job}, {Suburb}` |
|
|
13
13
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
14
|
+
* Titles keep the compact keyword form "{Service} {Place}" and are at most 60 characters: the short brand only when
|
|
15
|
+
* needed, never a cut keyword. One pipe separates the brand. A title carries no price and no proof tail (4.4.0,
|
|
16
|
+
* Romie's 20 November 2026 rulings): `proofTail` and `tier` are gone, and prices stay in the page body.
|
|
17
|
+
*
|
|
18
|
+
* A location page's on-page H1 may read naturally, "{Service} in {Place}" or "{Service} on the {Place}": pass the
|
|
19
|
+
* place with its place word (`definePlaceNames(...).get(slug).withPlaceWord`) as `placeWithWord`. Without it the H1
|
|
20
|
+
* is the compact form, as before. The title is compact either way.
|
|
17
21
|
*/
|
|
18
22
|
export const BRANDLAB_TITLE_MAX_LENGTH = 60;
|
|
19
23
|
export const BRANDLAB_TITLE_FAMILIES = [
|
|
@@ -27,6 +31,7 @@ export const BRANDLAB_TITLE_FAMILIES = [
|
|
|
27
31
|
'project',
|
|
28
32
|
];
|
|
29
33
|
const SMALL_WORDS = new Set(['a', 'an', 'and', 'as', 'at', 'but', 'by', 'for', 'of', 'on', 'or', 'to', 'with']);
|
|
34
|
+
/** Words a service phrase never carries: the place word belongs between the service and the place, not inside it. */
|
|
30
35
|
const BANNED_WORDS = ['in', 'the'];
|
|
31
36
|
function clean(value, field) {
|
|
32
37
|
const text = typeof value === 'string' ? value.trim().replace(/\s+/g, ' ') : '';
|
|
@@ -57,7 +62,7 @@ function bannedWordIn(service) {
|
|
|
57
62
|
const words = service.toLowerCase().split(/\s+/);
|
|
58
63
|
return BANNED_WORDS.find((banned) => words.includes(banned));
|
|
59
64
|
}
|
|
60
|
-
/** "{Service} {Place}": the service in title case and the place as named. The service has no "in" and no "the". */
|
|
65
|
+
/** "{Service} {Place}", the compact title form: the service in title case and the place as named. The service has no "in" and no "the". */
|
|
61
66
|
export function locationHeading(service, place) {
|
|
62
67
|
const name = clean(service, 'service');
|
|
63
68
|
const banned = bannedWordIn(name);
|
|
@@ -65,15 +70,24 @@ export function locationHeading(service, place) {
|
|
|
65
70
|
throw new Error(`A location heading has no "${banned}": "${name}" is not the short exact phrase.`);
|
|
66
71
|
return `${titleCase(name)} ${clean(place, 'place')}`;
|
|
67
72
|
}
|
|
68
|
-
|
|
73
|
+
/** The place words a natural location H1 may join the service and the place with. */
|
|
74
|
+
export const BRANDLAB_PLACE_WORDS = ['in', 'on'];
|
|
75
|
+
/** "{Service} in {Place}": the service in title case, then the place with its own place word ("on the Northern Beaches"). */
|
|
76
|
+
export function naturalLocationHeading(service, placeWithWord) {
|
|
77
|
+
const name = clean(service, 'service');
|
|
78
|
+
const banned = bannedWordIn(name);
|
|
79
|
+
if (banned)
|
|
80
|
+
throw new Error(`A location heading's service has no "${banned}": "${name}" is not the short exact phrase.`);
|
|
81
|
+
const place = clean(placeWithWord, 'placeWithWord');
|
|
82
|
+
if (!BRANDLAB_PLACE_WORDS.some((word) => place.toLowerCase().startsWith(`${word} `))) {
|
|
83
|
+
throw new Error(`placeWithWord starts with the place word ("in Ryde", "on the Northern Beaches"); got "${place}".`);
|
|
84
|
+
}
|
|
85
|
+
return `${titleCase(name)} ${place}`;
|
|
86
|
+
}
|
|
87
|
+
function fit(heading, input) {
|
|
69
88
|
const brand = clean(input.brand, 'brand');
|
|
70
89
|
const short = input.shortBrand?.trim() || brand;
|
|
71
|
-
const
|
|
72
|
-
const candidates = [
|
|
73
|
-
...(tail ? [`${heading} | ${tail} | ${brand}`, `${heading} | ${tail} | ${short}`] : []),
|
|
74
|
-
`${heading} | ${brand}`,
|
|
75
|
-
`${heading} | ${short}`,
|
|
76
|
-
];
|
|
90
|
+
const candidates = [`${heading} | ${brand}`, `${heading} | ${short}`];
|
|
77
91
|
return candidates.find((candidate) => candidate.length <= BRANDLAB_TITLE_MAX_LENGTH) ?? heading;
|
|
78
92
|
}
|
|
79
93
|
/** The title and H1 a new page of `family` takes. */
|
|
@@ -81,11 +95,12 @@ export function buildPageTitle(input) {
|
|
|
81
95
|
if (!BRANDLAB_TITLE_FAMILIES.includes(input.family)) {
|
|
82
96
|
throw new Error(`buildPageTitle does not know the family "${String(input.family)}".`);
|
|
83
97
|
}
|
|
84
|
-
const locationFamily = input.family !== 'home' && input.family !== 'service' && input.family !== 'cost-guide' && input.family !== 'project';
|
|
85
98
|
if (input.proofTail !== undefined) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
99
|
+
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).');
|
|
100
|
+
}
|
|
101
|
+
const locationFamily = input.family !== 'home' && input.family !== 'service' && input.family !== 'cost-guide' && input.family !== 'project';
|
|
102
|
+
if (input.placeWithWord !== undefined && !locationFamily) {
|
|
103
|
+
throw new Error('placeWithWord is for region, suburb, hub and service-in-suburb pages.');
|
|
89
104
|
}
|
|
90
105
|
let heading;
|
|
91
106
|
let h1;
|
|
@@ -118,16 +133,20 @@ export function buildPageTitle(input) {
|
|
|
118
133
|
}
|
|
119
134
|
default: {
|
|
120
135
|
heading = locationHeading(clean(input.service, 'service'), clean(input.place, 'place'));
|
|
121
|
-
h1 = heading;
|
|
136
|
+
h1 = input.placeWithWord === undefined ? heading : naturalLocationHeading(clean(input.service, 'service'), input.placeWithWord);
|
|
122
137
|
}
|
|
123
138
|
}
|
|
124
|
-
const title = fit(heading, input
|
|
139
|
+
const title = fit(heading, input);
|
|
125
140
|
return { title, h1, heading, length: title.length, overLength: heading.length > BRANDLAB_TITLE_MAX_LENGTH };
|
|
126
141
|
}
|
|
142
|
+
const JOINER = new RegExp(`\\s+(?:${BRANDLAB_PLACE_WORDS.join('|')})(?:\\s+the)?$`, 'i');
|
|
143
|
+
const DOLLAR_FIGURE = /\$\s?\d/;
|
|
127
144
|
/**
|
|
128
|
-
* Why a location page's H1 and title break
|
|
129
|
-
*
|
|
130
|
-
*
|
|
145
|
+
* Why a location page's H1 and title break the pattern, or null when they keep it (4.4.0):
|
|
146
|
+
* - the H1 names the service, then the place: "{Service} {Place}", or the natural "{Service} in {Place}" /
|
|
147
|
+
* "{Service} on the {Place}"; the service itself has no "in" and no "the";
|
|
148
|
+
* - the title starts with the compact "{Service} {Place}" (or with the H1, letter case aside), has at most two
|
|
149
|
+
* pipes, carries no dollar figure and is at most 60 characters.
|
|
131
150
|
*/
|
|
132
151
|
export function locationHeadingProblem(sample) {
|
|
133
152
|
const h1 = sample.h1.trim().replace(/\s+/g, ' ');
|
|
@@ -136,24 +155,30 @@ export function locationHeadingProblem(sample) {
|
|
|
136
155
|
const lowerH1 = h1.toLowerCase();
|
|
137
156
|
const lowerPlace = place.toLowerCase();
|
|
138
157
|
if (!lowerH1.endsWith(` ${lowerPlace}`) && lowerH1 !== lowerPlace) {
|
|
139
|
-
return `the H1 "${h1}" is not "{Service} {Place}": it never ends with the place ("${place}").`;
|
|
158
|
+
return `the H1 "${h1}" is not "{Service} {Place}" or "{Service} in {Place}": it never ends with the place ("${place}").`;
|
|
140
159
|
}
|
|
141
|
-
|
|
142
|
-
|
|
160
|
+
// "Tree Removal in Ryde" and "Tree Removal on the Northern Beaches" name the service before the place word.
|
|
161
|
+
const service = h1.slice(0, h1.length - place.length).trim().replace(JOINER, '').trim();
|
|
162
|
+
if (!service || BRANDLAB_PLACE_WORDS.includes(service.toLowerCase()))
|
|
143
163
|
return `the H1 "${h1}" names the place without the service.`;
|
|
144
164
|
const words = service.toLowerCase().split(' ');
|
|
145
165
|
if (words.includes('in'))
|
|
146
|
-
return `the H1 "${h1}" has "in"; it
|
|
166
|
+
return `the H1 "${h1}" has "in" inside the service; it reads "{Service} {Place}" or "{Service} in {Place}".`;
|
|
147
167
|
if (words.includes('the'))
|
|
148
|
-
return `the H1 "${h1}" has "the"; it
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
const
|
|
168
|
+
return `the H1 "${h1}" has "the" inside the service; it reads "{Service} {Place}" or "{Service} in {Place}".`;
|
|
169
|
+
const compact = `${service} ${place}`;
|
|
170
|
+
const lowerTitle = title.toLowerCase();
|
|
171
|
+
const lead = [compact, h1].find((candidate) => lowerTitle.startsWith(candidate.toLowerCase()));
|
|
172
|
+
if (lead === undefined)
|
|
173
|
+
return `the title "${title}" never starts with "${compact}" (the H1's service and place).`;
|
|
174
|
+
const rest = title.slice(lead.length);
|
|
152
175
|
if (rest && !rest.startsWith(' | '))
|
|
153
|
-
return `the title "${title}" adds words to "${
|
|
176
|
+
return `the title "${title}" adds words to "${lead}" before its brand.`;
|
|
154
177
|
if ((title.match(/\|/g) ?? []).length > 2)
|
|
155
178
|
return `the title "${title}" chains more than two pipes.`;
|
|
156
|
-
if (
|
|
179
|
+
if (DOLLAR_FIGURE.test(title))
|
|
180
|
+
return `the title "${title}" carries a price; prices stay in the page body, never in a title.`;
|
|
181
|
+
if (title.length > BRANDLAB_TITLE_MAX_LENGTH && title.toLowerCase() !== lead.toLowerCase()) {
|
|
157
182
|
return `the title "${title}" is ${title.length} characters; titles are at most 60 characters (drop or shorten the brand, never the keyword).`;
|
|
158
183
|
}
|
|
159
184
|
return null;
|
package/dist/page-titles.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page-titles.js","sourceRoot":"","sources":["../src/page-titles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;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;AAoCV,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,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;QACnB,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,KAAK,IAAI,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AC;QAAE,OAAO,cAAc,KAAK,+BAA+B,EAAE,IAAI,CAAA;IAC7G,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,CAAA;IACnC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC;QAAE,OAAO,cAAc,KAAK,oBAAoB,EAAE,qBAAqB,CAAA;IAC1G,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,cAAc,KAAK,+BAA+B,CAAA;IACpG,IAAI,KAAK,CAAC,MAAM,GAAG,yBAAyB,IAAI,KAAK,KAAK,EAAE,EAAE,CAAC;QAC7D,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 * H1s are the short exact phrase with no \"in\" and no \"the\". Titles are at most 60 characters: the short brand only\n * when needed, never a cut keyword. A proof tail (`| From $450 |`, \"Same-Week Quotes\") comes only from data and only\n * on the service page and head-tier pages. One pipe separates the brand; with a tail there are two.\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 /** Location pages: `head` pages may carry a proof tail; `standard` pages never do. */\n readonly tier?: 'head' | 'standard'\n /** \"From $450\" or \"Same-Week Quotes\": only when true and only on service and head-tier pages. */\n readonly proofTail?: 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'])\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 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\nfunction fit(heading: string, input: BrandlabPageTitleInput, tailAllowed: boolean): string {\n const brand = clean(input.brand, 'brand')\n const short = input.shortBrand?.trim() || brand\n const tail = tailAllowed ? input.proofTail?.trim() : undefined\n const candidates = [\n ...(tail ? [`${heading} | ${tail} | ${brand}`, `${heading} | ${tail} | ${short}`] : []),\n `${heading} | ${brand}`,\n `${heading} | ${short}`,\n ]\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 const locationFamily = input.family !== 'home' && input.family !== 'service' && input.family !== 'cost-guide' && input.family !== 'project'\n if (input.proofTail !== undefined) {\n if (input.family !== 'service' && !(locationFamily && input.tier === 'head')) {\n throw new Error('A proof tail goes only on the service page and head-tier pages; standard-tier pages never carry one.')\n }\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 = heading\n }\n }\n const title = fit(heading, input, input.proofTail !== undefined)\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\n/**\n * Why a location page's H1 and title break \"{Service} {Place}\", or null when they keep it: the H1 ends with the place\n * and has a service before it, no \"in\" and no leading \"the\"; the title starts with the H1 (letter case aside), has at\n * most two pipes 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}\": it never ends with the place (\"${place}\").`\n }\n const service = h1.slice(0, h1.length - place.length).trim()\n if (!service) 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\"; it is the short exact phrase \"{Service} {Place}\".`\n if (words.includes('the')) return `the H1 \"${h1}\" has \"the\"; it is the short exact phrase \"{Service} {Place}\".`\n if (!title.toLowerCase().startsWith(lowerH1)) return `the title \"${title}\" never starts with the H1 \"${h1}\".`\n const rest = title.slice(h1.length)\n if (rest && !rest.startsWith(' | ')) return `the title \"${title}\" adds words to \"${h1}\" before its brand.`\n if ((title.match(/\\|/g) ?? []).length > 2) return `the title \"${title}\" chains more than two pipes.`\n if (title.length > BRANDLAB_TITLE_MAX_LENGTH && title !== h1) {\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,KAAK,KAAK,QAAQ,CAA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AAC;QAAE,OAAO,WAAW,EAAE,yFAAyF,CAAA;IACxI,MAAM,OAAO,GAAG,GAAG,OAAO,IAAI,KAAK,EAAE,CAAA;IACrC,MAAM,UAAU,GAAG,KAAK,CAAC,WAAW,EAAE,CAAA;IACtC,MAAM,IAAI,GAAG,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,CAAC,CAAA;IAC9F,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,cAAc,KAAK,wBAAwB,OAAO,iCAAiC,CAAA;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"]}
|
package/dist/project.d.ts
CHANGED
|
@@ -59,7 +59,22 @@ export interface BrandlabSiteSystemConfig {
|
|
|
59
59
|
* and the exact wording the page uses instead.
|
|
60
60
|
*/
|
|
61
61
|
replyTime?: BrandlabReplyTimeRecord;
|
|
62
|
+
/**
|
|
63
|
+
* The site's own design kit as the ready gate reads it (check K8, 4.4.0). Absent: a page carries at most one
|
|
64
|
+
* section in the `band` tone, as before.
|
|
65
|
+
*/
|
|
66
|
+
kit?: BrandlabSiteKitRecord;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* What a site's design kit declares to the ready gate. `tones` lists the section tones that have a per-page limit,
|
|
70
|
+
* by the `data-tone` name the site's sections carry: `{ band: 2, feature: 1 }` lets a page carry two band sections
|
|
71
|
+
* and one feature section. A tone that is not listed has no limit. Neighbouring sections still differ in tone.
|
|
72
|
+
*/
|
|
73
|
+
export interface BrandlabSiteKitRecord {
|
|
74
|
+
tones: Readonly<Record<string, number>>;
|
|
62
75
|
}
|
|
76
|
+
/** The most sections of one limited tone a kit may allow on a page. */
|
|
77
|
+
export declare const BRANDLAB_SITE_KIT_TONE_MAX = 12;
|
|
63
78
|
/**
|
|
64
79
|
* The thank-you page's reply promise. A no-promise record carries the page's own wording (no time in it), who decided
|
|
65
80
|
* (the owner, or Romie for the owner) and the day the decision was made.
|
package/dist/project.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../src/project.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAA;AACtE,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAA;AAEhF,MAAM,MAAM,mBAAmB,GAC3B,UAAU,GACV,WAAW,GACX,mBAAmB,GACnB,MAAM,GACN,UAAU,GACV,OAAO,CAAA;AAEX,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,KAAK,GAAG,YAAY,CAAA;AAC/D,MAAM,MAAM,6BAA6B,GACrC,MAAM,GACN,iBAAiB,GACjB,iBAAiB,GACjB,0BAA0B,CAAA;AAC9B,MAAM,MAAM,wBAAwB,GAChC,MAAM,GACN,uBAAuB,GACvB,mBAAmB,GACnB,gBAAgB,CAAA;AACpB,MAAM,MAAM,uBAAuB,GAAG,eAAe,GAAG,yBAAyB,GAAG,eAAe,CAAA;AACnG,MAAM,MAAM,yBA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AE,qBAAqB,CAAA;CAChC;AA0ED,qHAAqH;AACrH,wBAAgB,iCAAiC,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAS3E;AAED,qGAAqG;AACrG,wBAAgB,qBAAqB,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,qBAAqB,EAAE,cAAc,CAAC,GAAG,oBAAoB,EAAE,CAGnH;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CA6EjF;AA0GD;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,CAAC,CAAC,SAAS,qBAAqB,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,CA4LzF"}
|
package/dist/project.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { normalizeBrandlabRoutePath } from './routes.js';
|
|
2
2
|
import { assertBrandlabCanonicalEntityId } from './entity-id.js';
|
|
3
|
+
/** The most sections of one limited tone a kit may allow on a page. */
|
|
4
|
+
export const BRANDLAB_SITE_KIT_TONE_MAX = 12;
|
|
3
5
|
/**
|
|
4
6
|
* Wording that still promises a time: a digit, minutes or hours, "same day", "next day", a business or working day,
|
|
5
7
|
* "end of the day", "today" or "tomorrow". A no-promise record's wording must not match.
|
|
@@ -63,7 +65,7 @@ const BUSINESS_PROFILE_REVIEWS_SELECTIONS = new Set([
|
|
|
63
65
|
'five-star',
|
|
64
66
|
]);
|
|
65
67
|
const SITE_SYSTEM_TIERS = new Set(['shell', 'enquiry', 'full']);
|
|
66
|
-
const SITE_SYSTEM_KEYS = ['tier', 'newBuild', 'samples', 'labels', 'freeQuotes', 'thirdParties', 'phones', 'refreshExceptions', 'replyTime'];
|
|
68
|
+
const SITE_SYSTEM_KEYS = ['tier', 'newBuild', 'samples', 'labels', 'freeQuotes', 'thirdParties', 'phones', 'refreshExceptions', 'replyTime', 'kit'];
|
|
67
69
|
const REPLY_TIME_KEYS = ['promise', 'wording', 'decidedBy', 'decidedOn'];
|
|
68
70
|
const REFRESH_EXCEPTION_KEYS = ['family', 'revalidateSeconds', 'reason', 'decisionId'];
|
|
69
71
|
const HOSTNAME_PATTERN = /^(?=.{1,253}$)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,63}$/;
|
|
@@ -244,6 +246,22 @@ function assertRefreshExceptions(value) {
|
|
|
244
246
|
});
|
|
245
247
|
assertUnique(value.map((entry) => entry.family), `${field}.family`);
|
|
246
248
|
}
|
|
249
|
+
function assertSiteKit(value) {
|
|
250
|
+
const field = 'siteSystem.kit';
|
|
251
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
252
|
+
throw new Error(`${field} must be { tones: { band: 2 } }.`);
|
|
253
|
+
assertKnownKeys(value, ['tones'], field);
|
|
254
|
+
const tones = value.tones;
|
|
255
|
+
if (!tones || typeof tones !== 'object' || Array.isArray(tones))
|
|
256
|
+
throw new Error(`${field}.tones must map each limited data-tone name to the sections a page may carry.`);
|
|
257
|
+
for (const [name, limit] of Object.entries(tones)) {
|
|
258
|
+
if (!/^[a-z][a-z0-9-]*$/.test(name))
|
|
259
|
+
throw new Error(`${field}.tones: "${name}" is not a data-tone name (lower case letters, digits and hyphens).`);
|
|
260
|
+
if (!Number.isSafeInteger(limit) || limit < 1 || limit > BRANDLAB_SITE_KIT_TONE_MAX) {
|
|
261
|
+
throw new Error(`${field}.tones.${name} must be a whole number from 1 to ${BRANDLAB_SITE_KIT_TONE_MAX}.`);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
247
265
|
function assertReplyTime(value) {
|
|
248
266
|
const field = 'siteSystem.replyTime';
|
|
249
267
|
if (!value || typeof value !== 'object' || Array.isArray(value) || typeof value.promise !== 'boolean') {
|
|
@@ -420,6 +438,9 @@ export function defineBrandlabProject(config) {
|
|
|
420
438
|
if (siteSystem.replyTime !== undefined) {
|
|
421
439
|
assertReplyTime(siteSystem.replyTime);
|
|
422
440
|
}
|
|
441
|
+
if (siteSystem.kit !== undefined) {
|
|
442
|
+
assertSiteKit(siteSystem.kit);
|
|
443
|
+
}
|
|
423
444
|
}
|
|
424
445
|
if (config.hosting !== undefined) {
|
|
425
446
|
// The date-bound lapse is the ready gate's (W5): a lapsed decision must not stop a build or a rollback.
|