@wealthreach/site-kit 0.0.0-stage → 1.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/dist/a11y/client.d.ts +23 -0
- package/dist/a11y/client.js +72 -0
- package/dist/a11y/index.d.ts +43 -0
- package/dist/a11y/index.js +194 -0
- package/dist/a11y/shell-client.d.ts +19 -0
- package/dist/a11y/shell-client.js +45 -0
- package/dist/analytics/index.d.ts +47 -0
- package/dist/analytics/index.js +122 -0
- package/dist/attribution-DQaAWtA5.d.ts +41 -0
- package/dist/blog/index.d.ts +92 -0
- package/dist/blog/index.js +239 -0
- package/dist/chunk-4YRCSRZZ.js +32 -0
- package/dist/chunk-7GDXQ6UB.js +772 -0
- package/dist/chunk-QQP7VG2C.js +231 -0
- package/dist/chunk-Y77ARZE4.js +214 -0
- package/dist/config/index.d.ts +20 -0
- package/dist/config/index.js +445 -0
- package/dist/consent/index.d.ts +103 -0
- package/dist/consent/index.js +61 -0
- package/dist/disclosures/index.d.ts +57 -0
- package/dist/disclosures/index.js +361 -0
- package/dist/forms/index.d.ts +128 -0
- package/dist/forms/index.js +449 -0
- package/dist/mdx/index.d.ts +15 -0
- package/dist/mdx/index.js +45 -0
- package/dist/next/config.cjs +140 -0
- package/dist/next/config.d.cts +36 -0
- package/dist/next/config.d.ts +36 -0
- package/dist/next/config.js +111 -0
- package/dist/next/draft-route.d.ts +10 -0
- package/dist/next/draft-route.js +49 -0
- package/dist/next/leads-route.d.ts +129 -0
- package/dist/next/leads-route.js +760 -0
- package/dist/next/privacy-mode.d.ts +14 -0
- package/dist/next/privacy-mode.js +86 -0
- package/dist/next/proxy.d.ts +19 -0
- package/dist/next/proxy.js +93 -0
- package/dist/regulatory-schema-uDKNJ7q8.d.ts +1301 -0
- package/dist/schema-C1ixytx2.d.ts +2911 -0
- package/dist/schema-DD0nDOD0.d.ts +1744 -0
- package/package.json +85 -3
- package/README.md +0 -3
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { SiteConfig } from '../config/index.js';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import '../regulatory-schema-uDKNJ7q8.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Exact Contract 3.5 waiting-post hold spelling:
|
|
8
|
+
* A held post carries `status: "waiting"` — omitted means live.
|
|
9
|
+
*/
|
|
10
|
+
declare const postFrontmatterSchema: z.ZodObject<{
|
|
11
|
+
title: z.ZodString;
|
|
12
|
+
description: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
13
|
+
excerpt: z.ZodOptional<z.ZodString>;
|
|
14
|
+
date: z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodDate]>, z.ZodTransform<string, string | Date>>;
|
|
15
|
+
updatedAt: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodDate]>, z.ZodTransform<string, string | Date>>>;
|
|
16
|
+
author: z.ZodOptional<z.ZodString>;
|
|
17
|
+
category: z.ZodOptional<z.ZodString>;
|
|
18
|
+
tags: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
19
|
+
image: z.ZodOptional<z.ZodString>;
|
|
20
|
+
videoUrl: z.ZodOptional<z.ZodString>;
|
|
21
|
+
transcript: z.ZodOptional<z.ZodString>;
|
|
22
|
+
status: z.ZodOptional<z.ZodLiteral<"waiting">>;
|
|
23
|
+
}, z.core.$loose>;
|
|
24
|
+
type PostFrontmatter = z.infer<typeof postFrontmatterSchema>;
|
|
25
|
+
interface BlogPost {
|
|
26
|
+
slug: string;
|
|
27
|
+
filePath: string;
|
|
28
|
+
frontmatter: PostFrontmatter;
|
|
29
|
+
content: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Exact Contract 3.5 rule: a post is live iff `status` is not `"waiting"`. */
|
|
33
|
+
declare function isPostLive(postOrFrontmatter: Pick<BlogPost, "frontmatter"> | PostFrontmatter): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Exact log format parsed by WealthReach / Eve `post_not_served` diagnostics
|
|
36
|
+
* (`hiding "<slug>": <reason>`).
|
|
37
|
+
*/
|
|
38
|
+
declare function logHiddenPost(slug: string, reason: string): void;
|
|
39
|
+
/**
|
|
40
|
+
* Synchronous visibility guard for post routes (call BEFORE rendering — never
|
|
41
|
+
* inside a streaming `<Suspense>` fallback, so hidden posts always 404).
|
|
42
|
+
*/
|
|
43
|
+
declare function assertPostReadable(post: BlogPost | null | undefined, options: {
|
|
44
|
+
isDraftMode?: boolean;
|
|
45
|
+
onNotFound: () => never;
|
|
46
|
+
}): BlogPost;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Pluggable post source seam so Phase 4 can swap git-committed MDX for a
|
|
50
|
+
* WealthReach Content API without touching any client blog page UI.
|
|
51
|
+
*/
|
|
52
|
+
interface PostSource {
|
|
53
|
+
loadAll(options?: {
|
|
54
|
+
includeWaiting?: boolean;
|
|
55
|
+
}): BlogPost[];
|
|
56
|
+
getBySlug(slug: string, options?: {
|
|
57
|
+
includeWaiting?: boolean;
|
|
58
|
+
}): BlogPost | null;
|
|
59
|
+
}
|
|
60
|
+
declare function createFileSystemPostSource(options?: {
|
|
61
|
+
postsDir?: string;
|
|
62
|
+
cwd?: string;
|
|
63
|
+
}): PostSource;
|
|
64
|
+
declare function loadPosts(options?: {
|
|
65
|
+
postsDir?: string;
|
|
66
|
+
cwd?: string;
|
|
67
|
+
includeWaiting?: boolean;
|
|
68
|
+
}): BlogPost[];
|
|
69
|
+
declare function getPostBySlug(slug: string, options?: {
|
|
70
|
+
postsDir?: string;
|
|
71
|
+
cwd?: string;
|
|
72
|
+
includeWaiting?: boolean;
|
|
73
|
+
}): BlogPost | null;
|
|
74
|
+
|
|
75
|
+
declare function buildPostJsonLd(post: BlogPost, config: SiteConfig): Record<string, unknown>;
|
|
76
|
+
|
|
77
|
+
declare const DRAFT_AUDIENCE_COOKIE = "__wr_draft_audience";
|
|
78
|
+
declare function isOwnerAudienceCookie(cookieValue: string | undefined): boolean;
|
|
79
|
+
declare function isDraftViewEnabled(isDraftMode: boolean): boolean;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Owner-only draft preview banner for `status: "waiting"` posts.
|
|
83
|
+
* Stamps exact `data-wr-hidden-post="not-live"` contract attribute expected by
|
|
84
|
+
* Eve's post verifier and WealthReach's draft-view flow.
|
|
85
|
+
*/
|
|
86
|
+
declare function DraftOwnerBanner({ slug, className, }: {
|
|
87
|
+
slug?: string;
|
|
88
|
+
className?: string;
|
|
89
|
+
}): React.JSX.Element;
|
|
90
|
+
|
|
91
|
+
export { DRAFT_AUDIENCE_COOKIE, DraftOwnerBanner, assertPostReadable, buildPostJsonLd, createFileSystemPostSource, getPostBySlug, isDraftViewEnabled, isOwnerAudienceCookie, isPostLive, loadPosts, logHiddenPost, postFrontmatterSchema };
|
|
92
|
+
export type { BlogPost, PostFrontmatter, PostSource };
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
// src/blog/frontmatter.ts
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
var postFrontmatterSchema = z.object({
|
|
4
|
+
title: z.string().trim().min(1),
|
|
5
|
+
description: z.string().trim().optional().default(""),
|
|
6
|
+
excerpt: z.string().trim().optional(),
|
|
7
|
+
date: z.union([z.string().trim().min(1), z.date()]).transform((v) => v instanceof Date ? v.toISOString().slice(0, 10) : v),
|
|
8
|
+
updatedAt: z.union([z.string().trim().min(1), z.date()]).transform((v) => v instanceof Date ? v.toISOString().slice(0, 10) : v).optional(),
|
|
9
|
+
author: z.string().trim().optional(),
|
|
10
|
+
category: z.string().trim().optional(),
|
|
11
|
+
tags: z.array(z.string().trim().min(1)).optional().default([]),
|
|
12
|
+
image: z.string().trim().optional(),
|
|
13
|
+
videoUrl: z.string().trim().optional(),
|
|
14
|
+
transcript: z.string().optional(),
|
|
15
|
+
status: z.literal("waiting").optional()
|
|
16
|
+
}).passthrough();
|
|
17
|
+
|
|
18
|
+
// src/blog/visibility.ts
|
|
19
|
+
function isPostLive(postOrFrontmatter) {
|
|
20
|
+
const fm = "frontmatter" in postOrFrontmatter && postOrFrontmatter.frontmatter !== null && typeof postOrFrontmatter.frontmatter === "object" ? postOrFrontmatter.frontmatter : postOrFrontmatter;
|
|
21
|
+
return fm.status !== "waiting";
|
|
22
|
+
}
|
|
23
|
+
function logHiddenPost(slug, reason) {
|
|
24
|
+
console.warn(`hiding "${slug}": ${reason}`);
|
|
25
|
+
}
|
|
26
|
+
function assertPostReadable(post, options) {
|
|
27
|
+
if (!post) {
|
|
28
|
+
options.onNotFound();
|
|
29
|
+
}
|
|
30
|
+
if (!isPostLive(post) && !options.isDraftMode) {
|
|
31
|
+
logHiddenPost(post.slug, 'status is "waiting" and draft mode is not active');
|
|
32
|
+
options.onNotFound();
|
|
33
|
+
}
|
|
34
|
+
return post;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// src/blog/source.ts
|
|
38
|
+
import fs from "fs";
|
|
39
|
+
import path from "path";
|
|
40
|
+
import matter from "gray-matter";
|
|
41
|
+
var POST_EXT_RE = /\.(?:mdx|md)$/i;
|
|
42
|
+
function createFileSystemPostSource(options) {
|
|
43
|
+
const baseDir = path.resolve(
|
|
44
|
+
options?.cwd ?? process.cwd(),
|
|
45
|
+
options?.postsDir ?? "data/blog"
|
|
46
|
+
);
|
|
47
|
+
function parseFile(filePath, slug) {
|
|
48
|
+
try {
|
|
49
|
+
const raw = fs.readFileSync(
|
|
50
|
+
/*turbopackIgnore: true*/
|
|
51
|
+
filePath,
|
|
52
|
+
"utf8"
|
|
53
|
+
);
|
|
54
|
+
const { data, content } = matter(raw);
|
|
55
|
+
const parsed = postFrontmatterSchema.safeParse(data);
|
|
56
|
+
if (!parsed.success) {
|
|
57
|
+
logHiddenPost(
|
|
58
|
+
slug,
|
|
59
|
+
`invalid frontmatter (${parsed.error.issues.map((i) => i.path.join(".") || i.message).join(", ")})`
|
|
60
|
+
);
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
slug,
|
|
65
|
+
filePath,
|
|
66
|
+
frontmatter: parsed.data,
|
|
67
|
+
content
|
|
68
|
+
};
|
|
69
|
+
} catch (error) {
|
|
70
|
+
logHiddenPost(
|
|
71
|
+
slug,
|
|
72
|
+
error instanceof Error ? error.message : "unreadable post file"
|
|
73
|
+
);
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
loadAll(loadOptions) {
|
|
79
|
+
if (!fs.existsSync(
|
|
80
|
+
/*turbopackIgnore: true*/
|
|
81
|
+
baseDir
|
|
82
|
+
)) return [];
|
|
83
|
+
const includeWaiting = loadOptions?.includeWaiting ?? false;
|
|
84
|
+
const entries = fs.readdirSync(
|
|
85
|
+
/*turbopackIgnore: true*/
|
|
86
|
+
baseDir,
|
|
87
|
+
{
|
|
88
|
+
withFileTypes: true
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
const posts = [];
|
|
92
|
+
for (const entry of entries) {
|
|
93
|
+
if (!entry.isFile() || !POST_EXT_RE.test(entry.name)) continue;
|
|
94
|
+
const slug = entry.name.replace(POST_EXT_RE, "");
|
|
95
|
+
const post = parseFile(
|
|
96
|
+
path.join(
|
|
97
|
+
/*turbopackIgnore: true*/
|
|
98
|
+
baseDir,
|
|
99
|
+
entry.name
|
|
100
|
+
),
|
|
101
|
+
slug
|
|
102
|
+
);
|
|
103
|
+
if (!post) continue;
|
|
104
|
+
if (!includeWaiting && !isPostLive(post)) continue;
|
|
105
|
+
posts.push(post);
|
|
106
|
+
}
|
|
107
|
+
posts.sort(
|
|
108
|
+
(a, b) => b.frontmatter.date.localeCompare(a.frontmatter.date)
|
|
109
|
+
);
|
|
110
|
+
return posts;
|
|
111
|
+
},
|
|
112
|
+
getBySlug(slug, getOptions) {
|
|
113
|
+
const includeWaiting = getOptions?.includeWaiting ?? false;
|
|
114
|
+
const cleanSlug = slug.replace(/[^a-zA-Z0-9-_]/g, "");
|
|
115
|
+
if (!cleanSlug || cleanSlug !== slug) return null;
|
|
116
|
+
for (const ext of [".mdx", ".md"]) {
|
|
117
|
+
const candidate = path.join(
|
|
118
|
+
/*turbopackIgnore: true*/
|
|
119
|
+
baseDir,
|
|
120
|
+
`${cleanSlug}${ext}`
|
|
121
|
+
);
|
|
122
|
+
if (fs.existsSync(
|
|
123
|
+
/*turbopackIgnore: true*/
|
|
124
|
+
candidate
|
|
125
|
+
)) {
|
|
126
|
+
const post = parseFile(candidate, cleanSlug);
|
|
127
|
+
if (!post) return null;
|
|
128
|
+
if (!includeWaiting && !isPostLive(post)) return null;
|
|
129
|
+
return post;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
function loadPosts(options) {
|
|
137
|
+
return createFileSystemPostSource(options).loadAll({
|
|
138
|
+
includeWaiting: options?.includeWaiting
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
function getPostBySlug(slug, options) {
|
|
142
|
+
return createFileSystemPostSource(options).getBySlug(slug, {
|
|
143
|
+
includeWaiting: options?.includeWaiting
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// src/blog/json-ld.ts
|
|
148
|
+
function buildPostJsonLd(post, config) {
|
|
149
|
+
const siteUrl = config.seo?.siteUrl?.replace(/\/$/, "") || "";
|
|
150
|
+
const routeSegment = config.blog?.routeSegment || "blog";
|
|
151
|
+
const url = siteUrl ? `${siteUrl}/${routeSegment}/${post.slug}` : void 0;
|
|
152
|
+
const article = {
|
|
153
|
+
"@context": "https://schema.org",
|
|
154
|
+
"@type": "Article",
|
|
155
|
+
headline: post.frontmatter.title,
|
|
156
|
+
description: post.frontmatter.description || post.frontmatter.excerpt || void 0,
|
|
157
|
+
datePublished: post.frontmatter.date,
|
|
158
|
+
...post.frontmatter.updatedAt ? { dateModified: post.frontmatter.updatedAt } : {},
|
|
159
|
+
...url ? { mainEntityOfPage: url, url } : {},
|
|
160
|
+
...post.frontmatter.image ? { image: post.frontmatter.image } : {},
|
|
161
|
+
author: {
|
|
162
|
+
"@type": post.frontmatter.author ? "Person" : "Organization",
|
|
163
|
+
name: post.frontmatter.author || config.brand.legalName
|
|
164
|
+
},
|
|
165
|
+
publisher: {
|
|
166
|
+
"@type": "Organization",
|
|
167
|
+
name: config.brand.legalName,
|
|
168
|
+
...config.brand.logoUrl ? { logo: { "@type": "ImageObject", url: config.brand.logoUrl } } : {}
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
if (post.frontmatter.videoUrl) {
|
|
172
|
+
article.video = {
|
|
173
|
+
"@type": "VideoObject",
|
|
174
|
+
name: post.frontmatter.title,
|
|
175
|
+
description: post.frontmatter.description || post.frontmatter.title,
|
|
176
|
+
contentUrl: post.frontmatter.videoUrl,
|
|
177
|
+
uploadDate: post.frontmatter.date,
|
|
178
|
+
...post.frontmatter.image ? { thumbnailUrl: post.frontmatter.image } : {},
|
|
179
|
+
...post.frontmatter.transcript ? { transcript: post.frontmatter.transcript } : {}
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
return article;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// src/blog/draft-view.ts
|
|
186
|
+
var DRAFT_AUDIENCE_COOKIE = "__wr_draft_audience";
|
|
187
|
+
function isOwnerAudienceCookie(cookieValue) {
|
|
188
|
+
return cookieValue === "owner";
|
|
189
|
+
}
|
|
190
|
+
function isDraftViewEnabled(isDraftMode) {
|
|
191
|
+
return process.env.NODE_ENV === "development" || isDraftMode;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// src/blog/draft-banner.tsx
|
|
195
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
196
|
+
function DraftOwnerBanner({
|
|
197
|
+
slug,
|
|
198
|
+
className
|
|
199
|
+
}) {
|
|
200
|
+
return /* @__PURE__ */ jsxs(
|
|
201
|
+
"aside",
|
|
202
|
+
{
|
|
203
|
+
role: "status",
|
|
204
|
+
"data-wr-hidden-post": "not-live",
|
|
205
|
+
className,
|
|
206
|
+
style: className ? void 0 : {
|
|
207
|
+
padding: "0.75rem 1rem",
|
|
208
|
+
marginBottom: "1.5rem",
|
|
209
|
+
borderRadius: "var(--wr-radius, 0.375rem)",
|
|
210
|
+
border: "1px solid #d97706",
|
|
211
|
+
backgroundColor: "#fffbeb",
|
|
212
|
+
color: "#92400e",
|
|
213
|
+
fontSize: "0.875rem",
|
|
214
|
+
fontWeight: 500
|
|
215
|
+
},
|
|
216
|
+
children: [
|
|
217
|
+
"Draft preview",
|
|
218
|
+
slug ? ` (${slug})` : "",
|
|
219
|
+
": this post is held (",
|
|
220
|
+
/* @__PURE__ */ jsx("code", { children: 'status: "waiting"' }),
|
|
221
|
+
") and is not visible to public visitors until published in WealthReach."
|
|
222
|
+
]
|
|
223
|
+
}
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
export {
|
|
227
|
+
DRAFT_AUDIENCE_COOKIE,
|
|
228
|
+
DraftOwnerBanner,
|
|
229
|
+
assertPostReadable,
|
|
230
|
+
buildPostJsonLd,
|
|
231
|
+
createFileSystemPostSource,
|
|
232
|
+
getPostBySlug,
|
|
233
|
+
isDraftViewEnabled,
|
|
234
|
+
isOwnerAudienceCookie,
|
|
235
|
+
isPostLive,
|
|
236
|
+
loadPosts,
|
|
237
|
+
logHiddenPost,
|
|
238
|
+
postFrontmatterSchema
|
|
239
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
captureAttributionOnLanding,
|
|
4
|
+
trackPageView
|
|
5
|
+
} from "./chunk-QQP7VG2C.js";
|
|
6
|
+
import {
|
|
7
|
+
useConsent
|
|
8
|
+
} from "./chunk-7GDXQ6UB.js";
|
|
9
|
+
|
|
10
|
+
// src/analytics/page-tracker.tsx
|
|
11
|
+
import { useEffect, useRef } from "react";
|
|
12
|
+
import { usePathname } from "next/navigation";
|
|
13
|
+
function PageTracker() {
|
|
14
|
+
const pathname = usePathname();
|
|
15
|
+
const { config, allowed, ready } = useConsent();
|
|
16
|
+
const lastTrackedPath = useRef(null);
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
captureAttributionOnLanding();
|
|
19
|
+
}, [pathname]);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (!ready || !allowed || !pathname) return;
|
|
22
|
+
if (config.visitors?.enabled) return;
|
|
23
|
+
if (lastTrackedPath.current === pathname) return;
|
|
24
|
+
lastTrackedPath.current = pathname;
|
|
25
|
+
trackPageView(pathname, config);
|
|
26
|
+
}, [ready, allowed, pathname, config]);
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export {
|
|
31
|
+
PageTracker
|
|
32
|
+
};
|