create-nersh 0.1.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.
Files changed (61) hide show
  1. package/dist/index.mjs +86 -0
  2. package/package.json +22 -0
  3. package/templates/next/app/globals.css +1 -0
  4. package/templates/next/app/layout.tsx +15 -0
  5. package/templates/next/app/page.tsx +7 -0
  6. package/templates/next/next.config.ts +5 -0
  7. package/templates/next/package.json.tmpl +25 -0
  8. package/templates/next/site.json +119 -0
  9. package/templates/next/src/components/site/SafeEmbed.tsx +72 -0
  10. package/templates/next/src/components/site/SiteButton.tsx +65 -0
  11. package/templates/next/src/components/site/SiteCard.tsx +46 -0
  12. package/templates/next/src/components/site/SiteCodeBlock.tsx +56 -0
  13. package/templates/next/src/components/site/SiteHeading.tsx +50 -0
  14. package/templates/next/src/components/site/SiteMobileSlider.tsx +71 -0
  15. package/templates/next/src/components/site/SiteSectionShell.tsx +91 -0
  16. package/templates/next/src/components/site/SiteStructuralContext.tsx +52 -0
  17. package/templates/next/src/lib/brandContext.ts +65 -0
  18. package/templates/next/src/lib/codeBlock.ts +76 -0
  19. package/templates/next/src/lib/componentLibrary/providers/shadcn/components.ts +146 -0
  20. package/templates/next/src/lib/componentLibrary/resolveComponent.ts +35 -0
  21. package/templates/next/src/lib/componentLibrary/schema.ts +219 -0
  22. package/templates/next/src/lib/embeds/index.ts +232 -0
  23. package/templates/next/src/lib/humanize.ts +58 -0
  24. package/templates/next/src/lib/sectionItems.ts +48 -0
  25. package/templates/next/src/lib/sectionSurface.ts +70 -0
  26. package/templates/next/src/lib/utils.ts +6 -0
  27. package/templates/next/src/registry.ts +16 -0
  28. package/templates/next/src/sections/about/Component.tsx +51 -0
  29. package/templates/next/src/sections/about/index.ts +7 -0
  30. package/templates/next/src/sections/about/meta.ts +8 -0
  31. package/templates/next/src/sections/about/schema.ts +38 -0
  32. package/templates/next/src/sections/about/writeCopy.ts +10 -0
  33. package/templates/next/src/sections/copyHelpers.ts +59 -0
  34. package/templates/next/src/sections/features/Component.tsx +122 -0
  35. package/templates/next/src/sections/features/index.ts +7 -0
  36. package/templates/next/src/sections/features/meta.ts +14 -0
  37. package/templates/next/src/sections/features/schema.ts +23 -0
  38. package/templates/next/src/sections/features/writeCopy.ts +18 -0
  39. package/templates/next/src/sections/footer/Component.tsx +103 -0
  40. package/templates/next/src/sections/footer/index.ts +7 -0
  41. package/templates/next/src/sections/footer/meta.ts +8 -0
  42. package/templates/next/src/sections/footer/schema.ts +39 -0
  43. package/templates/next/src/sections/footer/writeCopy.ts +31 -0
  44. package/templates/next/src/sections/marketing-hero/Component.tsx +187 -0
  45. package/templates/next/src/sections/marketing-hero/index.ts +7 -0
  46. package/templates/next/src/sections/marketing-hero/meta.ts +13 -0
  47. package/templates/next/src/sections/marketing-hero/schema.ts +106 -0
  48. package/templates/next/src/sections/marketing-hero/writeCopy.ts +18 -0
  49. package/templates/next/src/sections/navbar/Component.tsx +53 -0
  50. package/templates/next/src/sections/navbar/index.ts +7 -0
  51. package/templates/next/src/sections/navbar/meta.ts +8 -0
  52. package/templates/next/src/sections/navbar/schema.ts +50 -0
  53. package/templates/next/src/sections/navbar/writeCopy.ts +16 -0
  54. package/templates/next/src/sections/pricing/Component.tsx +125 -0
  55. package/templates/next/src/sections/pricing/index.ts +7 -0
  56. package/templates/next/src/sections/pricing/meta.ts +12 -0
  57. package/templates/next/src/sections/pricing/schema.ts +25 -0
  58. package/templates/next/src/sections/pricing/writeCopy.ts +22 -0
  59. package/templates/next/src/sections/siteLayoutClasses.ts +9 -0
  60. package/templates/next/src/sections/types.ts +119 -0
  61. package/templates/next/tsconfig.json +23 -0
