@brandlab-digital/site-core 3.19.1 → 4.0.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 +37 -3
- package/dist/area-map.d.ts +45 -0
- package/dist/area-map.d.ts.map +1 -1
- package/dist/area-map.js +234 -1
- package/dist/area-map.js.map +1 -1
- package/dist/blog.d.ts +5 -0
- package/dist/blog.d.ts.map +1 -1
- package/dist/blog.js +2 -0
- package/dist/blog.js.map +1 -1
- package/dist/jobs.d.ts +24 -5
- package/dist/jobs.d.ts.map +1 -1
- package/dist/jobs.js +20 -5
- package/dist/jobs.js.map +1 -1
- package/dist/navigation.d.ts +1 -1
- package/dist/navigation.js +1 -1
- package/dist/navigation.js.map +1 -1
- package/dist/place-names.d.ts +64 -0
- package/dist/place-names.d.ts.map +1 -0
- package/dist/place-names.js +87 -0
- package/dist/place-names.js.map +1 -0
- package/dist/schema.d.ts +24 -2
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +34 -4
- package/dist/schema.js.map +1 -1
- package/dist/section-order.d.ts +1 -1
- package/dist/section-order.js +1 -1
- package/dist/section-order.js.map +1 -1
- package/package.json +5 -1
package/dist/blog.d.ts
CHANGED
|
@@ -5,6 +5,11 @@ export interface BrandlabBlogAuthor {
|
|
|
5
5
|
id: string;
|
|
6
6
|
name: string;
|
|
7
7
|
profileUrl?: string;
|
|
8
|
+
/**
|
|
9
|
+
* 3.20.0: the `@id` of the graph node this author is, when the byline is the business (its `#business` node): the
|
|
10
|
+
* article's schema then refers to that node instead of typing the business as a Person.
|
|
11
|
+
*/
|
|
12
|
+
schemaId?: string;
|
|
8
13
|
}
|
|
9
14
|
export interface BrandlabBlogPost {
|
|
10
15
|
id: string;
|
package/dist/blog.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blog.d.ts","sourceRoot":"","sources":["../src/blog.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAA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AC,EAAE,SAAS,MAAM,EAAE,CAAA;IACxB,KAAK,CAAC,EAAE;QACN,GAAG,EAAE,MAAM,CAAA;QACX,GAAG,EAAE,MAAM,CAAA;KACZ,CAAA;IACD,UAAU,EAAE,MAAM,CAAA;CACnB;AAoBD,wBAAgB,cAAc,CAAC,KAAK,CAAC,CAAC,SAAS,gBAAgB,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,CA2F3E;AAcD,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,gBAAgB,EACtB,GAAG,GAAE,IAAiB,GACrB,IAAI,IAAI,gBAAgB,GAAG;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAMzE;AAED,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,SAAS,gBAAgB,EAAE,EAClC,GAAG,GAAE,IAAiB;YAGiC,WAAW;iBAAe,MAAM;KAIxF;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CASnD;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,KAG1B,MAAM,MAAM,KAAG,MAAM,CAQ9B"}
|
package/dist/blog.js
CHANGED
|
@@ -72,6 +72,8 @@ export function defineBlogPost(post) {
|
|
|
72
72
|
}
|
|
73
73
|
if (author.profileUrl)
|
|
74
74
|
assertAbsoluteHttpsUrl(author.profileUrl, `authors[${index}].profileUrl`);
|
|
75
|
+
if (author.schemaId !== undefined)
|
|
76
|
+
assertAbsoluteHttpsUrl(author.schemaId, `authors[${index}].schemaId`);
|
|
75
77
|
});
|
|
76
78
|
post.categories?.forEach((category, index) => assertNonEmpty(category, `categories[${index}]`));
|
|
77
79
|
post.tags?.forEach((tag, index) => assertNonEmpty(tag, `tags[${index}]`));
|
package/dist/blog.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blog.js","sourceRoot":"","sources":["../src/blog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,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CAAC,IAAI,EAAE,GAAG,CAAC,CAC/B;SACA,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAA;AACxF,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,MAAM,IAAI,GAAG,IAAI;SACd,WAAW,EAAE;SACb,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC;SACxB,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;SACpB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;SACnB,IAAI,EAAE,CAAA;IAET,OAAO,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAA;AAC3C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB;IAClC,MAAM,UAAU,GAAG,IAAI,GAAG,EAAkB,CAAA;IAE5C,OAAO,CAAC,IAAY,EAAU,EAAE;QAC9B,MAAM,QAAQ,GAAG,cAAc,CAAC,IAAI,CAAC,CAAA;QACrC,MAAM,KAAK,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAA;QAEjD,UAAU,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAA;QAE/B,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,QAAQ,IAAI,KAAK,EAAE,CAAA;IACxD,CAAC,CAAA;AACH,CAAC","sourcesContent":["import { normalizeBrandlabRoutePath } from './routes.js'\nimport type { BrandlabMetadataTitleMode } from './metadata.js'\n\nexport type BrandlabBlogAdapter = 'mdx' | 'structured'\nexport type BrandlabBlogPostStatus = 'draft' | 'published'\n\nexport interface BrandlabBlogAuthor {\n id: string\n name: string\n profileUrl?: string\n}\n\nexport interface BrandlabBlogPost {\n id: string\n slug: string\n path: string\n adapter: BrandlabBlogAdapter\n status: BrandlabBlogPostStatus\n headline: string\n description: string\n /** Optional reviewed search title. The visible and schema headline remains `headline`. */\n seo?: {\n title: string\n titleMode?: BrandlabMetadataTitleMode\n }\n publishedAt?: string\n modifiedAt?: string\n authors: readonly BrandlabBlogAuthor[]\n categories?: readonly string[]\n tags?: readonly string[]\n image?: {\n url: string\n alt: string\n }\n contentRef: string\n}\n\nfunction assertNonEmpty(value: string, field: string) {\n if (!value.trim()) throw new Error(`${field} cannot be empty.`)\n}\n\nfunction parseDate(value: string | undefined, field: string) {\n if (!value) return undefined\n const timestamp = Date.parse(value)\n if (Number.isNaN(timestamp)) throw new Error(`${field} must be a valid date.`)\n return timestamp\n}\n\nconst BLOG_ADAPTERS = new Set<BrandlabBlogAdapter>(['mdx', 'structured'])\nconst BLOG_POST_STATUSES = new Set<BrandlabBlogPostStatus>(['draft', 'published'])\nconst BLOG_METADATA_TITLE_MODES = new Set<BrandlabMetadataTitleMode>([\n 'templated',\n 'absolute',\n])\n\nexport function defineBlogPost<const T extends BrandlabBlogPost>(post: T): T {\n assertNonEmpty(post.id, 'id')\n assertNonEmpty(post.slug, 'slug')\n assertNonEmpty(post.path, 'path')\n assertNonEmpty(post.headline, 'headline')\n assertNonEmpty(post.description, 'description')\n assertNonEmpty(post.contentRef, 'contentRef')\n\n if (post.seo) {\n if (\n typeof post.seo.title !== 'string' ||\n !post.seo.title.trim() ||\n post.seo.title.trim() !== post.seo.title ||\n post.seo.title.length > 160 ||\n /[\\u0000-\\u001f\\u007f]/.test(post.seo.title)\n ) {\n throw new Error('seo.title must be bounded, trimmed, single-line text.')\n }\n if (\n post.seo.titleMode !== undefined &&\n !BLOG_METADATA_TITLE_MODES.has(post.seo.titleMode)\n ) {\n throw new Error('seo.titleMode must be \"templated\" or \"absolute\".')\n }\n }\n\n if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(post.id)) {\n throw new Error('id must be lowercase kebab-case.')\n }\n if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(post.slug)) {\n throw new Error('slug must be lowercase kebab-case.')\n }\n if (!BLOG_ADAPTERS.has(post.adapter)) {\n throw new Error('adapter must be \"mdx\" or \"structured\".')\n }\n if (!BLOG_POST_STATUSES.has(post.status)) {\n throw new Error('status must be \"draft\" or \"published\".')\n }\n try {\n normalizeBrandlabRoutePath(post.path)\n } catch {\n throw new Error('path must be root-relative without a query string or hash.')\n }\n if (post.path.split('/').filter(Boolean).at(-1) !== post.slug) {\n throw new Error('path must end with the canonical post slug.')\n }\n if (post.authors.length === 0) throw new Error('authors cannot be empty.')\n const authorIds = post.authors.map((author) => author.id)\n if (new Set(authorIds).size !== authorIds.length) {\n throw new Error('authors contains duplicate IDs.')\n }\n post.authors.forEach((author, index) => {\n assertNonEmpty(author.id, `authors[${index}].id`)\n assertNonEmpty(author.name, `authors[${index}].name`)\n if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(author.id)) {\n throw new Error(`authors[${index}].id must be lowercase kebab-case.`)\n }\n if (author.profileUrl) assertAbsoluteHttpsUrl(author.profileUrl, `authors[${index}].profileUrl`)\n })\n post.categories?.forEach((category, index) =>\n assertNonEmpty(category, `categories[${index}]`),\n )\n post.tags?.forEach((tag, index) => assertNonEmpty(tag, `tags[${index}]`))\n if (post.categories && new Set(post.categories).size !== post.categories.length) {\n throw new Error('categories contains duplicates.')\n }\n if (post.tags && new Set(post.tags).size !== post.tags.length) {\n throw new Error('tags contains duplicates.')\n }\n\n const publishedAt = parseDate(post.publishedAt, 'publishedAt')\n const modifiedAt = parseDate(post.modifiedAt, 'modifiedAt')\n if (post.status === 'published' && publishedAt === undefined) {\n throw new Error('A published post requires publishedAt.')\n }\n if (publishedAt !== undefined && modifiedAt !== undefined && modifiedAt < publishedAt) {\n throw new Error('modifiedAt cannot be earlier than publishedAt.')\n }\n\n if (post.image) {\n assertNonEmpty(post.image.url, 'image.url')\n assertNonEmpty(post.image.alt, 'image.alt')\n if (post.image.url.startsWith('/')) {\n normalizeBrandlabRoutePath(post.image.url)\n } else {\n assertAbsoluteHttpsUrl(post.image.url, 'image.url')\n }\n }\n\n return post\n}\n\nfunction assertAbsoluteHttpsUrl(value: string, field: string) {\n let url: URL\n try {\n url = new URL(value)\n } catch {\n throw new Error(`${field} must be an absolute HTTPS URL.`)\n }\n if (url.protocol !== 'https:' || url.username || url.password) {\n throw new Error(`${field} must be an absolute HTTPS URL.`)\n }\n}\n\nexport function isPublishedBlogPost(\n post: BrandlabBlogPost,\n now: Date = new Date(),\n): post is BrandlabBlogPost & { status: 'published'; publishedAt: string } {\n return (\n post.status === 'published' &&\n Boolean(post.publishedAt) &&\n Date.parse(post.publishedAt ?? '') <= now.getTime()\n )\n}\n\nexport function getPublishedBlogPosts(\n posts: readonly BrandlabBlogPost[],\n now: Date = new Date(),\n) {\n return posts\n .filter((post): post is BrandlabBlogPost & { status: 'published'; publishedAt: string } =>\n isPublishedBlogPost(post, now),\n )\n .sort((left, right) => Date.parse(right.publishedAt) - Date.parse(left.publishedAt))\n}\n\n/**\n * Heading anchor slug used by the fleet's MDX heading IDs: lower-case, drop\n * characters other than letters, digits, underscores, spaces and hyphens, then\n * hyphenate whitespace. Headings without usable text become `section`.\n */\nexport function slugifyHeading(text: string): string {\n const slug = text\n .toLowerCase()\n .replace(/[^\\w\\s-]/g, '')\n .replace(/\\s+/g, '-')\n .replace(/-+/g, '-')\n .trim()\n\n return slug.length > 0 ? slug : 'section'\n}\n\n/**\n * Returns a per-document slugger: create one per rendered article so repeated\n * heading text receives `-2`, `-3` suffixes in document order.\n */\nexport function createHeadingSlugger() {\n const slugCounts = new Map<string, number>()\n\n return (text: string): string => {\n const baseSlug = slugifyHeading(text)\n const count = (slugCounts.get(baseSlug) ?? 0) + 1\n\n slugCounts.set(baseSlug, count)\n\n return count === 1 ? baseSlug : `${baseSlug}-${count}`\n }\n}\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,KAAK,EAAE,CAAA;IACxD,CAAC,CAAA;AACH,CAAC","sourcesContent":["import { normalizeBrandlabRoutePath } from './routes.js'\nimport type { BrandlabMetadataTitleMode } from './metadata.js'\n\nexport type BrandlabBlogAdapter = 'mdx' | 'structured'\nexport type BrandlabBlogPostStatus = 'draft' | 'published'\n\nexport interface BrandlabBlogAuthor {\n id: string\n name: string\n profileUrl?: string\n /**\n * 3.20.0: the `@id` of the graph node this author is, when the byline is the business (its `#business` node): the\n * article's schema then refers to that node instead of typing the business as a Person.\n */\n schemaId?: string\n}\n\nexport interface BrandlabBlogPost {\n id: string\n slug: string\n path: string\n adapter: BrandlabBlogAdapter\n status: BrandlabBlogPostStatus\n headline: string\n description: string\n /** Optional reviewed search title. The visible and schema headline remains `headline`. */\n seo?: {\n title: string\n titleMode?: BrandlabMetadataTitleMode\n }\n publishedAt?: string\n modifiedAt?: string\n authors: readonly BrandlabBlogAuthor[]\n categories?: readonly string[]\n tags?: readonly string[]\n image?: {\n url: string\n alt: string\n }\n contentRef: string\n}\n\nfunction assertNonEmpty(value: string, field: string) {\n if (!value.trim()) throw new Error(`${field} cannot be empty.`)\n}\n\nfunction parseDate(value: string | undefined, field: string) {\n if (!value) return undefined\n const timestamp = Date.parse(value)\n if (Number.isNaN(timestamp)) throw new Error(`${field} must be a valid date.`)\n return timestamp\n}\n\nconst BLOG_ADAPTERS = new Set<BrandlabBlogAdapter>(['mdx', 'structured'])\nconst BLOG_POST_STATUSES = new Set<BrandlabBlogPostStatus>(['draft', 'published'])\nconst BLOG_METADATA_TITLE_MODES = new Set<BrandlabMetadataTitleMode>([\n 'templated',\n 'absolute',\n])\n\nexport function defineBlogPost<const T extends BrandlabBlogPost>(post: T): T {\n assertNonEmpty(post.id, 'id')\n assertNonEmpty(post.slug, 'slug')\n assertNonEmpty(post.path, 'path')\n assertNonEmpty(post.headline, 'headline')\n assertNonEmpty(post.description, 'description')\n assertNonEmpty(post.contentRef, 'contentRef')\n\n if (post.seo) {\n if (\n typeof post.seo.title !== 'string' ||\n !post.seo.title.trim() ||\n post.seo.title.trim() !== post.seo.title ||\n post.seo.title.length > 160 ||\n /[\\u0000-\\u001f\\u007f]/.test(post.seo.title)\n ) {\n throw new Error('seo.title must be bounded, trimmed, single-line text.')\n }\n if (\n post.seo.titleMode !== undefined &&\n !BLOG_METADATA_TITLE_MODES.has(post.seo.titleMode)\n ) {\n throw new Error('seo.titleMode must be \"templated\" or \"absolute\".')\n }\n }\n\n if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(post.id)) {\n throw new Error('id must be lowercase kebab-case.')\n }\n if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(post.slug)) {\n throw new Error('slug must be lowercase kebab-case.')\n }\n if (!BLOG_ADAPTERS.has(post.adapter)) {\n throw new Error('adapter must be \"mdx\" or \"structured\".')\n }\n if (!BLOG_POST_STATUSES.has(post.status)) {\n throw new Error('status must be \"draft\" or \"published\".')\n }\n try {\n normalizeBrandlabRoutePath(post.path)\n } catch {\n throw new Error('path must be root-relative without a query string or hash.')\n }\n if (post.path.split('/').filter(Boolean).at(-1) !== post.slug) {\n throw new Error('path must end with the canonical post slug.')\n }\n if (post.authors.length === 0) throw new Error('authors cannot be empty.')\n const authorIds = post.authors.map((author) => author.id)\n if (new Set(authorIds).size !== authorIds.length) {\n throw new Error('authors contains duplicate IDs.')\n }\n post.authors.forEach((author, index) => {\n assertNonEmpty(author.id, `authors[${index}].id`)\n assertNonEmpty(author.name, `authors[${index}].name`)\n if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(author.id)) {\n throw new Error(`authors[${index}].id must be lowercase kebab-case.`)\n }\n if (author.profileUrl) assertAbsoluteHttpsUrl(author.profileUrl, `authors[${index}].profileUrl`)\n if (author.schemaId !== undefined) assertAbsoluteHttpsUrl(author.schemaId, `authors[${index}].schemaId`)\n })\n post.categories?.forEach((category, index) =>\n assertNonEmpty(category, `categories[${index}]`),\n )\n post.tags?.forEach((tag, index) => assertNonEmpty(tag, `tags[${index}]`))\n if (post.categories && new Set(post.categories).size !== post.categories.length) {\n throw new Error('categories contains duplicates.')\n }\n if (post.tags && new Set(post.tags).size !== post.tags.length) {\n throw new Error('tags contains duplicates.')\n }\n\n const publishedAt = parseDate(post.publishedAt, 'publishedAt')\n const modifiedAt = parseDate(post.modifiedAt, 'modifiedAt')\n if (post.status === 'published' && publishedAt === undefined) {\n throw new Error('A published post requires publishedAt.')\n }\n if (publishedAt !== undefined && modifiedAt !== undefined && modifiedAt < publishedAt) {\n throw new Error('modifiedAt cannot be earlier than publishedAt.')\n }\n\n if (post.image) {\n assertNonEmpty(post.image.url, 'image.url')\n assertNonEmpty(post.image.alt, 'image.alt')\n if (post.image.url.startsWith('/')) {\n normalizeBrandlabRoutePath(post.image.url)\n } else {\n assertAbsoluteHttpsUrl(post.image.url, 'image.url')\n }\n }\n\n return post\n}\n\nfunction assertAbsoluteHttpsUrl(value: string, field: string) {\n let url: URL\n try {\n url = new URL(value)\n } catch {\n throw new Error(`${field} must be an absolute HTTPS URL.`)\n }\n if (url.protocol !== 'https:' || url.username || url.password) {\n throw new Error(`${field} must be an absolute HTTPS URL.`)\n }\n}\n\nexport function isPublishedBlogPost(\n post: BrandlabBlogPost,\n now: Date = new Date(),\n): post is BrandlabBlogPost & { status: 'published'; publishedAt: string } {\n return (\n post.status === 'published' &&\n Boolean(post.publishedAt) &&\n Date.parse(post.publishedAt ?? '') <= now.getTime()\n )\n}\n\nexport function getPublishedBlogPosts(\n posts: readonly BrandlabBlogPost[],\n now: Date = new Date(),\n) {\n return posts\n .filter((post): post is BrandlabBlogPost & { status: 'published'; publishedAt: string } =>\n isPublishedBlogPost(post, now),\n )\n .sort((left, right) => Date.parse(right.publishedAt) - Date.parse(left.publishedAt))\n}\n\n/**\n * Heading anchor slug used by the fleet's MDX heading IDs: lower-case, drop\n * characters other than letters, digits, underscores, spaces and hyphens, then\n * hyphenate whitespace. Headings without usable text become `section`.\n */\nexport function slugifyHeading(text: string): string {\n const slug = text\n .toLowerCase()\n .replace(/[^\\w\\s-]/g, '')\n .replace(/\\s+/g, '-')\n .replace(/-+/g, '-')\n .trim()\n\n return slug.length > 0 ? slug : 'section'\n}\n\n/**\n * Returns a per-document slugger: create one per rendered article so repeated\n * heading text receives `-2`, `-3` suffixes in document order.\n */\nexport function createHeadingSlugger() {\n const slugCounts = new Map<string, number>()\n\n return (text: string): string => {\n const baseSlug = slugifyHeading(text)\n const count = (slugCounts.get(baseSlug) ?? 0) + 1\n\n slugCounts.set(baseSlug, count)\n\n return count === 1 ? baseSlug : `${baseSlug}-${count}`\n }\n}\n"]}
|
package/dist/jobs.d.ts
CHANGED
|
@@ -2,9 +2,13 @@
|
|
|
2
2
|
* The job log (`src/data/jobs.ts`, 3.14.0): one row per completed job the owner has confirmed, shared by `NearbyJobs`,
|
|
3
3
|
* project cards, the area map's job places and head-tier decisions. A job names its suburb (registry slug), service
|
|
4
4
|
* and what was done; its month is optional, because owners often remember the job but not when (a card then shows the
|
|
5
|
-
* suburb without "Recent" or a date: "Tree removal
|
|
5
|
+
* suburb without "Recent" or a date: "Tree removal in Ryde"). Photos are media-manifest ids, so each carries its
|
|
6
6
|
* provenance; only genuine photos of that job may illustrate it.
|
|
7
7
|
*
|
|
8
|
+
* Website standard (4 Nov 2026): each job card carries a small, plain label naming its own suburb (`jobPlaceLabel`),
|
|
9
|
+
* another suburb's name never goes in a heading, and a job is called nearby only when its suburb shares a border with
|
|
10
|
+
* the page's (`suburbsTouch` in `site-core/area-map`).
|
|
11
|
+
*
|
|
8
12
|
* Distances rank job cards and are never printed: location copy carries no kilometre figures (L10).
|
|
9
13
|
*/
|
|
10
14
|
import type { SuburbCentreLookup } from './locations.js';
|
|
@@ -46,16 +50,31 @@ export declare function jobPhotos(job: BrandlabJob, media: BrandlabMediaManifest
|
|
|
46
50
|
readonly id: string;
|
|
47
51
|
})[];
|
|
48
52
|
/**
|
|
49
|
-
* A job
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
+
* A job's label: "{Service} in {Suburb}", naming the job's own suburb, on its own suburb's page and any other (3.20.0;
|
|
54
|
+
* before, another suburb's job always read "nearby: {Suburb}"). "{Service} nearby: {Suburb}" only with `nearby: true`,
|
|
55
|
+
* for a job whose suburb shares a border with the page's (`suburbsTouch` in `site-core/area-map`). Only a dated job
|
|
56
|
+
* says "Recent" (or `prefix`; `''` for none) and ends with ", {Month Year}": "Recent tree removal in Ryde, May 2026",
|
|
57
|
+
* but "Tree removal in Ryde" when the month is unknown, because an undated job may not be recent. On a page about
|
|
58
|
+
* another suburb this names that suburb, so it is a caption or label, never a heading (`jobPlaceLabel` is the plain
|
|
59
|
+
* suburb label beside a heading about the work).
|
|
53
60
|
*/
|
|
54
61
|
export declare function jobCardLabel(job: BrandlabJob, options: {
|
|
55
62
|
readonly service: string;
|
|
56
63
|
readonly suburbName: string;
|
|
57
64
|
readonly pageSuburb?: string;
|
|
58
65
|
readonly prefix?: string;
|
|
66
|
+
/** The job's suburb shares a border with the page's; ignored for the page's own suburb. */
|
|
67
|
+
readonly nearby?: boolean;
|
|
68
|
+
}): string;
|
|
69
|
+
/**
|
|
70
|
+
* A job card's small, plain place label (3.20.0): the job's suburb, then its month when known: "Ryde · May 2026", or
|
|
71
|
+
* "Ryde". With `nearby: true` (the suburbs share a border: `suburbsTouch` in `site-core/area-map`) it leads with
|
|
72
|
+
* "Nearby": "Nearby · Ryde · May 2026". It sits beside a heading about the work, so no heading names another suburb.
|
|
73
|
+
*/
|
|
74
|
+
export declare function jobPlaceLabel(job: BrandlabJob, options: {
|
|
75
|
+
readonly suburbName: string;
|
|
76
|
+
readonly nearby?: boolean;
|
|
77
|
+
readonly separator?: string;
|
|
59
78
|
}): string;
|
|
60
79
|
export interface BrandlabNearbyJob<T extends BrandlabJob = BrandlabJob> {
|
|
61
80
|
readonly job: T;
|
package/dist/jobs.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jobs.d.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CAAC,CAAC,EAAE,CAiBxB;AAED,mHAAmH;AACnH,wBAAgB,SAAS,CAAC,IAAI,EAAE,SAAS,WAAW,EAAE,GAAG,MAAM,EAAE,CAEhE"}
|
package/dist/jobs.js
CHANGED
|
@@ -67,20 +67,35 @@ function formatMonth(month) {
|
|
|
67
67
|
return new Intl.DateTimeFormat('en-AU', { month: 'long', year: 'numeric', timeZone: 'UTC' }).format(new Date(`${month}-01T00:00:00Z`));
|
|
68
68
|
}
|
|
69
69
|
/**
|
|
70
|
-
* A job
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
70
|
+
* A job's label: "{Service} in {Suburb}", naming the job's own suburb, on its own suburb's page and any other (3.20.0;
|
|
71
|
+
* before, another suburb's job always read "nearby: {Suburb}"). "{Service} nearby: {Suburb}" only with `nearby: true`,
|
|
72
|
+
* for a job whose suburb shares a border with the page's (`suburbsTouch` in `site-core/area-map`). Only a dated job
|
|
73
|
+
* says "Recent" (or `prefix`; `''` for none) and ends with ", {Month Year}": "Recent tree removal in Ryde, May 2026",
|
|
74
|
+
* but "Tree removal in Ryde" when the month is unknown, because an undated job may not be recent. On a page about
|
|
75
|
+
* another suburb this names that suburb, so it is a caption or label, never a heading (`jobPlaceLabel` is the plain
|
|
76
|
+
* suburb label beside a heading about the work).
|
|
74
77
|
*/
|
|
75
78
|
export function jobCardLabel(job, options) {
|
|
76
79
|
const service = options.service.trim().toLowerCase();
|
|
77
|
-
const where = job.suburb
|
|
80
|
+
const where = job.suburb !== options.pageSuburb && options.nearby === true ? `nearby: ${options.suburbName}` : `in ${options.suburbName}`;
|
|
78
81
|
if (!job.month)
|
|
79
82
|
return `${capitalise(service)} ${where}`;
|
|
80
83
|
const prefix = (options.prefix ?? 'Recent').trim();
|
|
81
84
|
const lead = prefix ? `${prefix} ${service}` : capitalise(service);
|
|
82
85
|
return `${lead} ${where}, ${formatMonth(job.month)}`;
|
|
83
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* A job card's small, plain place label (3.20.0): the job's suburb, then its month when known: "Ryde · May 2026", or
|
|
89
|
+
* "Ryde". With `nearby: true` (the suburbs share a border: `suburbsTouch` in `site-core/area-map`) it leads with
|
|
90
|
+
* "Nearby": "Nearby · Ryde · May 2026". It sits beside a heading about the work, so no heading names another suburb.
|
|
91
|
+
*/
|
|
92
|
+
export function jobPlaceLabel(job, options) {
|
|
93
|
+
const suburb = options.suburbName.trim();
|
|
94
|
+
if (!suburb)
|
|
95
|
+
throw new Error(`jobPlaceLabel: job "${job.id}" has no suburb name.`);
|
|
96
|
+
const separator = options.separator ?? ' · ';
|
|
97
|
+
return [...(options.nearby === true ? ['Nearby'] : []), suburb, ...(job.month ? [formatMonth(job.month)] : [])].join(separator);
|
|
98
|
+
}
|
|
84
99
|
function capitalise(text) {
|
|
85
100
|
return text.charAt(0).toUpperCase() + text.slice(1);
|
|
86
101
|
}
|
package/dist/jobs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jobs.js","sourceRoot":"","sources":["../src/jobs.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAA;AAyBzD,sGAAsG;AACtG,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,CAAA;AACjC,yCAAyC;AACzC,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAA;AAE/B,MAAM,IAAI,GAAG,4BAA4B,CAAA;AACzC,MAAM,KAAK,GAAG,2BAA2B,CAAA;AACzC,MAAM,QAAQ,GAAG,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAA;AAE7F,SAAS,UAAU,CAAC,KAAc,EAAE,KAAa,EAAE,OAAe;IAChE,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,KAA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(`src/data/jobs.ts`, 3.14.0): one row per completed job the owner has confirmed, shared by `NearbyJobs`,\n * project cards, the area map's job places and head-tier decisions. A job names its suburb (registry slug), service\n * and what was done; its month is optional, because owners often remember the job but not when (a card then shows the\n * suburb without \"Recent\" or a date: \"Tree removal nearby: Ryde\"). Photos are media-manifest ids, so each carries its\n * provenance; only genuine photos of that job may illustrate it.\n *\n * Distances rank job cards and are never printed: location copy carries no kilometre figures (L10).\n */\nimport type { SuburbCentreLookup } from './locations.js'\nimport { distanceBetweenCentresKm } from './locations.js'\nimport type { BrandlabMediaEntry, BrandlabMediaManifest } from './media.js'\n\nexport interface BrandlabJob {\n /** A stable kebab-case id; genuine photos of the job name it in their media entry's `job`. */\n readonly id: string\n /** The registry suburb slug, for example \"ryde\". */\n readonly suburb: string\n /** The service slug, as the site's service catalogue names it. */\n readonly service: string\n /** What was done, in one line of Australian English. */\n readonly outcome: string\n /**\n * The job's own short title (3.17.0), for example \"Leaning gum beside a pool\". A job card uses it where its label\n * would repeat another card's (\"Tree removal in Eastwood\" twice), or on every card with `cardTitle: 'job'`.\n */\n readonly title?: string\n /** YYYY-MM, when the owner knows it. */\n readonly month?: string\n /** Media-manifest ids of genuine photos of this job. */\n readonly photos?: readonly string[]\n /** Who confirmed the job and when, for example \"Owner, WhatsApp 3 Oct 2026\". */\n readonly source: string\n}\n\n/** Job cards show jobs within this distance of the page's suburb (v2: the 10 km cap on job cards). */\nexport const JOB_CARD_MAX_KM = 10\n/** Cards per page (playbook: 1 to 3). */\nexport const JOB_CARD_LIMIT = 3\n\nconst SLUG = /^[a-z0-9]+(?:-[a-z0-9]+)*$/\nconst MONTH = /^\\d{4}-(?:0[1-9]|1[0-2])$/\nconst JOB_KEYS = ['id', 'suburb', 'service', 'outcome', 'title', 'month', 'photos', 'source']\n\nfunction assertText(value: unknown, field: string, maximum: number) {\n if (typeof value !== 'string' || !value.trim() || value.trim() !== value || value.length > maximum || /[\\u0000-\\u001f\\u007f]/.test(value)) {\n throw new Error(`${field} must be bounded, trimmed text.`)\n }\n}\n\n/**\n * Validates the job log. With the media manifest, every photo must exist, be `genuine` (stock and AI images never\n * stand for the client's work) and, when its entry names a job, name this one.\n */\nexport function defineJobs<const T extends readonly BrandlabJob[]>(jobs: T, options: { readonly media?: BrandlabMediaManifest } = {}): T {\n if (!Array.isArray(jobs)) throw new Error('The job log must be a list.')\n const ids = new Set<string>()\n jobs.forEach((job, index) => {\n const field = `jobs[${index}]`\n if (!job || typeof job !== 'object' || Array.isArray(job)) throw new Error(`${field} must be a record.`)\n const unknown = Object.keys(job).find((key) => !JOB_KEYS.includes(key))\n if (unknown) throw new Error(`${field}.${unknown} is not a job field.`)\n if (typeof job.id !== 'string' || !SLUG.test(job.id)) throw new Error(`${field}.id must be a kebab-case id.`)\n if (ids.has(job.id)) throw new Error(`The job log lists \"${job.id}\" more than once.`)\n ids.add(job.id)\n if (typeof job.suburb !== 'string' || !SLUG.test(job.suburb)) throw new Error(`${field}.suburb must be the registry suburb slug.`)\n if (typeof job.service !== 'string' || !SLUG.test(job.service)) throw new Error(`${field}.service must be the service slug.`)\n assertText(job.outcome, `${field}.outcome`, 300)\n assertText(job.source, `${field}.source`, 200)\n if (job.title !== undefined) assertText(job.title, `${field}.title`, 80)\n if (job.month !== undefined && (typeof job.month !== 'string' || !MONTH.test(job.month))) throw new Error(`${field}.month must be YYYY-MM, or left out.`)\n if (job.photos !== undefined) {\n if (!Array.isArray(job.photos)) throw new Error(`${field}.photos must be a list of media ids.`)\n for (const id of job.photos) {\n if (!options.media) continue\n const entry = Object.hasOwn(options.media, id) ? options.media[id] : undefined\n if (!entry) throw new Error(`${field}.photos: \"${id}\" is not in the media manifest.`)\n if (entry.provenance !== 'genuine') throw new Error(`${field}.photos: \"${id}\" is ${entry.provenance}; only genuine photos show a job.`)\n if (entry.job !== undefined && entry.job !== job.id) throw new Error(`${field}.photos: \"${id}\" is a photo of ${entry.job}, not ${job.id}.`)\n }\n }\n })\n return jobs\n}\n\n/** A job's photos from the media manifest, in order, with their ids and provenance. */\nexport function jobPhotos(job: BrandlabJob, media: BrandlabMediaManifest): (BrandlabMediaEntry & { readonly id: string })[] {\n return (job.photos ?? []).flatMap((id) => (Object.hasOwn(media, id) ? [{ id, ...media[id]! }] : []))\n}\n\nfunction formatMonth(month: string): string {\n return new Intl.DateTimeFormat('en-AU', { month: 'long', year: 'numeric', timeZone: 'UTC' }).format(new Date(`${month}-01T00:00:00Z`))\n}\n\n/**\n * A job card's label: \"{Service} in {Suburb}\" for the page's own suburb, \"{Service} nearby: {Suburb}\" for any other\n * (L4 needs the \"nearby\" label). Only a dated job says \"Recent\" (or `prefix`; `''` for none) and ends with\n * \", {Month Year}\": \"Recent tree removal nearby: Ryde, May 2026\", but \"Tree removal nearby: Ryde\" when the month is\n * unknown, because an undated job may not be recent.\n */\nexport function jobCardLabel(\n job: BrandlabJob,\n options: { readonly service: string; readonly suburbName: string; readonly pageSuburb?: string; readonly prefix?: string },\n): string {\n const service = options.service.trim().toLowerCase()\n const where = job.suburb === options.pageSuburb ? `in ${options.suburbName}` : `nearby: ${options.suburbName}`\n if (!job.month) return `${capitalise(service)} ${where}`\n const prefix = (options.prefix ?? 'Recent').trim()\n const lead = prefix ? `${prefix} ${service}` : capitalise(service)\n return `${lead} ${where}, ${formatMonth(job.month)}`\n}\n\nfunction capitalise(text: string): string {\n return text.charAt(0).toUpperCase() + text.slice(1)\n}\n\nexport interface BrandlabNearbyJob<T extends BrandlabJob = BrandlabJob> {\n readonly job: T\n /** For ranking only; never printed. */\n readonly distanceKm: number\n readonly sameSuburb: boolean\n}\n\n/**\n * The job cards for a page about `origin`: its own suburb's jobs first, then other jobs by real distance between\n * registry centres, within `maxKm` (10) and at most `limit` (3); newest first among equals, undated last. Jobs whose\n * suburb has no centre are left out. Filter by `service` for a service-in-suburb page.\n */\nexport function nearbyJobs<T extends BrandlabJob>(\n origin: string,\n jobs: readonly T[],\n options: { readonly centreOf: SuburbCentreLookup; readonly service?: string; readonly maxKm?: number; readonly limit?: number },\n): BrandlabNearbyJob<T>[] {\n const from = options.centreOf(origin)\n if (!from) return []\n const maxKm = options.maxKm ?? JOB_CARD_MAX_KM\n const limit = options.limit ?? JOB_CARD_LIMIT\n const found: BrandlabNearbyJob<T>[] = []\n for (const job of jobs) {\n if (options.service !== undefined && job.service !== options.service) continue\n const sameSuburb = job.suburb === origin\n const to = sameSuburb ? from : options.centreOf(job.suburb)\n if (!to) continue\n const distanceKm = sameSuburb ? 0 : distanceBetweenCentresKm(from, to)\n if (distanceKm <= maxKm) found.push({ job, distanceKm, sameSuburb })\n }\n return found\n .sort((left, right) => left.distanceKm - right.distanceKm || (right.job.month ?? '').localeCompare(left.job.month ?? ''))\n .slice(0, limit)\n}\n\n/** One place per job, for the area map's job markers (`overviewMap`, `regionMap`, `suburbLocator` take `jobs`). */\nexport function jobPlaces(jobs: readonly BrandlabJob[]): string[] {\n return jobs.map((job) => job.suburb)\n}\n"]}
|
|
1
|
+
{"version":3,"file":"jobs.js","sourceRoot":"","sources":["../src/jobs.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAA;AAyBzD,sGAAsG;AACtG,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,CAAA;AACjC,yCAAyC;AACzC,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAA;AAE/B,MAAM,IAAI,GAAG,4BAA4B,CAAA;AACzC,MAAM,KAAK,GAAG,2BAA2B,CAAA;AACzC,MAAM,QAAQ,GAAG,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAA;AAE7F,SAAS,UAAU,CAAC,KAAc,EAAE,KAAa,EAAE,OAAe;IAChE,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,KAAK,IAAI,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C,IAAI,EAAE,EAAE,CAAC,CAAA;QACtE,IAAI,UAAU,IAAI,KAAK;YAAE,KAAK,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC,CAAA;IACtE,CAAC;IACD,OAAO,KAAK;SACT,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;SACxH,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAA;AACpB,CAAC;AAED,mHAAmH;AACnH,MAAM,UAAU,SAAS,CAAC,IAA4B;IACpD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;AACtC,CAAC","sourcesContent":["/**\n * The job log (`src/data/jobs.ts`, 3.14.0): one row per completed job the owner has confirmed, shared by `NearbyJobs`,\n * project cards, the area map's job places and head-tier decisions. A job names its suburb (registry slug), service\n * and what was done; its month is optional, because owners often remember the job but not when (a card then shows the\n * suburb without \"Recent\" or a date: \"Tree removal in Ryde\"). Photos are media-manifest ids, so each carries its\n * provenance; only genuine photos of that job may illustrate it.\n *\n * Website standard (4 Nov 2026): each job card carries a small, plain label naming its own suburb (`jobPlaceLabel`),\n * another suburb's name never goes in a heading, and a job is called nearby only when its suburb shares a border with\n * the page's (`suburbsTouch` in `site-core/area-map`).\n *\n * Distances rank job cards and are never printed: location copy carries no kilometre figures (L10).\n */\nimport type { SuburbCentreLookup } from './locations.js'\nimport { distanceBetweenCentresKm } from './locations.js'\nimport type { BrandlabMediaEntry, BrandlabMediaManifest } from './media.js'\n\nexport interface BrandlabJob {\n /** A stable kebab-case id; genuine photos of the job name it in their media entry's `job`. */\n readonly id: string\n /** The registry suburb slug, for example \"ryde\". */\n readonly suburb: string\n /** The service slug, as the site's service catalogue names it. */\n readonly service: string\n /** What was done, in one line of Australian English. */\n readonly outcome: string\n /**\n * The job's own short title (3.17.0), for example \"Leaning gum beside a pool\". A job card uses it where its label\n * would repeat another card's (\"Tree removal in Eastwood\" twice), or on every card with `cardTitle: 'job'`.\n */\n readonly title?: string\n /** YYYY-MM, when the owner knows it. */\n readonly month?: string\n /** Media-manifest ids of genuine photos of this job. */\n readonly photos?: readonly string[]\n /** Who confirmed the job and when, for example \"Owner, WhatsApp 3 Oct 2026\". */\n readonly source: string\n}\n\n/** Job cards show jobs within this distance of the page's suburb (v2: the 10 km cap on job cards). */\nexport const JOB_CARD_MAX_KM = 10\n/** Cards per page (playbook: 1 to 3). */\nexport const JOB_CARD_LIMIT = 3\n\nconst SLUG = /^[a-z0-9]+(?:-[a-z0-9]+)*$/\nconst MONTH = /^\\d{4}-(?:0[1-9]|1[0-2])$/\nconst JOB_KEYS = ['id', 'suburb', 'service', 'outcome', 'title', 'month', 'photos', 'source']\n\nfunction assertText(value: unknown, field: string, maximum: number) {\n if (typeof value !== 'string' || !value.trim() || value.trim() !== value || value.length > maximum || /[\\u0000-\\u001f\\u007f]/.test(value)) {\n throw new Error(`${field} must be bounded, trimmed text.`)\n }\n}\n\n/**\n * Validates the job log. With the media manifest, every photo must exist, be `genuine` (stock and AI images never\n * stand for the client's work) and, when its entry names a job, name this one.\n */\nexport function defineJobs<const T extends readonly BrandlabJob[]>(jobs: T, options: { readonly media?: BrandlabMediaManifest } = {}): T {\n if (!Array.isArray(jobs)) throw new Error('The job log must be a list.')\n const ids = new Set<string>()\n jobs.forEach((job, index) => {\n const field = `jobs[${index}]`\n if (!job || typeof job !== 'object' || Array.isArray(job)) throw new Error(`${field} must be a record.`)\n const unknown = Object.keys(job).find((key) => !JOB_KEYS.includes(key))\n if (unknown) throw new Error(`${field}.${unknown} is not a job field.`)\n if (typeof job.id !== 'string' || !SLUG.test(job.id)) throw new Error(`${field}.id must be a kebab-case id.`)\n if (ids.has(job.id)) throw new Error(`The job log lists \"${job.id}\" more than once.`)\n ids.add(job.id)\n if (typeof job.suburb !== 'string' || !SLUG.test(job.suburb)) throw new Error(`${field}.suburb must be the registry suburb slug.`)\n if (typeof job.service !== 'string' || !SLUG.test(job.service)) throw new Error(`${field}.service must be the service slug.`)\n assertText(job.outcome, `${field}.outcome`, 300)\n assertText(job.source, `${field}.source`, 200)\n if (job.title !== undefined) assertText(job.title, `${field}.title`, 80)\n if (job.month !== undefined && (typeof job.month !== 'string' || !MONTH.test(job.month))) throw new Error(`${field}.month must be YYYY-MM, or left out.`)\n if (job.photos !== undefined) {\n if (!Array.isArray(job.photos)) throw new Error(`${field}.photos must be a list of media ids.`)\n for (const id of job.photos) {\n if (!options.media) continue\n const entry = Object.hasOwn(options.media, id) ? options.media[id] : undefined\n if (!entry) throw new Error(`${field}.photos: \"${id}\" is not in the media manifest.`)\n if (entry.provenance !== 'genuine') throw new Error(`${field}.photos: \"${id}\" is ${entry.provenance}; only genuine photos show a job.`)\n if (entry.job !== undefined && entry.job !== job.id) throw new Error(`${field}.photos: \"${id}\" is a photo of ${entry.job}, not ${job.id}.`)\n }\n }\n })\n return jobs\n}\n\n/** A job's photos from the media manifest, in order, with their ids and provenance. */\nexport function jobPhotos(job: BrandlabJob, media: BrandlabMediaManifest): (BrandlabMediaEntry & { readonly id: string })[] {\n return (job.photos ?? []).flatMap((id) => (Object.hasOwn(media, id) ? [{ id, ...media[id]! }] : []))\n}\n\nfunction formatMonth(month: string): string {\n return new Intl.DateTimeFormat('en-AU', { month: 'long', year: 'numeric', timeZone: 'UTC' }).format(new Date(`${month}-01T00:00:00Z`))\n}\n\n/**\n * A job's label: \"{Service} in {Suburb}\", naming the job's own suburb, on its own suburb's page and any other (3.20.0;\n * before, another suburb's job always read \"nearby: {Suburb}\"). \"{Service} nearby: {Suburb}\" only with `nearby: true`,\n * for a job whose suburb shares a border with the page's (`suburbsTouch` in `site-core/area-map`). Only a dated job\n * says \"Recent\" (or `prefix`; `''` for none) and ends with \", {Month Year}\": \"Recent tree removal in Ryde, May 2026\",\n * but \"Tree removal in Ryde\" when the month is unknown, because an undated job may not be recent. On a page about\n * another suburb this names that suburb, so it is a caption or label, never a heading (`jobPlaceLabel` is the plain\n * suburb label beside a heading about the work).\n */\nexport function jobCardLabel(\n job: BrandlabJob,\n options: {\n readonly service: string\n readonly suburbName: string\n readonly pageSuburb?: string\n readonly prefix?: string\n /** The job's suburb shares a border with the page's; ignored for the page's own suburb. */\n readonly nearby?: boolean\n },\n): string {\n const service = options.service.trim().toLowerCase()\n const where = job.suburb !== options.pageSuburb && options.nearby === true ? `nearby: ${options.suburbName}` : `in ${options.suburbName}`\n if (!job.month) return `${capitalise(service)} ${where}`\n const prefix = (options.prefix ?? 'Recent').trim()\n const lead = prefix ? `${prefix} ${service}` : capitalise(service)\n return `${lead} ${where}, ${formatMonth(job.month)}`\n}\n\n/**\n * A job card's small, plain place label (3.20.0): the job's suburb, then its month when known: \"Ryde · May 2026\", or\n * \"Ryde\". With `nearby: true` (the suburbs share a border: `suburbsTouch` in `site-core/area-map`) it leads with\n * \"Nearby\": \"Nearby · Ryde · May 2026\". It sits beside a heading about the work, so no heading names another suburb.\n */\nexport function jobPlaceLabel(\n job: BrandlabJob,\n options: { readonly suburbName: string; readonly nearby?: boolean; readonly separator?: string },\n): string {\n const suburb = options.suburbName.trim()\n if (!suburb) throw new Error(`jobPlaceLabel: job \"${job.id}\" has no suburb name.`)\n const separator = options.separator ?? ' · '\n return [...(options.nearby === true ? ['Nearby'] : []), suburb, ...(job.month ? [formatMonth(job.month)] : [])].join(separator)\n}\n\nfunction capitalise(text: string): string {\n return text.charAt(0).toUpperCase() + text.slice(1)\n}\n\nexport interface BrandlabNearbyJob<T extends BrandlabJob = BrandlabJob> {\n readonly job: T\n /** For ranking only; never printed. */\n readonly distanceKm: number\n readonly sameSuburb: boolean\n}\n\n/**\n * The job cards for a page about `origin`: its own suburb's jobs first, then other jobs by real distance between\n * registry centres, within `maxKm` (10) and at most `limit` (3); newest first among equals, undated last. Jobs whose\n * suburb has no centre are left out. Filter by `service` for a service-in-suburb page.\n */\nexport function nearbyJobs<T extends BrandlabJob>(\n origin: string,\n jobs: readonly T[],\n options: { readonly centreOf: SuburbCentreLookup; readonly service?: string; readonly maxKm?: number; readonly limit?: number },\n): BrandlabNearbyJob<T>[] {\n const from = options.centreOf(origin)\n if (!from) return []\n const maxKm = options.maxKm ?? JOB_CARD_MAX_KM\n const limit = options.limit ?? JOB_CARD_LIMIT\n const found: BrandlabNearbyJob<T>[] = []\n for (const job of jobs) {\n if (options.service !== undefined && job.service !== options.service) continue\n const sameSuburb = job.suburb === origin\n const to = sameSuburb ? from : options.centreOf(job.suburb)\n if (!to) continue\n const distanceKm = sameSuburb ? 0 : distanceBetweenCentresKm(from, to)\n if (distanceKm <= maxKm) found.push({ job, distanceKm, sameSuburb })\n }\n return found\n .sort((left, right) => left.distanceKm - right.distanceKm || (right.job.month ?? '').localeCompare(left.job.month ?? ''))\n .slice(0, limit)\n}\n\n/** One place per job, for the area map's job markers (`overviewMap`, `regionMap`, `suburbLocator` take `jobs`). */\nexport function jobPlaces(jobs: readonly BrandlabJob[]): string[] {\n return jobs.map((job) => job.suburb)\n}\n"]}
|
package/dist/navigation.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* `defineBrandlabNavigation` (3.9.0) takes the menu as data plus the rules context (which pages exist, the money
|
|
7
7
|
* services, the recorded order) and enforces the N1 rules, throwing a precise error when one is broken.
|
|
8
8
|
* `validateBrandlabNavigation` returns the same findings without throwing; the conformance rule applies it to a
|
|
9
|
-
* rendered header. The types below are the contract
|
|
9
|
+
* rendered header. The types below are the contract a site's header renders.
|
|
10
10
|
*/
|
|
11
11
|
export interface BrandlabNavLink {
|
|
12
12
|
readonly label: string;
|
package/dist/navigation.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* `defineBrandlabNavigation` (3.9.0) takes the menu as data plus the rules context (which pages exist, the money
|
|
7
7
|
* services, the recorded order) and enforces the N1 rules, throwing a precise error when one is broken.
|
|
8
8
|
* `validateBrandlabNavigation` returns the same findings without throwing; the conformance rule applies it to a
|
|
9
|
-
* rendered header. The types below are the contract
|
|
9
|
+
* rendered header. The types below are the contract a site's header renders.
|
|
10
10
|
*/
|
|
11
11
|
export const BRANDLAB_NAV_PANELS = ['list', 'columns', 'featured'];
|
|
12
12
|
// ---------------------------------------------------------------------------
|