@contractspec/lib.content-gen 1.57.0 → 1.58.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 (51) hide show
  1. package/dist/browser/generators/blog.js +88 -0
  2. package/dist/browser/generators/email.js +111 -0
  3. package/dist/browser/generators/index.js +367 -0
  4. package/dist/browser/generators/landing-page.js +93 -0
  5. package/dist/browser/generators/social.js +78 -0
  6. package/dist/browser/index.js +407 -0
  7. package/dist/browser/seo/index.js +42 -0
  8. package/dist/browser/seo/optimizer.js +42 -0
  9. package/dist/browser/types.js +0 -0
  10. package/dist/generators/blog.d.ts +10 -14
  11. package/dist/generators/blog.d.ts.map +1 -1
  12. package/dist/generators/blog.js +88 -69
  13. package/dist/generators/email.d.ts +13 -17
  14. package/dist/generators/email.d.ts.map +1 -1
  15. package/dist/generators/email.js +103 -91
  16. package/dist/generators/index.d.ts +5 -5
  17. package/dist/generators/index.d.ts.map +1 -0
  18. package/dist/generators/index.js +367 -5
  19. package/dist/generators/landing-page.d.ts +21 -25
  20. package/dist/generators/landing-page.d.ts.map +1 -1
  21. package/dist/generators/landing-page.js +93 -77
  22. package/dist/generators/social.d.ts +9 -13
  23. package/dist/generators/social.d.ts.map +1 -1
  24. package/dist/generators/social.js +77 -73
  25. package/dist/index.d.ts +4 -7
  26. package/dist/index.d.ts.map +1 -0
  27. package/dist/index.js +407 -6
  28. package/dist/node/generators/blog.js +88 -0
  29. package/dist/node/generators/email.js +111 -0
  30. package/dist/node/generators/index.js +367 -0
  31. package/dist/node/generators/landing-page.js +93 -0
  32. package/dist/node/generators/social.js +78 -0
  33. package/dist/node/index.js +407 -0
  34. package/dist/node/seo/index.js +42 -0
  35. package/dist/node/seo/optimizer.js +42 -0
  36. package/dist/node/types.js +0 -0
  37. package/dist/seo/index.d.ts +2 -2
  38. package/dist/seo/index.d.ts.map +1 -0
  39. package/dist/seo/index.js +43 -3
  40. package/dist/seo/optimizer.d.ts +6 -10
  41. package/dist/seo/optimizer.d.ts.map +1 -1
  42. package/dist/seo/optimizer.js +42 -48
  43. package/dist/types.d.ts +58 -62
  44. package/dist/types.d.ts.map +1 -1
  45. package/dist/types.js +1 -0
  46. package/package.json +100 -31
  47. package/dist/generators/blog.js.map +0 -1
  48. package/dist/generators/email.js.map +0 -1
  49. package/dist/generators/landing-page.js.map +0 -1
  50. package/dist/generators/social.js.map +0 -1
  51. package/dist/seo/optimizer.js.map +0 -1