@@ -0,0 +1,232 @@
1
+ export type EmbedKind = "videoEmbed" | "iframeEmbed";
2
+
3
+ export type ParsedEmbed = {
4
+ embedSrc: string;
5
+ aspectRatio: string;
6
+ provider: string;
7
+ };
8
+
9
+ type ParseResult =
10
+ | { ok: true; embed: ParsedEmbed }
11
+ | { ok: false; error: string };
12
+
13
+ function fail(error: string): ParseResult {
14
+ return { ok: false, error };
15
+ }
16
+
17
+ function ok(embed: ParsedEmbed): ParseResult {
18
+ return { ok: true, embed };
19
+ }
20
+
21
+ function parseYoutube(raw: string): ParseResult | null {
22
+ try {
23
+ const u = new URL(raw.trim());
24
+ const host = u.hostname.replace(/^www\./, "");
25
+ let videoId: string | null = null;
26
+ if (host === "youtu.be") {
27
+ videoId = u.pathname.slice(1).split("/")[0] || null;
28
+ } else if (host === "youtube.com" || host === "m.youtube.com") {
29
+ if (u.pathname === "/watch") {
30
+ videoId = u.searchParams.get("v");
31
+ } else if (u.pathname.startsWith("/embed/")) {
32
+ videoId = u.pathname.split("/")[2] ?? null;
33
+ } else if (u.pathname.startsWith("/shorts/")) {
34
+ videoId = u.pathname.split("/")[2] ?? null;
35
+ }
36
+ }
37
+ if (!videoId) return null;
38
+ return ok({
39
+ embedSrc: `https://www.youtube.com/embed/${videoId}`,
40
+ aspectRatio: "16 / 9",
41
+ provider: "youtube",
42
+ });
43
+ } catch {
44
+ return null;
45
+ }
46
+ }
47
+
48
+ function parseVimeo(raw: string): ParseResult | null {
49
+ try {
50
+ const u = new URL(raw.trim());
51
+ const host = u.hostname.replace(/^www\./, "");
52
+ if (host !== "vimeo.com" && host !== "player.vimeo.com") return null;
53
+ const parts = u.pathname.split("/").filter(Boolean);
54
+ const id = parts[parts.length - 1];
55
+ if (!id || !/^\d+$/.test(id)) return null;
56
+ return ok({
57
+ embedSrc: `https://player.vimeo.com/video/${id}`,
58
+ aspectRatio: "16 / 9",
59
+ provider: "vimeo",
60
+ });
61
+ } catch {
62
+ return null;
63
+ }
64
+ }
65
+
66
+ function parseLoom(raw: string): ParseResult | null {
67
+ try {
68
+ const u = new URL(raw.trim());
69
+ if (!u.hostname.replace(/^www\./, "").includes("loom.com")) return null;
70
+ const match = u.pathname.match(/\/share\/([a-zA-Z0-9]+)/);
71
+ if (!match) return null;
72
+ return ok({
73
+ embedSrc: `https://www.loom.com/embed/${match[1]}`,
74
+ aspectRatio: "16 / 9",
75
+ provider: "loom",
76
+ });
77
+ } catch {
78
+ return null;
79
+ }
80
+ }
81
+
82
+ function parseWistia(raw: string): ParseResult | null {
83
+ try {
84
+ const u = new URL(raw.trim());
85
+ const host = u.hostname.replace(/^www\./, "");
86
+ if (host.includes("fast.wistia.net") && u.pathname.startsWith("/embed/iframe/")) {
87
+ return ok({
88
+ embedSrc: u.toString(),
89
+ aspectRatio: "16 / 9",
90
+ provider: "wistia",
91
+ });
92
+ }
93
+ const mediasMatch = u.pathname.match(/\/medias\/([a-zA-Z0-9]+)/);
94
+ if ((host.includes("wistia.com") || host.includes("wi.st")) && mediasMatch) {
95
+ return ok({
96
+ embedSrc: `https://fast.wistia.net/embed/iframe/${mediasMatch[1]}`,
97
+ aspectRatio: "16 / 9",
98
+ provider: "wistia",
99
+ });
100
+ }
101
+ return null;
102
+ } catch {
103
+ return null;
104
+ }
105
+ }
106
+
107
+ function parseGoogleMaps(raw: string): ParseResult | null {
108
+ try {
109
+ const u = new URL(raw.trim());
110
+ const host = u.hostname.replace(/^www\./, "");
111
+ if (host === "google.com" && u.pathname.startsWith("/maps/embed")) {
112
+ return ok({
113
+ embedSrc: u.toString(),
114
+ aspectRatio: "4 / 3",
115
+ provider: "google-maps",
116
+ });
117
+ }
118
+ if (host === "maps.google.com" && u.pathname.includes("/maps")) {
119
+ return ok({
120
+ embedSrc: u.toString(),
121
+ aspectRatio: "4 / 3",
122
+ provider: "google-maps",
123
+ });
124
+ }
125
+ return null;
126
+ } catch {
127
+ return null;
128
+ }
129
+ }
130
+
131
+ function parseSpotify(raw: string): ParseResult | null {
132
+ try {
133
+ const u = new URL(raw.trim());
134
+ if (!u.hostname.replace(/^www\./, "").includes("open.spotify.com")) return null;
135
+ if (!u.pathname.startsWith("/embed/")) return null;
136
+ return ok({
137
+ embedSrc: u.toString(),
138
+ aspectRatio: "auto",
139
+ provider: "spotify",
140
+ });
141
+ } catch {
142
+ return null;
143
+ }
144
+ }
145
+
146
+ function parseCalCom(raw: string): ParseResult | null {
147
+ try {
148
+ const u = new URL(raw.trim());
149
+ const host = u.hostname.replace(/^www\./, "");
150
+ if (host !== "cal.com" && !host.endsWith(".cal.com")) return null;
151
+ const embedSrc = u.pathname.includes("/embed")
152
+ ? u.toString()
153
+ : `${u.origin}${u.pathname.replace(/\/$/, "")}/embed`;
154
+ return ok({
155
+ embedSrc,
156
+ aspectRatio: "auto",
157
+ provider: "cal.com",
158
+ });
159
+ } catch {
160
+ return null;
161
+ }
162
+ }
163
+
164
+ function parseCalendly(raw: string): ParseResult | null {
165
+ try {
166
+ const u = new URL(raw.trim());
167
+ if (!u.hostname.replace(/^www\./, "").includes("calendly.com")) return null;
168
+ const embedSrc = u.pathname.includes("/embed")
169
+ ? u.toString()
170
+ : u.toString().replace("calendly.com/", "calendly.com/embed/");
171
+ return ok({
172
+ embedSrc,
173
+ aspectRatio: "auto",
174
+ provider: "calendly",
175
+ });
176
+ } catch {
177
+ return null;
178
+ }
179
+ }
180
+
181
+ export function parseEmbedUrl(url: string, kind: EmbedKind): ParseResult {
182
+ const trimmed = url.trim();
183
+ if (!trimmed) return fail("URL required");
184
+ if (/^javascript:/i.test(trimmed)) return fail("Invalid URL");
185
+
186
+ if (kind === "videoEmbed") {
187
+ return (
188
+ parseYoutube(trimmed)
189
+ ?? parseVimeo(trimmed)
190
+ ?? parseLoom(trimmed)
191
+ ?? parseWistia(trimmed)
192
+ ?? fail("Unsupported video URL (YouTube, Vimeo, Loom, or Wistia)")
193
+ );
194
+ }
195
+
196
+ return (
197
+ parseGoogleMaps(trimmed)
198
+ ?? parseSpotify(trimmed)
199
+ ?? parseCalCom(trimmed)
200
+ ?? parseCalendly(trimmed)
201
+ ?? fail("Unsupported embed URL (Google Maps, Spotify, Cal.com, or Calendly)")
202
+ );
203
+ }
204
+
205
+ export function validateEmbedUrl(url: string, kind: EmbedKind): ParseResult {
206
+ return parseEmbedUrl(url, kind);
207
+ }
208
+
209
+ /** `username/event` path for @calcom/embed-react from a parsed cal.com embed. */
210
+ export function calLinkFromEmbed(embed: ParsedEmbed): string | null {
211
+ if (embed.provider !== "cal.com") return null;
212
+ try {
213
+ const path = new URL(embed.embedSrc).pathname.replace(/\/embed\/?$/, "");
214
+ const calLink = path.replace(/^\//, "");
215
+ return calLink || null;
216
+ } catch {
217
+ return null;
218
+ }
219
+ }
220
+
221
+ /** Cal.com — hosted booking primitive. */
222
+ export function parseBookingUrl(url: string): ParseResult {
223
+ const trimmed = url.trim();
224
+ if (!trimmed) return fail("URL required");
225
+ if (/^javascript:/i.test(trimmed)) return fail("Invalid URL");
226
+
227
+ return (
228
+ parseCalCom(trimmed)
229
+ ?? parseCalendly(trimmed)
230
+ ?? fail("Unsupported booking URL (Cal.com)")
231
+ );
232
+ }
@@ -0,0 +1,58 @@
1
+ export const BANNED_PHRASES = [
2
+ "the real power",
3
+ "unlock the",
4
+ "in today's fast-paced world",
5
+ "truly make a difference",
6
+ "game-changing",
7
+ "at the end of the day",
8
+ "cutting-edge",
9
+ "take your business to the next level",
10
+ "revolutionize",
11
+ "leverage",
12
+ "seamlessly integrate",
13
+ "empower",
14
+ "robust solution",
15
+ "innovative solution",
16
+ "unparalleled",
17
+ "elevate your",
18
+ "it's not just X, it's Y",
19
+ ];
20
+
21
+ const SMART_QUOTES: Record<string, string> = {
22
+ "\u201c": '"',
23
+ "\u201d": '"',
24
+ "\u2018": "'",
25
+ "\u2019": "'",
26
+ };
27
+
28
+ export function containsBannedPhrase(text: string): boolean {
29
+ const lower = text.toLowerCase();
30
+ return BANNED_PHRASES.some((p) => lower.includes(p.toLowerCase()));
31
+ }
32
+
33
+ function stripBannedPhrases(text: string): string {
34
+ let out = text;
35
+ for (const phrase of BANNED_PHRASES) {
36
+ const re = new RegExp(phrase.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "gi");
37
+ out = out.replace(re, "");
38
+ }
39
+ return out.replace(/\s{2,}/g, " ").replace(/\s+([,.!?])/g, "$1").trim();
40
+ }
41
+
42
+ function normalizeDashes(text: string): string {
43
+ return text
44
+ .replace(/\s*[\u2014]\s*/g, ". ")
45
+ .replace(/[\u2013]/g, "-");
46
+ }
47
+
48
+ function normalizeQuotes(text: string): string {
49
+ return text.replace(/[\u201c\u201d\u2018\u2019]/g, (ch) => SMART_QUOTES[ch] ?? ch);
50
+ }
51
+
52
+ export function humanize(text: string): string {
53
+ let out = text;
54
+ out = normalizeQuotes(out);
55
+ out = normalizeDashes(out);
56
+ out = stripBannedPhrases(out);
57
+ return out;
58
+ }
@@ -0,0 +1,48 @@
1
+ export type FeatureItem = {
2
+ icon?: string;
3
+ label: string;
4
+ desc?: string;
5
+ bullets?: string[];
6
+ linkLabel?: string;
7
+ linkHref?: string;
8
+ };
9
+
10
+ const MAX_LEGACY_FEATURES = 6;
11
+
12
+ /** Parse features section items from JSON `items` slot or legacy numbered slots. */
13
+ export function parseFeatureItems(copy: Record<string, string>): FeatureItem[] {
14
+ const raw = copy.items?.trim();
15
+ if (raw) {
16
+ try {
17
+ const parsed = JSON.parse(raw) as unknown;
18
+ if (Array.isArray(parsed)) {
19
+ return parsed
20
+ .filter((item): item is FeatureItem => item != null && typeof item === 'object' && typeof (item as FeatureItem).label === 'string')
21
+ .map((item) => ({
22
+ icon: item.icon ?? '',
23
+ label: item.label,
24
+ desc: item.desc ?? '',
25
+ bullets: Array.isArray(item.bullets) ? item.bullets.filter((b): b is string => typeof b === 'string') : undefined,
26
+ linkLabel: item.linkLabel ?? '',
27
+ linkHref: item.linkHref ?? '',
28
+ }));
29
+ }
30
+ } catch {
31
+ // fall through to legacy slots
32
+ }
33
+ }
34
+
35
+ const legacy: FeatureItem[] = [];
36
+ for (let i = 1; i <= MAX_LEGACY_FEATURES; i += 1) {
37
+ const label = copy[`feature${i}Label`] ?? '';
38
+ if (!label) continue;
39
+ legacy.push({
40
+ icon: copy[`feature${i}Icon`] ?? '',
41
+ label,
42
+ desc: copy[`feature${i}Desc`] ?? '',
43
+ linkLabel: copy[`feature${i}LinkLabel`] ?? '',
44
+ linkHref: copy[`feature${i}LinkHref`] ?? '',
45
+ });
46
+ }
47
+ return legacy;
48
+ }
@@ -0,0 +1,70 @@
1
+ import type { CSSProperties } from 'react';
2
+
3
+ export const SECTION_SURFACE_KEYS = [
4
+ 'sectionBg',
5
+ 'sectionFg',
6
+ 'sectionBgImage',
7
+ 'sectionBgGradient',
8
+ 'sectionBgOpacity',
9
+ 'sectionBgBlend',
10
+ ] as const;
11
+
12
+ /** Tailwind classes — per-instance overrides via copy.sectionBg / copy.sectionFg. */
13
+ export const SECTION_SURFACE_CLASSES =
14
+ 'bg-[var(--section-bg,var(--background))] text-[var(--section-fg,var(--foreground))]';
15
+
16
+ /** Optional per-section surface override from copy slots. */
17
+ export function sectionSurfaceStyle(copy: Record<string, string>): CSSProperties | undefined {
18
+ const bg = copy.sectionBg?.trim();
19
+ const fg = copy.sectionFg?.trim();
20
+ const bgImage = copy.sectionBgImage?.trim();
21
+ const bgGradient = copy.sectionBgGradient?.trim();
22
+ const bgOpacity = copy.sectionBgOpacity?.trim();
23
+ const bgBlend = copy.sectionBgBlend?.trim();
24
+
25
+ const hasRich = bgImage || bgGradient;
26
+
27
+ if (!bg && !fg && !hasRich) return undefined;
28
+
29
+ if (!hasRich) {
30
+ return {
31
+ ...(bg ? { '--section-bg': bg } : {}),
32
+ ...(fg ? { '--section-fg': fg } : {}),
33
+ } as CSSProperties;
34
+ }
35
+
36
+ const layers: string[] = [];
37
+
38
+ if (bgGradient) {
39
+ layers.push(bgGradient);
40
+ } else if (bgOpacity) {
41
+ const a = parseFloat(bgOpacity);
42
+ if (!isNaN(a) && a > 0) {
43
+ layers.push(`linear-gradient(rgba(0,0,0,${a}),rgba(0,0,0,${a}))`);
44
+ }
45
+ }
46
+
47
+ if (bgImage) {
48
+ layers.push(`url(${bgImage}) center/cover no-repeat`);
49
+ }
50
+
51
+ if (bg) {
52
+ layers.push(bg);
53
+ }
54
+
55
+ const style: CSSProperties = {};
56
+
57
+ if (layers.length > 0) {
58
+ style.background = layers.join(', ');
59
+ }
60
+
61
+ if (bgBlend) {
62
+ style.backgroundBlendMode = bgBlend;
63
+ }
64
+
65
+ if (fg) {
66
+ (style as Record<string, string>)['--section-fg'] = fg;
67
+ }
68
+
69
+ return style;
70
+ }
@@ -0,0 +1,6 @@
1
+ import { clsx, type ClassValue } from "clsx"
2
+ import { twMerge } from "tailwind-merge"
3
+
4
+ export function cn(...inputs: ClassValue[]) {
5
+ return twMerge(clsx(inputs))
6
+ }
@@ -0,0 +1,16 @@
1
+ import type { SectionRegistry } from "@nersh/render";
2
+ import { Component as navbar } from "@/sections/navbar/Component";
3
+ import { Component as marketingHero } from "@/sections/marketing-hero/Component";
4
+ import { Component as features } from "@/sections/features/Component";
5
+ import { Component as pricing } from "@/sections/pricing/Component";
6
+ import { Component as about } from "@/sections/about/Component";
7
+ import { Component as footer } from "@/sections/footer/Component";
8
+
9
+ export const registry: SectionRegistry = {
10
+ "navbar": navbar,
11
+ "marketing-hero": marketingHero,
12
+ "features": features,
13
+ "pricing": pricing,
14
+ "about": about,
15
+ "footer": footer,
16
+ };
@@ -0,0 +1,51 @@
1
+ import type { SectionProps } from "../types";
2
+ import { sectionSurfaceStyle } from "@/lib/sectionSurface";
3
+ import { SafeEmbedFromUrl } from "@/components/site/SafeEmbed";
4
+ import { SiteCodeBlock } from "@/components/site/SiteCodeBlock";
5
+ import { SiteSectionShell } from "@/components/site/SiteSectionShell";
6
+
7
+ export function Component({ copy }: SectionProps) {
8
+ const heading = copy.heading || "About";
9
+ const body = copy.body ?? "";
10
+ const image = copy.image ?? "";
11
+ const video = copy.video ?? "";
12
+ const codeSample = copy.codeSample ?? "";
13
+
14
+ return (
15
+ <SiteSectionShell
16
+ id={copy.anchor}
17
+ heading={heading}
18
+ style={sectionSurfaceStyle(copy)}
19
+ className="bg-[var(--section-bg,var(--background))] text-[var(--section-fg,var(--foreground))]"
20
+ innerClassName="max-w-5xl"
21
+ >
22
+ <div
23
+ className={
24
+ image
25
+ ? "grid justify-items-center gap-8 @md/site:grid-cols-[minmax(0,1fr)_minmax(0,2fr)] @md/site:items-start @md/site:justify-items-stretch"
26
+ : ""
27
+ }
28
+ >
29
+ {image && (
30
+ <div className="site-media-frame site-media-frame--free">
31
+ {/* eslint-disable-next-line @next/next/no-img-element */}
32
+ <img src={image} alt="" className="site-media-img" />
33
+ </div>
34
+ )}
35
+ <p className="site-type-subhead leading-relaxed text-[var(--foreground)]">
36
+ {body}
37
+ </p>
38
+ </div>
39
+ {video && (
40
+ <div className="mt-8">
41
+ <SafeEmbedFromUrl url={video} kind="videoEmbed" title="About video" />
42
+ </div>
43
+ )}
44
+ {codeSample && (
45
+ <div className="mt-8">
46
+ <SiteCodeBlock raw={codeSample} />
47
+ </div>
48
+ )}
49
+ </SiteSectionShell>
50
+ );
51
+ }
@@ -0,0 +1,7 @@
1
+ import type { Section } from "../types";
2
+ import { Component } from "./Component";
3
+ import { schema } from "./schema";
4
+ import { meta } from "./meta";
5
+ import { writeCopy } from "./writeCopy";
6
+
7
+ export const about: Section = { meta, schema, Component, writeCopy };
@@ -0,0 +1,8 @@
1
+ import type { SectionMeta } from "../types";
2
+
3
+ export const meta: SectionMeta = {
4
+ id: "about",
5
+ displayName: "About",
6
+ family: "content",
7
+ tags: ["about", "bio", "personal", "story", "content"],
8
+ };
@@ -0,0 +1,38 @@
1
+ import type { SectionCopySchemaField } from "../types";
2
+
3
+ export const schema: SectionCopySchemaField[] = [
4
+ {
5
+ key: "heading",
6
+ label: "Heading",
7
+ type: "text",
8
+ placeholder: '"About"',
9
+ required: false,
10
+ maxLength: 60,
11
+ },
12
+ {
13
+ key: "image",
14
+ label: "Image",
15
+ type: "image",
16
+ required: false,
17
+ },
18
+ {
19
+ key: "body",
20
+ label: "Body",
21
+ type: "textarea",
22
+ placeholder: "One or two paragraphs about the work.",
23
+ required: true,
24
+ maxLength: 800,
25
+ },
26
+ {
27
+ key: "video",
28
+ label: "Video",
29
+ type: "videoEmbed",
30
+ required: false,
31
+ },
32
+ {
33
+ key: "codeSample",
34
+ label: "Code sample",
35
+ type: "codeBlock",
36
+ required: false,
37
+ },
38
+ ];
@@ -0,0 +1,10 @@
1
+ import type { SectionWriteCopy } from "../types";
2
+ import { virgilQuote } from "../copyHelpers";
3
+
4
+ export const writeCopy: SectionWriteCopy = (ctx) => {
5
+ // Vibes drive aesthetics (palette, font) — they never appear as copy.
6
+ return {
7
+ heading: virgilQuote("About"),
8
+ body: (ctx.purpose ?? "").trim() || "More to come.",
9
+ };
10
+ };
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Shared string helpers for section writeCopy functions. Pure, deterministic.
3
+ */
4
+
5
+ export function firstSentence(s: string): string {
6
+ const trimmed = s.trim();
7
+ if (!trimmed) return "";
8
+ const match = trimmed.match(/^[^.!?]+[.!?]/);
9
+ return (match ? match[0] : trimmed).trim();
10
+ }
11
+
12
+ export function firstWord(s: string): string {
13
+ return s.trim().split(/\s+/)[0] ?? "";
14
+ }
15
+
16
+ export function initials(s: string): string {
17
+ const words = s.trim().split(/\s+/).filter(Boolean);
18
+ return words
19
+ .slice(0, 3)
20
+ .map((w) => w[0]?.toUpperCase() ?? "")
21
+ .join("");
22
+ }
23
+
24
+ /** Virgil Abloh — quoted label around default section headings. */
25
+ export function virgilQuote(label: string): string {
26
+ const trimmed = label.trim();
27
+ if (!trimmed) return trimmed;
28
+ if (trimmed.startsWith('"') && trimmed.endsWith('"')) return trimmed;
29
+ return `"${trimmed}"`;
30
+ }
31
+
32
+ /** Strip decorative Virgil quotes from a heading label. */
33
+ export function unvirgilQuote(label: string): string {
34
+ const trimmed = label.trim();
35
+ if (trimmed.startsWith('"') && trimmed.endsWith('"') && trimmed.length >= 2) {
36
+ return trimmed.slice(1, -1).trim();
37
+ }
38
+ return trimmed;
39
+ }
40
+
41
+ /** Section heading seed — plain label (preset-specific styling returns with future skins). */
42
+ export function headingForSkin(_skinId: string, label: string): string {
43
+ return unvirgilQuote(label);
44
+ }
45
+
46
+ const HEADING_SLOT_KEYS = new Set(["heading", "headline"]);
47
+
48
+ export function isHeadingSlotKey(key: string): boolean {
49
+ return HEADING_SLOT_KEYS.has(key);
50
+ }
51
+
52
+ export function truncate(s: string, max: number, ellipsis = "…"): string {
53
+ const trimmed = s.trim();
54
+ if (trimmed.length <= max) return trimmed;
55
+ const cut = trimmed.slice(0, max - 1);
56
+ const lastSpace = cut.lastIndexOf(" ");
57
+ const base = lastSpace > 0 ? cut.slice(0, lastSpace) : cut;
58
+ return base.trim() + ellipsis;
59
+ }