@brandlab-digital/site-core 3.13.0 → 3.15.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 +105 -0
- package/dist/area-map.d.ts +36 -3
- package/dist/area-map.d.ts.map +1 -1
- package/dist/area-map.js +71 -11
- package/dist/area-map.js.map +1 -1
- package/dist/business.d.ts +97 -0
- package/dist/business.d.ts.map +1 -1
- package/dist/business.js +128 -0
- package/dist/business.js.map +1 -1
- package/dist/council-register.d.ts +53 -0
- package/dist/council-register.d.ts.map +1 -0
- package/dist/council-register.js +113 -0
- package/dist/council-register.js.map +1 -0
- package/dist/geography.js +2 -2
- package/dist/geography.js.map +1 -1
- package/dist/jobs.d.ts +74 -0
- package/dist/jobs.d.ts.map +1 -0
- package/dist/jobs.js +116 -0
- package/dist/jobs.js.map +1 -0
- package/dist/locations.d.ts +10 -0
- package/dist/locations.d.ts.map +1 -1
- package/dist/locations.js +15 -0
- package/dist/locations.js.map +1 -1
- package/dist/navigation.d.ts +37 -1
- package/dist/navigation.d.ts.map +1 -1
- package/dist/navigation.js +107 -2
- package/dist/navigation.js.map +1 -1
- package/dist/page-titles.d.ts +71 -0
- package/dist/page-titles.d.ts.map +1 -0
- package/dist/page-titles.js +161 -0
- package/dist/page-titles.js.map +1 -0
- package/dist/project.d.ts +23 -0
- package/dist/project.d.ts.map +1 -1
- package/dist/project.js +33 -1
- package/dist/project.js.map +1 -1
- package/dist/section-order.d.ts +49 -3
- package/dist/section-order.d.ts.map +1 -1
- package/dist/section-order.js +108 -3
- package/dist/section-order.js.map +1 -1
- package/dist/strategy.d.ts +208 -0
- package/dist/strategy.d.ts.map +1 -1
- package/dist/strategy.js +340 -2
- package/dist/strategy.js.map +1 -1
- package/package.json +13 -1
package/README.md
CHANGED
|
@@ -88,6 +88,9 @@ boundary throws). Then:
|
|
|
88
88
|
job places, a label point per region.
|
|
89
89
|
- `regionMap(site, regionSlug, options)`: a region's localities: indexed
|
|
90
90
|
linked, served-but-noindex served and unlinked, the rest muted; job places.
|
|
91
|
+
From 3.15.0 the frame is 0.5 to 0.75 as high as wide (`REGION_MAP_ASPECT`),
|
|
92
|
+
and a region taller than wide keeps the square stretch holding most of its
|
|
93
|
+
served places; the served places left out are in `outside`, not drawn.
|
|
91
94
|
- `suburbLocator(site, slug, { neighbours, jobs })`: the place, its nearest
|
|
92
95
|
neighbours in the order given (the page's own nearby list) and job places;
|
|
93
96
|
undefined when there is nothing to show.
|
|
@@ -101,6 +104,108 @@ groups with no colours) for a cached static route; the page draws each group
|
|
|
101
104
|
with `<use href="<file>#<id>">` (`areaMapLayerIds(model)`) and styles the
|
|
102
105
|
`<use>` with its own tokens.
|
|
103
106
|
|
|
107
|
+
From 3.15.0, `renderAreaMapBaseSvg(site, model, { linked: true })` also writes
|
|
108
|
+
the model's linked shapes into the file's `<defs>`, each with the id
|
|
109
|
+
`areaMapShapeId(shape)` (`suburb-castle-hill`), so site-next's `AreaMap` links
|
|
110
|
+
them with `<a><use href="<file>#<id>"></a>` and no boundary path sits in the
|
|
111
|
+
page's HTML. Without `linked` the file is unchanged.
|
|
112
|
+
|
|
104
113
|
`./area-map/encode` (Node tools): `encodeAreaMapBoundaries` builds a document
|
|
105
114
|
in the shared format (topology, per-arc Douglas-Peucker, dissolves, base64url
|
|
106
115
|
arcs); the registry generator and `brandlab-area-map places` use it.
|
|
116
|
+
|
|
117
|
+
## Site data for the v2 library (from 3.14.0)
|
|
118
|
+
|
|
119
|
+
All additive: existing sites change nothing until they record the new data.
|
|
120
|
+
|
|
121
|
+
### Credentials (`./business`)
|
|
122
|
+
|
|
123
|
+
`BrandlabBusiness.credentials` (or `defineBusinessCredentials`) records `insurance` (cover, `amountAud`, optional
|
|
124
|
+
`insurer` and `expiresOn`), `qualifications` (person-less titles such as "AQF Level 3-qualified arborist"),
|
|
125
|
+
`experience` (`years`, `holder: 'practitioner' | 'business'`, `field`) and `established` (`year`, optional `month`).
|
|
126
|
+
Every entry carries its claims-register id (`claimId: 'CLM-22'`) and its own `evidence`. Nothing renders without it:
|
|
127
|
+
`renderableCredentials(credentials, surface, asOf)` returns only entries whose evidence allows the surface and has not
|
|
128
|
+
expired (and no insurance past `expiresOn`), without the evidence. `formatInsuranceAmount(20_000_000)` gives
|
|
129
|
+
"$20 million"; `yearsSinceEstablished(established, asOf)` counts whole years in Sydney.
|
|
130
|
+
|
|
131
|
+
3.15.0 adds `afterHours` (`work`, optional `endsOn` for a storm season), the record `EmergencyBand` needs before it
|
|
132
|
+
renders: real after-hours work in the claims register, never a response time. It renders until its `endsOn` (Sydney).
|
|
133
|
+
|
|
134
|
+
### Decision card (`./strategy`)
|
|
135
|
+
|
|
136
|
+
`defineStrategyDecisions` validates the typed decisions a site records beside `defineSiteStrategy` (v2 §2.4, §12.2
|
|
137
|
+
step 2): `recordedOn`, `trade`, `mainArea`, `homePhrase`, the seven-field `decisionCard`, `moneyServices` (job mode
|
|
138
|
+
`urgent | planned | mixed`, optional `pattern: 'add-on' | 'seasonal'`, `onLocationPages:
|
|
139
|
+
'owns-suburb-page' | 'service-in-suburb-pages' | 'suburb-page-section'`, with `suburbFamily` true exactly for the first
|
|
140
|
+
two and one owner of the suburb page), the 90-day `leadBaseline` with target and read dates, up to three
|
|
141
|
+
`reasonsToChoose` each with its `claims`, and optional `jobEconomics` (null until the owner says), `homeTerritory`,
|
|
142
|
+
`tiers`, typed `exclusions` and at most five `ownerQuestions`.
|
|
143
|
+
|
|
144
|
+
### Estate plan and return waves (`./strategy`)
|
|
145
|
+
|
|
146
|
+
A wave may be `kind: 'return'`: existing pages, live and noindex now, that come back to the index on the day.
|
|
147
|
+
`siteStrategy.estate` records an existing estate's plan: `indexedNow` (paths or patterns), `paths` (`region`,
|
|
148
|
+
`suburb` and nested `serviceInSuburb` families such as `/tree-services/stump-grinding/{suburb}`) and `slugs` (public
|
|
149
|
+
slugs that differ from the registry's: any region rename; a suburb only ever as "{slug}-suburb", which is how a suburb
|
|
150
|
+
clashing with a region slug under the same parent is named, as AA's `ryde-suburb`). `estatePlanProblems`,
|
|
151
|
+
`estatePublicSlug` and `estateLocationPath(plan, kind, registrySlug, template?)` share the rules with LOC-INDEX.
|
|
152
|
+
|
|
153
|
+
While return waves run, indexable pages name a waiting suburb as plain text instead of linking its noindex page (3.15.0):
|
|
154
|
+
`estateLinkState(path, { estate, waves, on })` is `'link'` for a page indexed now or whose wave is due on `on` (a
|
|
155
|
+
Sydney day, today by default) and `'text'` otherwise, and `coverageEntries(places, { estate, waves, on, pathFor? })`
|
|
156
|
+
turns a region's suburbs into `Coverage` entries (`{ label, href? }`), so the region page still lists every suburb.
|
|
157
|
+
Pass `{ ...siteStrategy, on }` for the options.
|
|
158
|
+
|
|
159
|
+
### Titles and H1s (`./page-titles`)
|
|
160
|
+
|
|
161
|
+
`buildPageTitle({ family, brand, shortBrand?, phrase?, service?, place?, tier?, proofTail?, year?, job? })` writes
|
|
162
|
+
v2 §5.2's patterns: "{Service} {Place}" for region, suburb, service-region and service-in-suburb pages (no "in", no
|
|
163
|
+
"the"), the home and service phrases, cost guides and projects; titles stay within 60 characters by using the short
|
|
164
|
+
brand, then dropping the brand, never cutting the keyword. A proof tail is allowed only on service and head-tier pages.
|
|
165
|
+
Pass the `title` with `titleMode: 'absolute'`. `locationHeadingProblem` is the rule check E1-pattern applies.
|
|
166
|
+
|
|
167
|
+
### Trade map (`./section-order`)
|
|
168
|
+
|
|
169
|
+
`SECTION_TRADE_PROFILES` holds matrix part B per trade: the credential block (`licence`, `qualifications` or
|
|
170
|
+
`unconfirmed`), requirement changes (`SECTION_ORDER_TRADE_MAP` is derived from them) and required slots inside
|
|
171
|
+
sections. Trees is filled: the permit note is required in `LocalFacts` on suburb and service-in-suburb pages, the about
|
|
172
|
+
page's owner block carries the qualifications and insurance lines, and the licence block is optional. Other trades keep
|
|
173
|
+
the defaults until confirmed. A component marks each slot with `data-bl-slot="permit"`; when the data is missing or
|
|
174
|
+
stale it lists `permit:no-current-council-record` in the section's `data-bl-slot-skip`
|
|
175
|
+
(`formatSectionSlotSkips`). `requiredSectionSlots(family, trade)` is what K12-slots reads.
|
|
176
|
+
|
|
177
|
+
From 3.15.0 the suburb family lists `nearby-areas` (conditional) before the required `area-map`, and the service
|
|
178
|
+
family an optional `gallery` after the projects. The trees licence block stays on the about page only.
|
|
179
|
+
|
|
180
|
+
### Job log (`./jobs`)
|
|
181
|
+
|
|
182
|
+
`defineJobs(jobs, { media })` validates `src/data/jobs.ts`: `id`, registry `suburb`, `service`, `outcome`, `source`,
|
|
183
|
+
optional `month` (YYYY-MM) and `photos` (media ids, genuine photos of that job only). `nearbyJobs(origin, jobs, {
|
|
184
|
+
centreOf, service?, maxKm = 10, limit = 3 })` ranks the page's own suburb first, then by real distance;
|
|
185
|
+
`jobCardLabel` writes "Recent tree removal nearby: Ryde, May 2026" when the month is known and "Tree removal nearby:
|
|
186
|
+
Ryde" when it is not (an undated job may not be recent; `prefix` replaces "Recent", `''` for none); `jobPlaces` feeds the area
|
|
187
|
+
map. Distances rank and filter only; location copy never prints them (L10).
|
|
188
|
+
|
|
189
|
+
### Nearest suburbs (`./locations`, `./geography`)
|
|
190
|
+
|
|
191
|
+
Suburb centres already ship as `getSuburbCentre` in `./geography` (the registry's NSW Spatial Services label points,
|
|
192
|
+
also used by the area map). `nearestSuburbsWithin(origin, served, { centreOf: getSuburbCentre, limit = 6, maxKm? })`
|
|
193
|
+
returns the nearest served places with their distances, next to `nearestServedSuburbs` and `rankSuburbsByDistance`.
|
|
194
|
+
|
|
195
|
+
### Council register (`./council-register`)
|
|
196
|
+
|
|
197
|
+
`defineCouncilRegister` validates one record per council: `council`, `councilName`, `rule`, optional `fees` with their
|
|
198
|
+
`financialYear` ("2026/27"), the council's https `sourceUrl` and `checkedOn`. `councilRecordStatus(record, asOf)` and
|
|
199
|
+
`visibleCouncilRecord` hide a record six months after it was checked, or on 1 July after its fees' financial year,
|
|
200
|
+
whichever comes first; the permit slot then skips with `COUNCIL_PERMIT_SKIP_REASON`. `formatCheckedMonth` writes the
|
|
201
|
+
"checked {Month Year}" date.
|
|
202
|
+
|
|
203
|
+
### Thank-you reply time (`siteSystem.replyTime` in `./project`, from 3.15.0)
|
|
204
|
+
|
|
205
|
+
The ready gate's C7 wants the thank-you page to say when the business will reply. When the owner decides to promise no
|
|
206
|
+
time, `defineBrandlabProject` records it: `siteSystem.replyTime: { promise: false, wording: 'We will call you back as
|
|
207
|
+
soon as possible.', decidedBy: 'owner' | 'romie', decidedOn: 'YYYY-MM-DD' }`. The wording is what the page's reply slot
|
|
208
|
+
says, non-empty and with no time in it (`BRANDLAB_REPLY_TIME_PROMISE`: digits, minutes, hours, "same day", "next day",
|
|
209
|
+
a business or working day, "end of the day", "today", "tomorrow"); `decidedBy` is `romie` when Romie relays the owner's
|
|
210
|
+
decision; `decidedOn` must be a real date. `{ promise: true }`, or no record, means the page names a specific time.
|
|
211
|
+
|
package/dist/area-map.d.ts
CHANGED
|
@@ -216,8 +216,20 @@ export interface AreaMapModel {
|
|
|
216
216
|
/** A tighter crop around the served area for narrow screens. */
|
|
217
217
|
crop: AreaMapCrop;
|
|
218
218
|
layers: AreaMapLayers;
|
|
219
|
+
/**
|
|
220
|
+
* A region's served places left outside its frame (3.15.0): outlying rural suburbs, by name. They are not drawn or
|
|
221
|
+
* linked on the map, so the text alternative (`areaMapPlaces`) lists them; `href` only for an indexed page.
|
|
222
|
+
*/
|
|
223
|
+
outside?: readonly AreaMapOutsidePlace[];
|
|
219
224
|
attribution: string;
|
|
220
225
|
}
|
|
226
|
+
/** A served place a region map leaves out of its frame. */
|
|
227
|
+
export interface AreaMapOutsidePlace {
|
|
228
|
+
key: string;
|
|
229
|
+
slug: string;
|
|
230
|
+
name: string;
|
|
231
|
+
href?: string;
|
|
232
|
+
}
|
|
221
233
|
export interface AreaMapOptions {
|
|
222
234
|
/** Map units across (default 1000; a locator 800). */
|
|
223
235
|
width?: number;
|
|
@@ -246,11 +258,19 @@ export interface OverviewMapOptions extends AreaMapOptions {
|
|
|
246
258
|
* point for each region and town.
|
|
247
259
|
*/
|
|
248
260
|
export declare function overviewMap(site: AreaMapSite, options?: OverviewMapOptions): AreaMapModel;
|
|
261
|
+
/** A region map's height over width (3.15.0): a wide column's shape, never a tall strip. */
|
|
262
|
+
export declare const REGION_MAP_ASPECT: Readonly<{
|
|
263
|
+
min: 0.5;
|
|
264
|
+
max: 0.75;
|
|
265
|
+
}>;
|
|
249
266
|
/**
|
|
250
267
|
* A region page's map: the region's localities, indexed suburbs linked (their
|
|
251
268
|
* pages), served suburbs without an indexable page served but unlinked, the rest
|
|
252
269
|
* muted; neighbouring regions outlined for context; job places and the base
|
|
253
|
-
* marked; a label point for every locality in the region.
|
|
270
|
+
* marked; a label point for every locality in the region. From 3.15.0 a region
|
|
271
|
+
* taller than wide is cut to the square stretch holding most of its served places
|
|
272
|
+
* (the served places left out are listed in `outside`, not drawn), and every frame
|
|
273
|
+
* is 0.5 to 0.75 of its width high (`REGION_MAP_ASPECT`), widened to fit a column.
|
|
254
274
|
*/
|
|
255
275
|
export declare function regionMap(site: AreaMapSite, regionSlug: string, options?: AreaMapOptions): AreaMapModel;
|
|
256
276
|
export interface SuburbLocatorOptions extends AreaMapOptions {
|
|
@@ -271,12 +291,25 @@ export declare const AREA_MAP_LAYER_IDS: readonly ["land", "focus", "served", "o
|
|
|
271
291
|
export type AreaMapLayerId = (typeof AREA_MAP_LAYER_IDS)[number];
|
|
272
292
|
/** The base layer groups a model draws (land and outline always; focus and served when it has them). */
|
|
273
293
|
export declare function areaMapLayerIds(model: Pick<AreaMapModel, 'layers'>): AreaMapLayerId[];
|
|
294
|
+
/**
|
|
295
|
+
* A linked shape's element id in the base file (3.15.0): its key with the colon as a hyphen (`suburb-castle-hill`,
|
|
296
|
+
* `region-hills-district`, `place-young`). The page draws it with `<use href="<file>#<id>">` inside the shape's link.
|
|
297
|
+
*/
|
|
298
|
+
export declare function areaMapShapeId(shape: Pick<AreaMapShape, 'key'>): string;
|
|
299
|
+
export interface AreaMapBaseSvgOptions extends AreaMapPathOptions {
|
|
300
|
+
/**
|
|
301
|
+
* Also write the model's linked shapes, each a `<path id="<areaMapShapeId>">` in `<defs>` (drawn only where a page
|
|
302
|
+
* uses it), so the page links them with `<use>` instead of inline paths (site-next's `AreaMap`, 3.15.0).
|
|
303
|
+
*/
|
|
304
|
+
linked?: boolean;
|
|
305
|
+
}
|
|
274
306
|
/**
|
|
275
307
|
* The static base layer of a model as an SVG document: `land` (all land in the
|
|
276
308
|
* frame; water is the space around it), `focus`, `served` and `outline` (unique
|
|
277
309
|
* borders, `fill="none"`, non-scaling strokes). The groups set no colours: the
|
|
278
310
|
* page draws each with `<use href="<file>#<id>">` and styles the `<use>` with its
|
|
279
|
-
* own tokens. Serve it from a static route, never inline.
|
|
311
|
+
* own tokens. Serve it from a static route, never inline. With `linked: true` the file also holds the linked shapes
|
|
312
|
+
* for `<use>` (`areaMapShapeId`).
|
|
280
313
|
*/
|
|
281
|
-
export declare function renderAreaMapBaseSvg(site: AreaMapSite, model: AreaMapModel, options?:
|
|
314
|
+
export declare function renderAreaMapBaseSvg(site: AreaMapSite, model: AreaMapModel, options?: AreaMapBaseSvgOptions): string;
|
|
282
315
|
//# sourceMappingURL=area-map.d.ts.map
|
package/dist/area-map.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"area-map.d.ts","sourceRoot":"","sources":["../src/area-map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,EAIL,KAAK,uBAAuB,EAE5B,KAAK,YAAY,EAClB,MAAM,sBAAsB,CAAA;AAG7B,OAAO,KAAK,EACV,sBAAsB,EACtB,6BAA6B,EAC7B,iBAAiB,EAEjB,YAAY,EACb,MAAM,gBAAgB,CAAA;AAEvB,YAAY,EAAE,cAAc,EAAE,uBAAuB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAEhH;;;;GAIG;AACH,eAAO,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AAE,MAAM,EAAE,OAAO,GAAE,cAAmB,GAAG,YAAY,CAiE3G;AAED,MAAM,WAAW,oBAAqB,SAAQ,cAAc;IAC1D,yGAAyG;IACzG,UAAU,EAAE,SAAS,MAAM,EAAE,CAAA;IAC7B,iEAAiE;IACjE,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,oBAAoB,GAAG,YAAY,GAAG,SAAS,CAyDtH;AAMD,6EAA6E;AAC7E,eAAO,MAAM,kBAAkB,iDAAkD,CAAA;AACjF,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAA;AAEhE,wGAAwG;AACxG,wBAAgB,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC,GAAG,cAAc,EAAE,CAErF;AAgCD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,KAAK,CAAC,GAAG,MAAM,CAEvE;AAED,MAAM,WAAW,qBAAsB,SAAQ,kBAAkB;IAC/D;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,GAAE,qBAA0B,GAAG,MAAM,CAsBxH"}
|
package/dist/area-map.js
CHANGED
|
@@ -875,11 +875,43 @@ function regionMembers(registry, regionSlug) {
|
|
|
875
875
|
return localitiesOf(registry).filter((locality) => locality.regionSlug === subRegion.parentRegionSlug &&
|
|
876
876
|
((subRegion.councilSlugs?.includes(locality.councilSlug) ?? false) || (subRegion.suburbSlugs?.includes(locality.slug) ?? false)));
|
|
877
877
|
}
|
|
878
|
+
/** A region map's height over width (3.15.0): a wide column's shape, never a tall strip. */
|
|
879
|
+
export const REGION_MAP_ASPECT = Object.freeze({ min: 0.5, max: 0.75 });
|
|
880
|
+
/**
|
|
881
|
+
* The box a region map fits (3.15.0). A region taller than it is wide (the Hills District runs some 40 km north to
|
|
882
|
+
* Wisemans Ferry across about 13 km) keeps its full width and a square window of it along its length: the window
|
|
883
|
+
* that holds the most of its served places (an indexed place counts twice), centred on them. The places outside it
|
|
884
|
+
* are its outliers, typically outlying rural suburbs. Any other region keeps its whole box.
|
|
885
|
+
*/
|
|
886
|
+
function regionFitBounds(regionBounds, places) {
|
|
887
|
+
const middle = (regionBounds.north + regionBounds.south) / 2;
|
|
888
|
+
const cos = Math.cos((middle * Math.PI) / 180);
|
|
889
|
+
const across = (regionBounds.east - regionBounds.west) * cos;
|
|
890
|
+
const along = regionBounds.north - regionBounds.south;
|
|
891
|
+
if (along <= across)
|
|
892
|
+
return regionBounds;
|
|
893
|
+
const centres = places.flatMap(({ place, state }) => (place.centre && state !== 'muted' ? [{ latitude: place.centre.latitude, weight: state === 'linked' ? 2 : 1 }] : []));
|
|
894
|
+
if (centres.length === 0)
|
|
895
|
+
return regionBounds;
|
|
896
|
+
let best = { score: -1, north: regionBounds.north };
|
|
897
|
+
for (const { latitude } of [...centres].sort((a, b) => b.latitude - a.latitude)) {
|
|
898
|
+
const score = centres.reduce((total, centre) => total + (centre.latitude <= latitude && centre.latitude >= latitude - across ? centre.weight : 0), 0);
|
|
899
|
+
if (score > best.score)
|
|
900
|
+
best = { score, north: latitude };
|
|
901
|
+
}
|
|
902
|
+
const held = centres.filter((centre) => centre.latitude <= best.north && centre.latitude >= best.north - across).map((centre) => centre.latitude);
|
|
903
|
+
const centre = (Math.max(...held) + Math.min(...held)) / 2;
|
|
904
|
+
const north = Math.min(regionBounds.north, Math.max(regionBounds.south + across, centre + across / 2));
|
|
905
|
+
return { west: regionBounds.west, east: regionBounds.east, north, south: north - across };
|
|
906
|
+
}
|
|
878
907
|
/**
|
|
879
908
|
* A region page's map: the region's localities, indexed suburbs linked (their
|
|
880
909
|
* pages), served suburbs without an indexable page served but unlinked, the rest
|
|
881
910
|
* muted; neighbouring regions outlined for context; job places and the base
|
|
882
|
-
* marked; a label point for every locality in the region.
|
|
911
|
+
* marked; a label point for every locality in the region. From 3.15.0 a region
|
|
912
|
+
* taller than wide is cut to the square stretch holding most of its served places
|
|
913
|
+
* (the served places left out are listed in `outside`, not drawn), and every frame
|
|
914
|
+
* is 0.5 to 0.75 of its width high (`REGION_MAP_ASPECT`), widened to fit a column.
|
|
883
915
|
*/
|
|
884
916
|
export function regionMap(site, regionSlug, options = {}) {
|
|
885
917
|
const drawing = pathOptions(options);
|
|
@@ -889,22 +921,38 @@ export function regionMap(site, regionSlug, options = {}) {
|
|
|
889
921
|
}
|
|
890
922
|
const registry = [site.input.registry, ...registries].find((entry) => regionMembers(entry, resolveRegistrySlug(regionSlug)).length > 0);
|
|
891
923
|
const members = registry ? regionMembers(registry, resolveRegistrySlug(regionSlug)) : [];
|
|
892
|
-
const regionBounds = shapeBounds(region.shape);
|
|
893
|
-
const frame = fitAreaMapFrame(regionBounds, { width: options.width ?? 1000, padding: options.padding ?? 0.06 });
|
|
894
|
-
const visibleBounds = frameBounds(frame);
|
|
895
924
|
// The site may publish a member under a legacy slug: state and links follow the published slug.
|
|
896
925
|
const publishedFor = new Map();
|
|
897
926
|
for (const slug of site.input.estate.published)
|
|
898
927
|
publishedFor.set(resolveRegistrySlug(slug), slug);
|
|
928
|
+
const places = [...members]
|
|
929
|
+
.sort((a, b) => a.name.localeCompare(b.name))
|
|
930
|
+
.flatMap((member) => {
|
|
931
|
+
const slug = publishedFor.get(member.slug) ?? member.slug;
|
|
932
|
+
const place = site.place(slug);
|
|
933
|
+
return place?.shape ? [{ slug, place, state: site.stateOf(slug) }] : [];
|
|
934
|
+
});
|
|
935
|
+
const regionBounds = regionFitBounds(shapeBounds(region.shape), places);
|
|
936
|
+
const width = options.width ?? 1000;
|
|
937
|
+
const padding = options.padding ?? 0.06;
|
|
938
|
+
const natural = fitAreaMapFrame(regionBounds, { width, padding });
|
|
939
|
+
const ratio = natural.height / natural.width;
|
|
940
|
+
const aspect = Math.min(Math.max(ratio, REGION_MAP_ASPECT.min), REGION_MAP_ASPECT.max);
|
|
941
|
+
const frame = aspect === ratio ? natural : fitAreaMapFrame(regionBounds, { width, padding, aspect });
|
|
942
|
+
const visibleBounds = frameBounds(frame);
|
|
899
943
|
const shapes = [];
|
|
900
944
|
const labels = [];
|
|
901
945
|
const served = [];
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
946
|
+
const outside = [];
|
|
947
|
+
for (const { slug, place, state } of places) {
|
|
948
|
+
if (!place.shape)
|
|
949
|
+
continue;
|
|
950
|
+
if (state !== 'muted' && place.centre && !inside(frame, projectAreaMapPoint(frame, place.centre))) {
|
|
951
|
+
outside.push({ key: place.shape.key, slug: place.slug, name: place.name, ...(state === 'linked' ? { href: site.input.href(place.slug) } : {}) });
|
|
952
|
+
// Still filled as served where it reaches into the frame, never linked or named there.
|
|
953
|
+
served.push(place.shape.key);
|
|
906
954
|
continue;
|
|
907
|
-
|
|
955
|
+
}
|
|
908
956
|
if (state === 'linked') {
|
|
909
957
|
const shape = shapeFor(site, place, frame, drawing);
|
|
910
958
|
if (shape)
|
|
@@ -934,6 +982,7 @@ export function regionMap(site, regionSlug, options = {}) {
|
|
|
934
982
|
served,
|
|
935
983
|
outline: [...new Set([...neighbours, ...members.map((member) => `suburb:${member.slug}`)])],
|
|
936
984
|
},
|
|
985
|
+
outside,
|
|
937
986
|
});
|
|
938
987
|
}
|
|
939
988
|
/**
|
|
@@ -1047,12 +1096,20 @@ function outlinePath(site, keys, frame, options) {
|
|
|
1047
1096
|
}
|
|
1048
1097
|
return linesPath(lines, options.precision);
|
|
1049
1098
|
}
|
|
1099
|
+
/**
|
|
1100
|
+
* A linked shape's element id in the base file (3.15.0): its key with the colon as a hyphen (`suburb-castle-hill`,
|
|
1101
|
+
* `region-hills-district`, `place-young`). The page draws it with `<use href="<file>#<id>">` inside the shape's link.
|
|
1102
|
+
*/
|
|
1103
|
+
export function areaMapShapeId(shape) {
|
|
1104
|
+
return shape.key.replace(':', '-');
|
|
1105
|
+
}
|
|
1050
1106
|
/**
|
|
1051
1107
|
* The static base layer of a model as an SVG document: `land` (all land in the
|
|
1052
1108
|
* frame; water is the space around it), `focus`, `served` and `outline` (unique
|
|
1053
1109
|
* borders, `fill="none"`, non-scaling strokes). The groups set no colours: the
|
|
1054
1110
|
* page draws each with `<use href="<file>#<id>">` and styles the `<use>` with its
|
|
1055
|
-
* own tokens. Serve it from a static route, never inline.
|
|
1111
|
+
* own tokens. Serve it from a static route, never inline. With `linked: true` the file also holds the linked shapes
|
|
1112
|
+
* for `<use>` (`areaMapShapeId`).
|
|
1056
1113
|
*/
|
|
1057
1114
|
export function renderAreaMapBaseSvg(site, model, options = {}) {
|
|
1058
1115
|
const drawing = { tolerance: options.tolerance ?? 0.6, precision: options.precision ?? 0 };
|
|
@@ -1062,7 +1119,10 @@ export function renderAreaMapBaseSvg(site, model, options = {}) {
|
|
|
1062
1119
|
...frameRings(areaMapBoundaries, 'land', frame, drawing),
|
|
1063
1120
|
...(siteLand && Object.hasOwn(siteLand.shapes, 'land') ? frameRings(siteLand, 'land', frame, drawing) : []),
|
|
1064
1121
|
], drawing.precision);
|
|
1065
|
-
const
|
|
1122
|
+
const defs = options.linked && model.shapes.length > 0
|
|
1123
|
+
? [`<defs>${model.shapes.map((shape) => `<path id="${areaMapShapeId(shape)}" d="${shape.d}"/>`).join('')}</defs>`]
|
|
1124
|
+
: [];
|
|
1125
|
+
const groups = [...defs, `<g id="land"><path d="${land}" fill-rule="evenodd"/></g>`];
|
|
1066
1126
|
if (model.layers.focus.length > 0)
|
|
1067
1127
|
groups.push(`<g id="focus"><path d="${fillPath(site, model.layers.focus, frame, drawing)}" fill-rule="evenodd"/></g>`);
|
|
1068
1128
|
if (model.layers.served.length > 0)
|