@@ -0,0 +1,407 @@
1
+ // src/generators/blog.ts
2
+ class BlogGenerator {
3
+ llm;
4
+ model;
5
+ temperature;
6
+ constructor(options) {
7
+ this.llm = options?.llm;
8
+ this.model = options?.model;
9
+ this.temperature = options?.temperature ?? 0.4;
10
+ }
11
+ async generate(brief) {
12
+ if (this.llm) {
13
+ return this.generateWithLlm(brief);
14
+ }
15
+ return this.generateDeterministic(brief);
16
+ }
17
+ async generateWithLlm(brief) {
18
+ if (!this.llm) {
19
+ return this.generateDeterministic(brief);
20
+ }
21
+ const response = await this.llm.chat([
22
+ {
23
+ role: "system",
24
+ content: [
25
+ {
26
+ type: "text",
27
+ text: "You are a product marketing writer. Produce JSON with title, subtitle, intro, sections[].heading/body/bullets, outro."
28
+ }
29
+ ]
30
+ },
31
+ {
32
+ role: "user",
33
+ content: [
34
+ {
35
+ type: "text",
36
+ text: JSON.stringify({ brief })
37
+ }
38
+ ]
39
+ }
40
+ ], {
41
+ responseFormat: "json",
42
+ model: this.model,
43
+ temperature: this.temperature
44
+ });
45
+ const jsonPart = response.message.content.find((part) => ("text" in part));
46
+ if (jsonPart && "text" in jsonPart) {
47
+ return JSON.parse(jsonPart.text);
48
+ }
49
+ return this.generateDeterministic(brief);
50
+ }
51
+ generateDeterministic(brief) {
52
+ const intro = `Operators like ${brief.audience.role} teams face ${brief.problems.slice(0, 2).join(" and ")}. ${brief.title} changes that by ${brief.summary}.`;
53
+ const sections = [
54
+ {
55
+ heading: "Why now",
56
+ body: this.renderWhyNow(brief)
57
+ },
58
+ {
59
+ heading: "What you get",
60
+ body: "A focused stack built for policy-safe automation.",
61
+ bullets: brief.solutions
62
+ },
63
+ {
64
+ heading: "Proof it works",
65
+ body: "Teams using the blueprint report measurable wins.",
66
+ bullets: brief.metrics ?? [
67
+ "Launch workflows in minutes",
68
+ "Cut review time by 60%"
69
+ ]
70
+ }
71
+ ];
72
+ return {
73
+ title: brief.title,
74
+ subtitle: brief.summary,
75
+ intro,
76
+ sections,
77
+ outro: brief.callToAction ?? "Ready to see it live? Spin up a sandbox in under 5 minutes."
78
+ };
79
+ }
80
+ renderWhyNow(brief) {
81
+ const audience = `${brief.audience.role}${brief.audience.industry ? ` in ${brief.audience.industry}` : ""}`;
82
+ const pains = brief.problems.slice(0, 2).join("; ");
83
+ return `${audience} teams are stuck with ${pains}. ${brief.title} delivers guardrails without slowing shipping.`;
84
+ }
85
+ }
86
+
87
+ // src/generators/email.ts
88
+ class EmailCampaignGenerator {
89
+ llm;
90
+ model;
91
+ temperature;
92
+ constructor(options) {
93
+ this.llm = options?.llm;
94
+ this.model = options?.model;
95
+ this.temperature = options?.temperature ?? 0.6;
96
+ }
97
+ async generate(input) {
98
+ if (this.llm) {
99
+ const draft = await this.generateWithLlm(input);
100
+ if (draft)
101
+ return draft;
102
+ }
103
+ return this.generateFallback(input);
104
+ }
105
+ async generateWithLlm(input) {
106
+ if (!this.llm)
107
+ return null;
108
+ const response = await this.llm.chat([
109
+ {
110
+ role: "system",
111
+ content: [
112
+ {
113
+ type: "text",
114
+ text: "Draft product marketing email as JSON {subject, previewText, body, cta}."
115
+ }
116
+ ]
117
+ },
118
+ {
119
+ role: "user",
120
+ content: [{ type: "text", text: JSON.stringify(input) }]
121
+ }
122
+ ], {
123
+ responseFormat: "json",
124
+ model: this.model,
125
+ temperature: this.temperature
126
+ });
127
+ const jsonPart = response.message.content.find((chunk) => ("text" in chunk));
128
+ if (!jsonPart || !("text" in jsonPart))
129
+ return null;
130
+ const parsed = JSON.parse(jsonPart.text);
131
+ if (!parsed.subject || !parsed.body || !parsed.cta)
132
+ return null;
133
+ return {
134
+ subject: parsed.subject,
135
+ previewText: parsed.previewText ?? this.defaultPreview(input),
136
+ body: parsed.body,
137
+ cta: parsed.cta,
138
+ variant: input.variant
139
+ };
140
+ }
141
+ generateFallback(input) {
142
+ const { brief, variant } = input;
143
+ const subject = this.subjects(brief.title, variant)[0] ?? `${brief.title} update`;
144
+ const previewText = this.defaultPreview(input);
145
+ const body = this.renderBody(input);
146
+ const cta = brief.callToAction ?? "Explore the sandbox";
147
+ return { subject, previewText, body, cta, variant };
148
+ }
149
+ subjects(title, variant) {
150
+ switch (variant) {
151
+ case "announcement":
152
+ return [`Launch: ${title}`, `${title} is live`, `New: ${title}`];
153
+ case "onboarding":
154
+ return [`Get started with ${title}`, `Your ${title} guide`];
155
+ case "nurture":
156
+ default:
157
+ return [`How ${title} speeds ops`, `Proof ${title} works`];
158
+ }
159
+ }
160
+ defaultPreview(input) {
161
+ const win = input.brief.metrics?.[0] ?? "ship faster without policy gaps";
162
+ return `See how teams ${win}.`;
163
+ }
164
+ renderBody(input) {
165
+ const { brief, variant } = input;
166
+ const greeting = "Hi there,";
167
+ const hook = this.variantHook(variant, brief);
168
+ const proof = brief.metrics?.map((metric) => `• ${metric}`).join(`
169
+ `) ?? "";
170
+ return `${greeting}
171
+
172
+ ${hook}
173
+
174
+ Top reasons teams adopt ${brief.title}:
175
+ ${brief.solutions.map((solution) => `• ${solution}`).join(`
176
+ `)}
177
+
178
+ ${proof}
179
+
180
+ ${brief.callToAction ?? "Spin up a sandbox"} → ${(input.cadenceDay ?? 0) + 1}
181
+ `;
182
+ }
183
+ variantHook(variant, brief) {
184
+ switch (variant) {
185
+ case "announcement":
186
+ return `${brief.title} is live. ${brief.summary}`;
187
+ case "onboarding":
188
+ return `Here is your next step to unlock ${brief.title}.`;
189
+ case "nurture":
190
+ default:
191
+ return `Operators like ${brief.audience.role} keep asking how to automate policy checks. Here is what works.`;
192
+ }
193
+ }
194
+ }
195
+
196
+ // src/generators/landing-page.ts
197
+ class LandingPageGenerator {
198
+ options;
199
+ llm;
200
+ model;
201
+ constructor(options) {
202
+ this.options = options;
203
+ this.llm = options?.llm;
204
+ this.model = options?.model;
205
+ }
206
+ async generate(brief) {
207
+ if (this.llm) {
208
+ return this.generateWithLlm(brief);
209
+ }
210
+ return this.generateFallback(brief);
211
+ }
212
+ async generateWithLlm(brief) {
213
+ if (!this.llm) {
214
+ return this.generateFallback(brief);
215
+ }
216
+ const response = await this.llm.chat([
217
+ {
218
+ role: "system",
219
+ content: [
220
+ {
221
+ type: "text",
222
+ text: "Write JSON landing page copy with hero/highlights/socialProof/faq arrays."
223
+ }
224
+ ]
225
+ },
226
+ {
227
+ role: "user",
228
+ content: [{ type: "text", text: JSON.stringify({ brief }) }]
229
+ }
230
+ ], {
231
+ responseFormat: "json",
232
+ model: this.model,
233
+ temperature: this.options?.temperature ?? 0.5
234
+ });
235
+ const part = response.message.content.find((chunk) => ("text" in chunk));
236
+ if (part && "text" in part) {
237
+ return JSON.parse(part.text);
238
+ }
239
+ return this.generateFallback(brief);
240
+ }
241
+ generateFallback(brief) {
242
+ return {
243
+ hero: {
244
+ eyebrow: `${brief.audience.industry ?? "Operations"} teams`,
245
+ title: brief.title,
246
+ subtitle: brief.summary,
247
+ primaryCta: brief.callToAction ?? "Launch a sandbox",
248
+ secondaryCta: "View docs"
249
+ },
250
+ highlights: brief.solutions.slice(0, 3).map((solution, index) => ({
251
+ heading: [
252
+ "Policy-safe by default",
253
+ "Auto-adapts per tenant",
254
+ "Launch-ready in days"
255
+ ][index] ?? "Key capability",
256
+ body: solution
257
+ })),
258
+ socialProof: {
259
+ heading: "Teams using ContractSpec",
260
+ body: brief.proofPoints?.join(`
261
+ `) ?? "“We ship compliant workflows 5x faster while cutting ops toil in half.”"
262
+ },
263
+ faq: this.buildFaq(brief)
264
+ };
265
+ }
266
+ buildFaq(brief) {
267
+ const faqs = [
268
+ {
269
+ heading: "How does this keep policies enforced?",
270
+ body: "All workflows compile from TypeScript specs and pass through PDP checks before execution, so no shadow logic slips through."
271
+ },
272
+ {
273
+ heading: "Will it fit our existing stack?",
274
+ body: "Runtime adapters plug into REST, GraphQL, or MCP. Integrations stay vendor agnostic."
275
+ }
276
+ ];
277
+ if (brief.complianceNotes?.length) {
278
+ faqs.push({
279
+ heading: "What about compliance requirements?",
280
+ body: brief.complianceNotes.join(" ")
281
+ });
282
+ }
283
+ return faqs;
284
+ }
285
+ }
286
+
287
+ // src/generators/social.ts
288
+ class SocialPostGenerator {
289
+ llm;
290
+ model;
291
+ constructor(options) {
292
+ this.llm = options?.llm;
293
+ this.model = options?.model;
294
+ }
295
+ async generate(brief) {
296
+ if (this.llm) {
297
+ const posts = await this.generateWithLlm(brief);
298
+ if (posts.length)
299
+ return posts;
300
+ }
301
+ return this.generateFallback(brief);
302
+ }
303
+ async generateWithLlm(brief) {
304
+ if (!this.llm)
305
+ return [];
306
+ const response = await this.llm.chat([
307
+ {
308
+ role: "system",
309
+ content: [
310
+ {
311
+ type: "text",
312
+ text: "Create JSON array of social posts for twitter/linkedin/threads with body, hashtags, cta."
313
+ }
314
+ ]
315
+ },
316
+ {
317
+ role: "user",
318
+ content: [{ type: "text", text: JSON.stringify(brief) }]
319
+ }
320
+ ], { responseFormat: "json", model: this.model });
321
+ const part = response.message.content.find((chunk) => ("text" in chunk));
322
+ if (!part || !("text" in part))
323
+ return [];
324
+ return JSON.parse(part.text);
325
+ }
326
+ generateFallback(brief) {
327
+ const hashtags = this.buildHashtags(brief);
328
+ return [
329
+ {
330
+ channel: "linkedin",
331
+ body: `${brief.title}: ${brief.summary}
332
+ ${brief.problems[0]} → ${brief.solutions[0]}`,
333
+ hashtags,
334
+ cta: brief.callToAction ?? "Book a 15-min run-through"
335
+ },
336
+ {
337
+ channel: "twitter",
338
+ body: `${brief.solutions[0]} in <60s. ${brief.solutions[1] ?? ""}`.trim(),
339
+ hashtags: hashtags.slice(0, 3),
340
+ cta: "→ contractspec.io/sandbox"
341
+ },
342
+ {
343
+ channel: "threads",
344
+ body: `Ops + policy can move fast. ${brief.title} automates guardrails so teams ship daily.`,
345
+ hashtags: hashtags.slice(1, 4)
346
+ }
347
+ ];
348
+ }
349
+ buildHashtags(brief) {
350
+ const base = [
351
+ brief.audience.industry ? `#${camel(brief.audience.industry)}` : "#operations",
352
+ "#automation",
353
+ "#aiops",
354
+ "#compliance"
355
+ ];
356
+ return [...new Set(base.map((tag) => tag.replace(/\s+/g, "")))].slice(0, 5);
357
+ }
358
+ }
359
+ function camel(text) {
360
+ return text.split(/\s|-/).filter(Boolean).map((word) => word[0]?.toUpperCase() + word.slice(1)).join("");
361
+ }
362
+ // src/seo/optimizer.ts
363
+ class SeoOptimizer {
364
+ optimize(brief) {
365
+ const keywords = this.keywords(brief);
366
+ const metaTitle = `${brief.title} | ContractSpec`;
367
+ const metaDescription = `${brief.summary} — built for ${brief.audience.role}${brief.audience.industry ? ` in ${brief.audience.industry}` : ""}.`;
368
+ const slug = this.slugify(brief.title);
369
+ const schemaMarkup = this.schema(brief, metaDescription, keywords);
370
+ return { metaTitle, metaDescription, keywords, slug, schemaMarkup };
371
+ }
372
+ keywords(brief) {
373
+ const base = [brief.title, ...brief.problems, ...brief.solutions];
374
+ return [
375
+ ...new Set(base.flatMap((entry) => entry.toLowerCase().split(/\s+/)))
376
+ ].filter((word) => word.length > 3).slice(0, 12);
377
+ }
378
+ slugify(text) {
379
+ return text.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
380
+ }
381
+ schema(brief, description, keywords) {
382
+ return {
383
+ "@context": "https://schema.org",
384
+ "@type": "Product",
385
+ name: brief.title,
386
+ description,
387
+ audience: {
388
+ "@type": "Audience",
389
+ audienceType: brief.audience.role,
390
+ industry: brief.audience.industry
391
+ },
392
+ offers: {
393
+ "@type": "Offer",
394
+ description: brief.callToAction ?? "Start building with ContractSpec"
395
+ },
396
+ keywords: keywords.join(", "),
397
+ citation: brief.references?.map((ref) => ref.url)
398
+ };
399
+ }
400
+ }
401
+ export {
402
+ SocialPostGenerator,
403
+ SeoOptimizer,
404
+ LandingPageGenerator,
405
+ EmailCampaignGenerator,
406
+ BlogGenerator
407
+ };
@@ -0,0 +1,42 @@
1
+ // src/seo/optimizer.ts
2
+ class SeoOptimizer {
3
+ optimize(brief) {
4
+ const keywords = this.keywords(brief);
5
+ const metaTitle = `${brief.title} | ContractSpec`;
6
+ const metaDescription = `${brief.summary} — built for ${brief.audience.role}${brief.audience.industry ? ` in ${brief.audience.industry}` : ""}.`;
7
+ const slug = this.slugify(brief.title);
8
+ const schemaMarkup = this.schema(brief, metaDescription, keywords);
9
+ return { metaTitle, metaDescription, keywords, slug, schemaMarkup };
10
+ }
11
+ keywords(brief) {
12
+ const base = [brief.title, ...brief.problems, ...brief.solutions];
13
+ return [
14
+ ...new Set(base.flatMap((entry) => entry.toLowerCase().split(/\s+/)))
15
+ ].filter((word) => word.length > 3).slice(0, 12);
16
+ }
17
+ slugify(text) {
18
+ return text.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
19
+ }
20
+ schema(brief, description, keywords) {
21
+ return {
22
+ "@context": "https://schema.org",
23
+ "@type": "Product",
24
+ name: brief.title,
25
+ description,
26
+ audience: {
27
+ "@type": "Audience",
28
+ audienceType: brief.audience.role,
29
+ industry: brief.audience.industry
30
+ },
31
+ offers: {
32
+ "@type": "Offer",
33
+ description: brief.callToAction ?? "Start building with ContractSpec"
34
+ },
35
+ keywords: keywords.join(", "),
36
+ citation: brief.references?.map((ref) => ref.url)
37
+ };
38
+ }
39
+ }
40
+ export {
41
+ SeoOptimizer
42
+ };
@@ -0,0 +1,42 @@
1
+ // src/seo/optimizer.ts
2
+ class SeoOptimizer {
3
+ optimize(brief) {
4
+ const keywords = this.keywords(brief);
5
+ const metaTitle = `${brief.title} | ContractSpec`;
6
+ const metaDescription = `${brief.summary} — built for ${brief.audience.role}${brief.audience.industry ? ` in ${brief.audience.industry}` : ""}.`;
7
+ const slug = this.slugify(brief.title);
8
+ const schemaMarkup = this.schema(brief, metaDescription, keywords);
9
+ return { metaTitle, metaDescription, keywords, slug, schemaMarkup };
10
+ }
11
+ keywords(brief) {
12
+ const base = [brief.title, ...brief.problems, ...brief.solutions];
13
+ return [
14
+ ...new Set(base.flatMap((entry) => entry.toLowerCase().split(/\s+/)))
15
+ ].filter((word) => word.length > 3).slice(0, 12);
16
+ }
17
+ slugify(text) {
18
+ return text.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
19
+ }
20
+ schema(brief, description, keywords) {
21
+ return {
22
+ "@context": "https://schema.org",
23
+ "@type": "Product",
24
+ name: brief.title,
25
+ description,
26
+ audience: {
27
+ "@type": "Audience",
28
+ audienceType: brief.audience.role,
29
+ industry: brief.audience.industry
30
+ },
31
+ offers: {
32
+ "@type": "Offer",
33
+ description: brief.callToAction ?? "Start building with ContractSpec"
34
+ },
35
+ keywords: keywords.join(", "),
36
+ citation: brief.references?.map((ref) => ref.url)
37
+ };
38
+ }
39
+ }
40
+ export {
41
+ SeoOptimizer
42
+ };
File without changes
@@ -1,2 +1,2 @@
1
- import { SeoOptimizer } from "./optimizer.js";
2
- export { SeoOptimizer };
1
+ export * from './optimizer';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/seo/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
package/dist/seo/index.js CHANGED
@@ -1,3 +1,43 @@
1
- import { SeoOptimizer } from "./optimizer.js";
2
-
3
- export { SeoOptimizer };
1
+ // @bun
2
+ // src/seo/optimizer.ts
3
+ class SeoOptimizer {
4
+ optimize(brief) {
5
+ const keywords = this.keywords(brief);
6
+ const metaTitle = `${brief.title} | ContractSpec`;
7
+ const metaDescription = `${brief.summary} \u2014 built for ${brief.audience.role}${brief.audience.industry ? ` in ${brief.audience.industry}` : ""}.`;
8
+ const slug = this.slugify(brief.title);
9
+ const schemaMarkup = this.schema(brief, metaDescription, keywords);
10
+ return { metaTitle, metaDescription, keywords, slug, schemaMarkup };
11
+ }
12
+ keywords(brief) {
13
+ const base = [brief.title, ...brief.problems, ...brief.solutions];
14
+ return [
15
+ ...new Set(base.flatMap((entry) => entry.toLowerCase().split(/\s+/)))
16
+ ].filter((word) => word.length > 3).slice(0, 12);
17
+ }
18
+ slugify(text) {
19
+ return text.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
20
+ }
21
+ schema(brief, description, keywords) {
22
+ return {
23
+ "@context": "https://schema.org",
24
+ "@type": "Product",
25
+ name: brief.title,
26
+ description,
27
+ audience: {
28
+ "@type": "Audience",
29
+ audienceType: brief.audience.role,
30
+ industry: brief.audience.industry
31
+ },
32
+ offers: {
33
+ "@type": "Offer",
34
+ description: brief.callToAction ?? "Start building with ContractSpec"
35
+ },
36
+ keywords: keywords.join(", "),
37
+ citation: brief.references?.map((ref) => ref.url)
38
+ };
39
+ }
40
+ }
41
+ export {
42
+ SeoOptimizer
43
+ };
@@ -1,12 +1,8 @@
1
- import { ContentBrief, SeoMetadata } from "../types.js";
2
-
3
- //#region src/seo/optimizer.d.ts
4
- declare class SeoOptimizer {
5
- optimize(brief: ContentBrief): SeoMetadata;
6
- private keywords;
7
- private slugify;
8
- private schema;
1
+ import type { ContentBrief, SeoMetadata } from '../types';
2
+ export declare class SeoOptimizer {
3
+ optimize(brief: ContentBrief): SeoMetadata;
4
+ private keywords;
5
+ private slugify;
6
+ private schema;
9
7
  }
10
- //#endregion
11
- export { SeoOptimizer };
12
8
  //# sourceMappingURL=optimizer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"optimizer.d.ts","names":[],"sources":["../../src/seo/optimizer.ts"],"mappings":";;;cAEa,YAAA;EACX,QAAA,CAAS,KAAA,EAAO,YAAA,GAAe,WAAA;EAAA,QASvB,QAAA;EAAA,QASA,OAAA;EAAA,QAOA,MAAA;AAAA"}
1
+ {"version":3,"file":"optimizer.d.ts","sourceRoot":"","sources":["../../src/seo/optimizer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE1D,qBAAa,YAAY;IACvB,QAAQ,CAAC,KAAK,EAAE,YAAY,GAAG,WAAW;IAS1C,OAAO,CAAC,QAAQ;IAShB,OAAO,CAAC,OAAO;IAOf,OAAO,CAAC,MAAM;CAuBf"}
@@ -1,49 +1,43 @@
1
- //#region src/seo/optimizer.ts
2
- var SeoOptimizer = class {
3
- optimize(brief) {
4
- const keywords = this.keywords(brief);
5
- const metaTitle = `${brief.title} | ContractSpec`;
6
- const metaDescription = `${brief.summary} built for ${brief.audience.role}${brief.audience.industry ? ` in ${brief.audience.industry}` : ""}.`;
7
- return {
8
- metaTitle,
9
- metaDescription,
10
- keywords,
11
- slug: this.slugify(brief.title),
12
- schemaMarkup: this.schema(brief, metaDescription, keywords)
13
- };
14
- }
15
- keywords(brief) {
16
- const base = [
17
- brief.title,
18
- ...brief.problems,
19
- ...brief.solutions
20
- ];
21
- return [...new Set(base.flatMap((entry) => entry.toLowerCase().split(/\s+/)))].filter((word) => word.length > 3).slice(0, 12);
22
- }
23
- slugify(text) {
24
- return text.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
25
- }
26
- schema(brief, description, keywords) {
27
- return {
28
- "@context": "https://schema.org",
29
- "@type": "Product",
30
- name: brief.title,
31
- description,
32
- audience: {
33
- "@type": "Audience",
34
- audienceType: brief.audience.role,
35
- industry: brief.audience.industry
36
- },
37
- offers: {
38
- "@type": "Offer",
39
- description: brief.callToAction ?? "Start building with ContractSpec"
40
- },
41
- keywords: keywords.join(", "),
42
- citation: brief.references?.map((ref) => ref.url)
43
- };
44
- }
1
+ // @bun
2
+ // src/seo/optimizer.ts
3
+ class SeoOptimizer {
4
+ optimize(brief) {
5
+ const keywords = this.keywords(brief);
6
+ const metaTitle = `${brief.title} | ContractSpec`;
7
+ const metaDescription = `${brief.summary} \u2014 built for ${brief.audience.role}${brief.audience.industry ? ` in ${brief.audience.industry}` : ""}.`;
8
+ const slug = this.slugify(brief.title);
9
+ const schemaMarkup = this.schema(brief, metaDescription, keywords);
10
+ return { metaTitle, metaDescription, keywords, slug, schemaMarkup };
11
+ }
12
+ keywords(brief) {
13
+ const base = [brief.title, ...brief.problems, ...brief.solutions];
14
+ return [
15
+ ...new Set(base.flatMap((entry) => entry.toLowerCase().split(/\s+/)))
16
+ ].filter((word) => word.length > 3).slice(0, 12);
17
+ }
18
+ slugify(text) {
19
+ return text.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
20
+ }
21
+ schema(brief, description, keywords) {
22
+ return {
23
+ "@context": "https://schema.org",
24
+ "@type": "Product",
25
+ name: brief.title,
26
+ description,
27
+ audience: {
28
+ "@type": "Audience",
29
+ audienceType: brief.audience.role,
30
+ industry: brief.audience.industry
31
+ },
32
+ offers: {
33
+ "@type": "Offer",
34
+ description: brief.callToAction ?? "Start building with ContractSpec"
35
+ },
36
+ keywords: keywords.join(", "),
37
+ citation: brief.references?.map((ref) => ref.url)
38
+ };
39
+ }
40
+ }
41
+ export {
42
+ SeoOptimizer
45
43
  };
46
-
47
- //#endregion
48
- export { SeoOptimizer };
49
- //# sourceMappingURL=optimizer.js.map