@luhtech/site-template 0.15.1 → 0.16.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luhtech/site-template",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "Shared Astro component library + content-instance contract for LuhTech venture marketing sites -- one template renders every site from content/page.schema.json + content/site.schema.json instances.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -51,10 +51,10 @@
|
|
|
51
51
|
},
|
|
52
52
|
"luhtech": {
|
|
53
53
|
"schemaPins": {
|
|
54
|
-
"content/page.schema.json": "2.
|
|
55
|
-
"content/site.schema.json": "1.
|
|
54
|
+
"content/page.schema.json": "2.5.0",
|
|
55
|
+
"content/site.schema.json": "1.3.0",
|
|
56
56
|
"content/capability-claim.schema.json": "0.2.0",
|
|
57
|
-
"content/tool.schema.json": "1.
|
|
57
|
+
"content/tool.schema.json": "1.2.0",
|
|
58
58
|
"portfolio/brand-identity.schema.json": "1.5.0"
|
|
59
59
|
}
|
|
60
60
|
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
---
|
|
2
|
+
// d-2026-10-01-st-asset-request-form. The gated asset form a cta section
|
|
3
|
+
// renders when it carries assetRequest (page.schema.json v2.5.0): name, work
|
|
4
|
+
// email, company, role and one unticked series opt-in, posted to the capture
|
|
5
|
+
// service (site.leadCapture.assetRequestEndpoint, site.schema.json v1.3.0).
|
|
6
|
+
// The capture service emails a seven-day link; this page only ever shows a
|
|
7
|
+
// confirmation -- it never receives, renders or links the asset itself.
|
|
8
|
+
//
|
|
9
|
+
// An optional "discuss this with us" box, with the page's requestPrompt as
|
|
10
|
+
// its question, also submits a request (request.submitted: an Opportunity).
|
|
11
|
+
// Same anti-bot controls as LeadCaptureForm: a CSS-hidden honeypot and a
|
|
12
|
+
// minimum time-to-submit.
|
|
13
|
+
import { PERSONAS } from '../lib/assetRequest.ts';
|
|
14
|
+
|
|
15
|
+
export interface Props {
|
|
16
|
+
assetRequest: { assetRef: string; requestPrompt?: string };
|
|
17
|
+
leadCapture: { assetRequestEndpoint: string; honeypotField: string; minSubmitMs?: number; ventureField?: string };
|
|
18
|
+
}
|
|
19
|
+
const { assetRequest, leadCapture } = Astro.props;
|
|
20
|
+
const minSubmitMs = leadCapture.minSubmitMs ?? 2000;
|
|
21
|
+
const field = 'w-full px-3 py-2 rounded-md border border-ink/20 bg-canvas text-ink';
|
|
22
|
+
---
|
|
23
|
+
<form
|
|
24
|
+
class="asset-request-form max-w-md space-y-4 text-left"
|
|
25
|
+
data-endpoint={leadCapture.assetRequestEndpoint}
|
|
26
|
+
data-asset-ref={assetRequest.assetRef}
|
|
27
|
+
data-venture={leadCapture.ventureField}
|
|
28
|
+
data-honeypot={leadCapture.honeypotField}
|
|
29
|
+
data-min-submit-ms={minSubmitMs}
|
|
30
|
+
>
|
|
31
|
+
<div class="grid grid-cols-2 gap-3">
|
|
32
|
+
<div>
|
|
33
|
+
<label class="block text-sm font-medium mb-1" for={`ar-first-${assetRequest.assetRef}`}>First name</label>
|
|
34
|
+
<input id={`ar-first-${assetRequest.assetRef}`} name="firstName" type="text" required maxlength="100" autocomplete="given-name" class={field} />
|
|
35
|
+
</div>
|
|
36
|
+
<div>
|
|
37
|
+
<label class="block text-sm font-medium mb-1" for={`ar-last-${assetRequest.assetRef}`}>Last name</label>
|
|
38
|
+
<input id={`ar-last-${assetRequest.assetRef}`} name="lastName" type="text" required maxlength="100" autocomplete="family-name" class={field} />
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
<div>
|
|
42
|
+
<label class="block text-sm font-medium mb-1" for={`ar-email-${assetRequest.assetRef}`}>Work email</label>
|
|
43
|
+
<input id={`ar-email-${assetRequest.assetRef}`} name="email" type="email" required maxlength="255" autocomplete="email" class={field} />
|
|
44
|
+
</div>
|
|
45
|
+
<div>
|
|
46
|
+
<label class="block text-sm font-medium mb-1" for={`ar-company-${assetRequest.assetRef}`}>Company</label>
|
|
47
|
+
<input id={`ar-company-${assetRequest.assetRef}`} name="company" type="text" maxlength="255" autocomplete="organization" class={field} />
|
|
48
|
+
</div>
|
|
49
|
+
<div>
|
|
50
|
+
<label class="block text-sm font-medium mb-1" for={`ar-role-${assetRequest.assetRef}`}>Role</label>
|
|
51
|
+
<select id={`ar-role-${assetRequest.assetRef}`} name="persona" class={field}>
|
|
52
|
+
{PERSONAS.map((p) => <option value={p.value} selected={p.value === 'unclassified'}>{p.label}</option>)}
|
|
53
|
+
</select>
|
|
54
|
+
</div>
|
|
55
|
+
<label class="flex gap-2 items-start text-sm">
|
|
56
|
+
<input name="seriesOptIn" type="checkbox" class="mt-1" />
|
|
57
|
+
<span>Send me the rest of the series as it comes out.</span>
|
|
58
|
+
</label>
|
|
59
|
+
<label class="flex gap-2 items-start text-sm">
|
|
60
|
+
<input name="discuss" type="checkbox" class="mt-1" />
|
|
61
|
+
<span>I'd like to discuss this with LuhTech.</span>
|
|
62
|
+
</label>
|
|
63
|
+
{assetRequest.requestPrompt && (
|
|
64
|
+
<div>
|
|
65
|
+
<label class="block text-sm font-medium mb-1" for={`ar-answer-${assetRequest.assetRef}`}>{assetRequest.requestPrompt}</label>
|
|
66
|
+
<textarea id={`ar-answer-${assetRequest.assetRef}`} name="answer" rows="3" maxlength="4000" class={field}></textarea>
|
|
67
|
+
</div>
|
|
68
|
+
)}
|
|
69
|
+
<div class="hidden" aria-hidden="true">
|
|
70
|
+
<label for={`ar-${leadCapture.honeypotField}-${assetRequest.assetRef}`}>Website</label>
|
|
71
|
+
<input id={`ar-${leadCapture.honeypotField}-${assetRequest.assetRef}`} name={leadCapture.honeypotField} type="text" tabindex="-1" autocomplete="off" />
|
|
72
|
+
</div>
|
|
73
|
+
<button type="submit" class="px-5 py-2.5 rounded-md bg-accent-primary text-canvas font-medium transition-all duration-200 hover:opacity-90 disabled:opacity-50 focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent-secondary focus-visible:rounded">
|
|
74
|
+
Send me the paper
|
|
75
|
+
</button>
|
|
76
|
+
<p class="asset-request-status text-sm" role="status" aria-live="polite"></p>
|
|
77
|
+
</form>
|
|
78
|
+
|
|
79
|
+
<script>
|
|
80
|
+
import { assetRequestBody, contentRequestBody, requestEndpointFor } from '../lib/assetRequest.ts';
|
|
81
|
+
|
|
82
|
+
for (const form of document.querySelectorAll<HTMLFormElement>('form.asset-request-form')) {
|
|
83
|
+
const status = form.querySelector('.asset-request-status') as HTMLParagraphElement;
|
|
84
|
+
const loadedAt = Date.now();
|
|
85
|
+
const endpoint = form.dataset.endpoint!;
|
|
86
|
+
const honeypot = form.dataset.honeypot!;
|
|
87
|
+
const minSubmitMs = Number(form.dataset.minSubmitMs ?? '2000');
|
|
88
|
+
|
|
89
|
+
form.addEventListener('submit', async (e) => {
|
|
90
|
+
e.preventDefault();
|
|
91
|
+
const data = new FormData(form);
|
|
92
|
+
if ((data.get(honeypot) as string)?.length > 0) return;
|
|
93
|
+
if (Date.now() - loadedAt < minSubmitMs) return;
|
|
94
|
+
|
|
95
|
+
const button = form.querySelector('button[type="submit"]') as HTMLButtonElement;
|
|
96
|
+
button.disabled = true;
|
|
97
|
+
status.textContent = 'Sending...';
|
|
98
|
+
|
|
99
|
+
const input = {
|
|
100
|
+
firstName: String(data.get('firstName') ?? ''),
|
|
101
|
+
lastName: String(data.get('lastName') ?? ''),
|
|
102
|
+
email: String(data.get('email') ?? ''),
|
|
103
|
+
company: String(data.get('company') ?? ''),
|
|
104
|
+
persona: String(data.get('persona') ?? 'unclassified'),
|
|
105
|
+
seriesOptIn: data.get('seriesOptIn') === 'on',
|
|
106
|
+
discuss: data.get('discuss') === 'on',
|
|
107
|
+
answer: String(data.get('answer') ?? ''),
|
|
108
|
+
};
|
|
109
|
+
const ctx = {
|
|
110
|
+
assetRef: form.dataset.assetRef!,
|
|
111
|
+
search: window.location.search,
|
|
112
|
+
pathname: window.location.pathname,
|
|
113
|
+
ventureRef: form.dataset.venture || undefined,
|
|
114
|
+
};
|
|
115
|
+
const post = (url: string, body: unknown) =>
|
|
116
|
+
fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) });
|
|
117
|
+
|
|
118
|
+
try {
|
|
119
|
+
const res = await post(endpoint, assetRequestBody(input, ctx));
|
|
120
|
+
if (!res.ok) throw new Error(String(res.status));
|
|
121
|
+
const request = contentRequestBody(input, ctx);
|
|
122
|
+
if (request) await post(requestEndpointFor(endpoint), request).catch(() => undefined);
|
|
123
|
+
status.textContent = request
|
|
124
|
+
? "Check your inbox -- the link works for seven days. We'll be in touch about your question."
|
|
125
|
+
: 'Check your inbox -- the link works for seven days.';
|
|
126
|
+
form.reset();
|
|
127
|
+
} catch {
|
|
128
|
+
status.textContent = 'Something went wrong. Try again in a moment.';
|
|
129
|
+
button.disabled = false;
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
</script>
|
|
@@ -9,23 +9,35 @@
|
|
|
9
9
|
// heading and a dead-end button).
|
|
10
10
|
import Block from '../Block.astro';
|
|
11
11
|
import CtaLink from '../CtaLink.astro';
|
|
12
|
+
import AssetRequestForm from '../AssetRequestForm.astro';
|
|
12
13
|
import LeadCaptureForm from '../LeadCaptureForm.astro';
|
|
13
14
|
import SectionHeading from '../SectionHeading.astro';
|
|
14
15
|
import type { SectionIcons } from '../Section.astro';
|
|
15
16
|
|
|
16
17
|
export interface Props {
|
|
17
18
|
section: any;
|
|
18
|
-
leadCapture?: { destination: string; source: string; ventureField: string; honeypotField: string; minSubmitMs?: number };
|
|
19
|
+
leadCapture?: { destination: string; source: string; ventureField: string; honeypotField: string; minSubmitMs?: number; assetRequestEndpoint?: string; toolSubmitEndpoint?: string };
|
|
19
20
|
companyLabel?: string;
|
|
20
21
|
icons?: SectionIcons;
|
|
21
22
|
}
|
|
22
23
|
const { section, leadCapture, companyLabel, icons } = Astro.props;
|
|
23
24
|
const sectionIcon = icons?.section?.[section.sectionId];
|
|
25
|
+
// A gated asset cta with nowhere to post would render a form that silently
|
|
26
|
+
// fails -- refuse the build instead.
|
|
27
|
+
if (section.assetRequest && !leadCapture?.assetRequestEndpoint) {
|
|
28
|
+
throw new Error(`Cta.astro: section ${section.sectionId} carries assetRequest but site.leadCapture has no assetRequestEndpoint`);
|
|
29
|
+
}
|
|
24
30
|
---
|
|
25
31
|
<section id={section.sectionId} class="py-12 text-center border-t border-ink/10" data-reveal>
|
|
26
32
|
<SectionHeading eyebrow={section.eyebrow} heading={section.heading} subheading={section.subheading} icon={sectionIcon} center class="mb-3" />
|
|
27
33
|
{section.blocks?.map((b: any) => <Block block={b} class="mb-4 max-w-xl mx-auto text-left" />)}
|
|
28
|
-
{leadCapture ? (
|
|
34
|
+
{section.assetRequest && leadCapture?.assetRequestEndpoint ? (
|
|
35
|
+
// d-2026-10-01-st-asset-request-form: a gated asset cta (page.schema.json
|
|
36
|
+
// v2.5.0 assetRequest) renders the asset form against the capture service.
|
|
37
|
+
<div class="text-left max-w-md mx-auto">
|
|
38
|
+
<AssetRequestForm assetRequest={section.assetRequest} leadCapture={leadCapture as any} />
|
|
39
|
+
</div>
|
|
40
|
+
) : leadCapture ? (
|
|
29
41
|
<div class="text-left max-w-md mx-auto">
|
|
30
42
|
<LeadCaptureForm leadCapture={leadCapture} heading="" companyLabel={companyLabel} />
|
|
31
43
|
</div>
|
package/src/content/loadPage.ts
CHANGED
|
@@ -3,7 +3,7 @@ import Ajv from 'ajv';
|
|
|
3
3
|
import addFormats from 'ajv-formats';
|
|
4
4
|
import { fetchSchema, fetchSupportSchema } from './schemaFetch.js';
|
|
5
5
|
|
|
6
|
-
const PAGE_PIN = '2.
|
|
6
|
+
const PAGE_PIN = '2.5.0';
|
|
7
7
|
const CAPABILITY_CLAIM_PIN = '0.2.0';
|
|
8
8
|
|
|
9
9
|
let validatorPromise: ReturnType<typeof buildValidator> | null = null;
|
package/src/content/loadSite.ts
CHANGED
package/src/content/loadTool.ts
CHANGED
|
@@ -3,7 +3,8 @@ import Ajv from 'ajv';
|
|
|
3
3
|
import addFormats from 'ajv-formats';
|
|
4
4
|
import { fetchSchema, fetchSupportSchema } from './schemaFetch.js';
|
|
5
5
|
|
|
6
|
-
const TOOL_PIN = '1.
|
|
6
|
+
const TOOL_PIN = '1.2.0';
|
|
7
|
+
const CAPABILITY_CLAIM_PIN = '0.2.0';
|
|
7
8
|
|
|
8
9
|
let validatorPromise: ReturnType<typeof buildValidator> | null = null;
|
|
9
10
|
|
|
@@ -11,14 +12,28 @@ async function buildValidator() {
|
|
|
11
12
|
const ajv = new Ajv({ strict: false, allErrors: true });
|
|
12
13
|
addFormats(ajv);
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
// tool.schema.json 1.2.0 adopts the content spine (cell refs, themes,
|
|
16
|
+
// strategy) and forbids audit-paint field names, so its $ref chain now
|
|
17
|
+
// reaches cell, content-spine (which itself $refs capability-claim) and
|
|
18
|
+
// forbidden-audit-paint-names -- found building LuhTech-Business's /tools/
|
|
19
|
+
// route against the 1.2.0 pin, which failed "can't resolve reference".
|
|
20
|
+
const [toolSchema, capabilityClaimSchema, definitionsSchema, graphSchema, cellSchema, contentSpineSchema, forbiddenNamesSchema] =
|
|
21
|
+
await Promise.all([
|
|
22
|
+
fetchSchema('content/tool.schema.json', TOOL_PIN),
|
|
23
|
+
fetchSchema('content/capability-claim.schema.json', CAPABILITY_CLAIM_PIN),
|
|
24
|
+
fetchSupportSchema('_definitions/definitions.schema.json'),
|
|
25
|
+
fetchSupportSchema('_definitions/graph.schema.json'),
|
|
26
|
+
fetchSupportSchema('_definitions/cell.schema.json'),
|
|
27
|
+
fetchSupportSchema('_definitions/content-spine.schema.json'),
|
|
28
|
+
fetchSupportSchema('_definitions/forbidden-audit-paint-names.schema.json'),
|
|
29
|
+
]);
|
|
19
30
|
|
|
31
|
+
ajv.addSchema(capabilityClaimSchema as object);
|
|
20
32
|
ajv.addSchema(definitionsSchema as object);
|
|
21
33
|
ajv.addSchema(graphSchema as object);
|
|
34
|
+
ajv.addSchema(cellSchema as object);
|
|
35
|
+
ajv.addSchema(contentSpineSchema as object);
|
|
36
|
+
ajv.addSchema(forbiddenNamesSchema as object);
|
|
22
37
|
|
|
23
38
|
return ajv.compile(toolSchema as object);
|
|
24
39
|
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// d-2026-10-01-st-asset-request-form: the request a gated asset form sends
|
|
2
|
+
// to the capture service (Ectropy-Business POST /api/tools/submissions/assets
|
|
3
|
+
// and /requests, d-2026-10-01-eb-capture-service-assets-and-requests). Pure,
|
|
4
|
+
// so the form's script and the tests share one implementation.
|
|
5
|
+
|
|
6
|
+
/** Persona values the form offers (crm/persona-classification plus the form default). */
|
|
7
|
+
export const PERSONAS = [
|
|
8
|
+
{ value: 'unclassified', label: 'Prefer not to say' },
|
|
9
|
+
{ value: 'owner', label: 'Owner or developer' },
|
|
10
|
+
{ value: 'gc', label: 'General contractor' },
|
|
11
|
+
{ value: 'architect', label: 'Architect or engineer' },
|
|
12
|
+
{ value: 'sub', label: 'Specialty contractor' },
|
|
13
|
+
{ value: 'super', label: 'Superintendent' },
|
|
14
|
+
{ value: 'gov', label: 'Public agency' },
|
|
15
|
+
] as const;
|
|
16
|
+
|
|
17
|
+
const UTM_KEYS = ['source', 'medium', 'campaign', 'content', 'term'] as const;
|
|
18
|
+
const SOURCE_REF = /^(article:[a-z0-9]+(-[a-z0-9]+)*|post:[A-Za-z0-9:_-]+|page:[a-z0-9]+(-[a-z0-9]+)*)$/;
|
|
19
|
+
|
|
20
|
+
/** utm_source=... -> { source: ... }, the five standard keys only. */
|
|
21
|
+
export function utmFromSearch(search: string): Record<string, string> | undefined {
|
|
22
|
+
const params = new URLSearchParams(search);
|
|
23
|
+
const utm: Record<string, string> = {};
|
|
24
|
+
for (const k of UTM_KEYS) {
|
|
25
|
+
const v = params.get(`utm_${k}`);
|
|
26
|
+
if (v) utm[k] = v.slice(0, 200);
|
|
27
|
+
}
|
|
28
|
+
return Object.keys(utm).length ? utm : undefined;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Where the visitor came from: an explicit ?src=post:<id> or article:<slug>
|
|
33
|
+
* the post's own link carries, else this page (page:<last path segment>).
|
|
34
|
+
*/
|
|
35
|
+
export function sourceRefFor(search: string, pathname: string): string {
|
|
36
|
+
const src = new URLSearchParams(search).get('src');
|
|
37
|
+
if (src && SOURCE_REF.test(src)) return src;
|
|
38
|
+
const slug = pathname.split('/').filter(Boolean).pop() ?? 'home';
|
|
39
|
+
const pageRef = `page:${slug.toLowerCase().replace(/[^a-z0-9-]+/g, '-').replace(/^-+|-+$/g, '') || 'home'}`;
|
|
40
|
+
return SOURCE_REF.test(pageRef) ? pageRef : 'page:home';
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** The /requests endpoint beside the /assets endpoint the site config names. */
|
|
44
|
+
export function requestEndpointFor(assetRequestEndpoint: string): string {
|
|
45
|
+
return assetRequestEndpoint.replace(/\/assets\/?$/, '/requests');
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface AssetFormInput {
|
|
49
|
+
firstName: string;
|
|
50
|
+
lastName: string;
|
|
51
|
+
email: string;
|
|
52
|
+
company?: string;
|
|
53
|
+
persona: string;
|
|
54
|
+
seriesOptIn: boolean;
|
|
55
|
+
discuss: boolean;
|
|
56
|
+
answer?: string;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface AssetContext {
|
|
60
|
+
assetRef: string;
|
|
61
|
+
search: string;
|
|
62
|
+
pathname: string;
|
|
63
|
+
ventureRef?: string;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** The asset request body. */
|
|
67
|
+
export function assetRequestBody(input: AssetFormInput, ctx: AssetContext) {
|
|
68
|
+
const utm = utmFromSearch(ctx.search);
|
|
69
|
+
return {
|
|
70
|
+
assetRef: ctx.assetRef,
|
|
71
|
+
sourceRef: sourceRefFor(ctx.search, ctx.pathname),
|
|
72
|
+
route: ctx.pathname,
|
|
73
|
+
...(ctx.ventureRef ? { ventureRef: ctx.ventureRef } : {}),
|
|
74
|
+
persona: PERSONAS.some((p) => p.value === input.persona) ? input.persona : 'unclassified',
|
|
75
|
+
seriesOptIn: input.seriesOptIn === true,
|
|
76
|
+
...(utm ? { utm } : {}),
|
|
77
|
+
contact: {
|
|
78
|
+
firstName: input.firstName.trim(),
|
|
79
|
+
lastName: input.lastName.trim(),
|
|
80
|
+
email: input.email.trim(),
|
|
81
|
+
...(input.company?.trim() ? { company: input.company.trim() } : {}),
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** The request body when the visitor ticks "discuss this with us" -- null when they do not. */
|
|
87
|
+
export function contentRequestBody(input: AssetFormInput, ctx: AssetContext) {
|
|
88
|
+
if (!input.discuss) return null;
|
|
89
|
+
const asset = assetRequestBody(input, ctx);
|
|
90
|
+
const { seriesOptIn: _optIn, ...rest } = asset;
|
|
91
|
+
return {
|
|
92
|
+
...rest,
|
|
93
|
+
requestKind: 'whitepaper' as const,
|
|
94
|
+
...(input.answer?.trim() ? { message: input.answer.trim().slice(0, 4000) } : {}),
|
|
95
|
+
};
|
|
96
|
+
}
|