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
package/dist/index.mjs ADDED
@@ -0,0 +1,86 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/index.ts
4
+ import {
5
+ cpSync,
6
+ existsSync,
7
+ mkdirSync,
8
+ readFileSync,
9
+ readdirSync,
10
+ unlinkSync,
11
+ writeFileSync
12
+ } from "fs";
13
+ import path from "path";
14
+ var VALID_SKINS = [
15
+ "zinc",
16
+ "slate",
17
+ "stone",
18
+ "gray",
19
+ "neutral",
20
+ "red",
21
+ "rose",
22
+ "orange",
23
+ "green",
24
+ "blue",
25
+ "violet"
26
+ ];
27
+ function die(msg) {
28
+ console.error(msg);
29
+ process.exit(1);
30
+ }
31
+ function main() {
32
+ const args = process.argv.slice(2);
33
+ const flags = {};
34
+ const positional = [];
35
+ for (let i = 0; i < args.length; i++) {
36
+ if (args[i] === "--skin" && args[i + 1]) {
37
+ flags.skin = args[++i];
38
+ } else if (args[i].startsWith("--")) {
39
+ die(`Unknown flag: ${args[i]}`);
40
+ } else {
41
+ positional.push(args[i]);
42
+ }
43
+ }
44
+ const projectName = positional[0];
45
+ if (!projectName) die("Usage: create-nersh <project-name> [--skin <id>]");
46
+ const skinId = flags.skin ?? "zinc";
47
+ if (!VALID_SKINS.includes(skinId)) {
48
+ die(`Invalid skin "${skinId}". Valid skins: ${VALID_SKINS.join(", ")}`);
49
+ }
50
+ const cwd = process.cwd();
51
+ const projectDir = path.resolve(cwd, projectName);
52
+ if (existsSync(projectDir)) {
53
+ const entries = readdirSync(projectDir);
54
+ if (entries.length > 0) {
55
+ die(`Directory "${projectName}" already exists and is not empty.`);
56
+ }
57
+ }
58
+ mkdirSync(projectDir, { recursive: true });
59
+ const templateDir = path.resolve(import.meta.dirname, "../templates/next");
60
+ cpSync(templateDir, projectDir, { recursive: true });
61
+ const tmplPath = path.join(projectDir, "package.json.tmpl");
62
+ const pkgContent = readFileSync(tmplPath, "utf-8").replace(
63
+ /\{\{PROJECT_NAME\}\}/g,
64
+ projectName
65
+ );
66
+ writeFileSync(path.join(projectDir, "package.json"), pkgContent);
67
+ unlinkSync(tmplPath);
68
+ if (skinId !== "zinc") {
69
+ const sitePath = path.join(projectDir, "site.json");
70
+ const site = JSON.parse(readFileSync(sitePath, "utf-8"));
71
+ site.skinId = skinId;
72
+ writeFileSync(sitePath, JSON.stringify(site, null, 2) + "\n");
73
+ }
74
+ console.log(`
75
+ \u2713 Created ${projectName}
76
+
77
+ cd ${projectName}
78
+ npm install
79
+ npm run dev
80
+
81
+ Your site is ready at http://localhost:3000
82
+ Edit sections in src/sections/ \u2014 you own the code.
83
+ Change the skin in site.json (skinId field).
84
+ `);
85
+ }
86
+ main();
package/package.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "create-nersh",
3
+ "version": "0.1.0",
4
+ "description": "Scaffold a nertia site — own the code, rent the skin engine",
5
+ "license": "MIT",
6
+ "author": "nersh <ps2pdx@gmail.com>",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/ps2pdx/nertia",
10
+ "directory": "packages/create-nersh"
11
+ },
12
+ "homepage": "https://nertia.ai",
13
+ "keywords": ["nertia", "nersh", "website", "scaffolder", "create", "cli", "react", "next"],
14
+ "type": "module",
15
+ "bin": {
16
+ "create-nersh": "./dist/index.mjs"
17
+ },
18
+ "files": ["dist", "templates"],
19
+ "scripts": {
20
+ "build": "tsup"
21
+ }
22
+ }
@@ -0,0 +1 @@
1
+ @import "tailwindcss";
@@ -0,0 +1,15 @@
1
+ import type { Metadata } from "next";
2
+ import "./globals.css";
3
+
4
+ export const metadata: Metadata = {
5
+ title: "My Site",
6
+ description: "Built with nersh",
7
+ };
8
+
9
+ export default function RootLayout({ children }: { children: React.ReactNode }) {
10
+ return (
11
+ <html lang="en">
12
+ <body>{children}</body>
13
+ </html>
14
+ );
15
+ }
@@ -0,0 +1,7 @@
1
+ import { SiteRenderer } from "@nersh/render";
2
+ import { registry } from "@/registry";
3
+ import site from "../site.json";
4
+
5
+ export default function Home() {
6
+ return <SiteRenderer site={site} registry={registry} />;
7
+ }
@@ -0,0 +1,5 @@
1
+ import type { NextConfig } from "next";
2
+
3
+ const nextConfig: NextConfig = {};
4
+
5
+ export default nextConfig;
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "{{PROJECT_NAME}}",
3
+ "version": "0.1.0",
4
+ "private": true,
5
+ "scripts": {
6
+ "dev": "next dev",
7
+ "build": "next build",
8
+ "start": "next start"
9
+ },
10
+ "dependencies": {
11
+ "@nersh/render": "^0.2.0",
12
+ "clsx": "^2.1.1",
13
+ "next": "^15.0.0",
14
+ "react": "^19.0.0",
15
+ "react-dom": "^19.0.0",
16
+ "tailwind-merge": "^3.0.0",
17
+ "tailwindcss": "^4.0.0"
18
+ },
19
+ "devDependencies": {
20
+ "@types/node": "^22.0.0",
21
+ "@types/react": "^19.0.0",
22
+ "@types/react-dom": "^19.0.0",
23
+ "typescript": "^5.7.0"
24
+ }
25
+ }
@@ -0,0 +1,119 @@
1
+ {
2
+ "slug": "mysite",
3
+ "composition": {
4
+ "id": "marketing",
5
+ "sections": [
6
+ {
7
+ "id": "navbar",
8
+ "instanceId": "nav-1"
9
+ },
10
+ {
11
+ "id": "marketing-hero",
12
+ "instanceId": "hero-1"
13
+ },
14
+ {
15
+ "id": "features",
16
+ "instanceId": "features-1"
17
+ },
18
+ {
19
+ "id": "pricing",
20
+ "instanceId": "pricing-1"
21
+ },
22
+ {
23
+ "id": "about",
24
+ "instanceId": "about-1"
25
+ },
26
+ {
27
+ "id": "footer",
28
+ "instanceId": "footer-1"
29
+ }
30
+ ]
31
+ },
32
+ "skinId": "zinc",
33
+ "copy": {
34
+ "nav-1.wordmark": "\"WORDMARK\"",
35
+ "nav-1.logoImage": "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%221200%22%20height%3D%22675%22%20viewBox%3D%220%200%201200%20675%22%3E%3Crect%20x%3D%221%22%20y%3D%221%22%20width%3D%221198%22%20height%3D%22673%22%20fill%3D%22%238888881a%22%20stroke%3D%22%23888888%22%20stroke-width%3D%222%22%20stroke-dasharray%3D%2210%208%22%2F%3E%3Ctext%20x%3D%2250%25%22%20y%3D%2250%25%22%20fill%3D%22%23888888%22%20font-family%3D%22ui-monospace%2C%20monospace%22%20font-size%3D%2232%22%20text-anchor%3D%22middle%22%20dominant-baseline%3D%22middle%22%3E%22LOGO%20IMAGE%20%2F%2016%3A9%22%3C%2Ftext%3E%3C%2Fsvg%3E",
36
+ "nav-1.link1Label": "\"LINK 1 LABEL\"",
37
+ "nav-1.link1Href": "\"LINK 1 HREF\"",
38
+ "nav-1.link2Label": "\"LINK 2 LABEL\"",
39
+ "nav-1.link2Href": "\"LINK 2 HREF\"",
40
+ "nav-1.link3Label": "\"LINK 3 LABEL\"",
41
+ "nav-1.link3Href": "\"LINK 3 HREF\"",
42
+ "nav-1.navLinksJson": "\"NAV LINKS (JSON ARRAY — OVERRIDES LINK 1–3)\"",
43
+ "hero-1.eyebrow": "\"EYEBROW (ABOVE HEADLINE)\"",
44
+ "hero-1.headline": "\"HEADLINE\"",
45
+ "hero-1.sub": "\"SUB COPY\"",
46
+ "hero-1.heroImage": "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%221200%22%20height%3D%22675%22%20viewBox%3D%220%200%201200%20675%22%3E%3Crect%20x%3D%221%22%20y%3D%221%22%20width%3D%221198%22%20height%3D%22673%22%20fill%3D%22%238888881a%22%20stroke%3D%22%23888888%22%20stroke-width%3D%222%22%20stroke-dasharray%3D%2210%208%22%2F%3E%3Ctext%20x%3D%2250%25%22%20y%3D%2250%25%22%20fill%3D%22%23888888%22%20font-family%3D%22ui-monospace%2C%20monospace%22%20font-size%3D%2232%22%20text-anchor%3D%22middle%22%20dominant-baseline%3D%22middle%22%3E%22HERO%20IMAGE%20%2F%2016%3A9%22%3C%2Ftext%3E%3C%2Fsvg%3E",
47
+ "hero-1.heroVideo": "",
48
+ "hero-1.ctaLabel": "\"CTA LABEL\"",
49
+ "hero-1.ctaHref": "\"CTA LINK\"",
50
+ "hero-1.cta2Label": "\"SECONDARY CTA LABEL\"",
51
+ "hero-1.cta2Href": "\"SECONDARY CTA LINK\"",
52
+ "hero-1.cardHeading": "\"CTA CARD HEADING (CARD LAYOUT)\"",
53
+ "hero-1.cardSub": "\"CTA CARD SUB (CARD LAYOUT)\"",
54
+ "hero-1.trustBadge1": "\"TRUST BADGE 1 (OPTIONAL)\"",
55
+ "hero-1.trustBadge2": "\"TRUST BADGE 2 (OPTIONAL)\"",
56
+ "hero-1.trustBadge3": "\"TRUST BADGE 3 (OPTIONAL)\"",
57
+ "features-1.headline": "\"HEADLINE\"",
58
+ "features-1.anchor": "\"SECTION ANCHOR (FOR NAV LINKS, E.G. SERVICES)\"",
59
+ "features-1.sub": "\"SUBHEADING\"",
60
+ "features-1.ctaLabel": "\"SECTION CTA LABEL\"",
61
+ "features-1.ctaHref": "\"SECTION CTA LINK\"",
62
+ "features-1.items": "[{\"label\":\"\\\"FEATURE ITEMS\\\"\",\"icon\":\"\",\"desc\":\"what it does\"},{\"label\":\"\\\"FEATURE ITEMS\\\"\",\"icon\":\"\",\"desc\":\"what it does\"},{\"label\":\"\\\"FEATURE ITEMS\\\"\",\"icon\":\"\",\"desc\":\"what it does\"}]",
63
+ "features-1.feature1Icon": "\"FEATURE 1 — ICON (EMOJI)\"",
64
+ "features-1.feature1Label": "\"FEATURE 1 — LABEL\"",
65
+ "features-1.feature1Desc": "\"FEATURE 1 — DESCRIPTION\"",
66
+ "features-1.feature2Icon": "\"FEATURE 2 — ICON (EMOJI)\"",
67
+ "features-1.feature2Label": "\"FEATURE 2 — LABEL\"",
68
+ "features-1.feature2Desc": "\"FEATURE 2 — DESCRIPTION\"",
69
+ "features-1.feature3Icon": "\"FEATURE 3 — ICON (EMOJI)\"",
70
+ "features-1.feature3Label": "\"FEATURE 3 — LABEL\"",
71
+ "features-1.feature3Desc": "\"FEATURE 3 — DESCRIPTION\"",
72
+ "pricing-1.heading": "\"HEADING\"",
73
+ "pricing-1.checkIcon": "\"FEATURE BULLET ICON (IMAGE URL, OPTIONAL)\"",
74
+ "pricing-1.tier1Label": "\"TIER 1 LABEL\"",
75
+ "pricing-1.tier1Price": "\"TIER 1 PRICE\"",
76
+ "pricing-1.tier1Desc": "\"TIER 1 DESCRIPTION\"",
77
+ "pricing-1.tier1Features": "\"TIER 1 FEATURES (ONE PER LINE)\"",
78
+ "pricing-1.tier1CtaLabel": "\"TIER 1 CTA LABEL\"",
79
+ "pricing-1.tier2Label": "\"TIER 2 LABEL\"",
80
+ "pricing-1.tier2Price": "\"TIER 2 PRICE\"",
81
+ "pricing-1.tier2Desc": "\"TIER 2 DESCRIPTION\"",
82
+ "pricing-1.tier2Features": "\"TIER 2 FEATURES (ONE PER LINE)\"",
83
+ "pricing-1.tier2CtaLabel": "\"TIER 2 CTA LABEL\"",
84
+ "pricing-1.tier2Badge": "\"TIER 2 BADGE (OPTIONAL)\"",
85
+ "pricing-1.tier3Label": "\"TIER 3 LABEL\"",
86
+ "pricing-1.tier3Price": "\"TIER 3 PRICE\"",
87
+ "pricing-1.tier3Desc": "\"TIER 3 DESCRIPTION\"",
88
+ "pricing-1.tier3Features": "\"TIER 3 FEATURES (ONE PER LINE)\"",
89
+ "pricing-1.tier3CtaLabel": "\"TIER 3 CTA LABEL\"",
90
+ "about-1.heading": "\"HEADING\"",
91
+ "about-1.image": "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%221200%22%20height%3D%22675%22%20viewBox%3D%220%200%201200%20675%22%3E%3Crect%20x%3D%221%22%20y%3D%221%22%20width%3D%221198%22%20height%3D%22673%22%20fill%3D%22%238888881a%22%20stroke%3D%22%23888888%22%20stroke-width%3D%222%22%20stroke-dasharray%3D%2210%208%22%2F%3E%3Ctext%20x%3D%2250%25%22%20y%3D%2250%25%22%20fill%3D%22%23888888%22%20font-family%3D%22ui-monospace%2C%20monospace%22%20font-size%3D%2232%22%20text-anchor%3D%22middle%22%20dominant-baseline%3D%22middle%22%3E%22IMAGE%20%2F%2016%3A9%22%3C%2Ftext%3E%3C%2Fsvg%3E",
92
+ "about-1.body": "\"BODY\"",
93
+ "about-1.video": "",
94
+ "about-1.codeSample": "",
95
+ "footer-1.wordmark": "\"WORDMARK\"",
96
+ "footer-1.tagline": "\"TAGLINE\"",
97
+ "footer-1.phone": "\"PHONE\"",
98
+ "footer-1.email": "\"EMAIL\"",
99
+ "footer-1.hours": "\"HOURS\"",
100
+ "footer-1.link1Label": "\"QUICK LINK 1 LABEL\"",
101
+ "footer-1.link1Href": "\"QUICK LINK 1 HREF\"",
102
+ "footer-1.link2Label": "\"QUICK LINK 2 LABEL\"",
103
+ "footer-1.link2Href": "\"QUICK LINK 2 HREF\"",
104
+ "footer-1.link3Label": "\"QUICK LINK 3 LABEL\"",
105
+ "footer-1.link3Href": "\"QUICK LINK 3 HREF\"",
106
+ "footer-1.link4Label": "\"QUICK LINK 4 LABEL\"",
107
+ "footer-1.link4Href": "\"QUICK LINK 4 HREF\"",
108
+ "footer-1.link5Label": "\"QUICK LINK 5 LABEL\"",
109
+ "footer-1.link5Href": "\"QUICK LINK 5 HREF\"",
110
+ "footer-1.social1Label": "\"SOCIAL 1 LABEL\"",
111
+ "footer-1.social1Href": "\"SOCIAL 1 URL\"",
112
+ "footer-1.social2Label": "\"SOCIAL 2 LABEL\"",
113
+ "footer-1.social2Href": "\"SOCIAL 2 URL\"",
114
+ "footer-1.social3Label": "\"SOCIAL 3 LABEL\"",
115
+ "footer-1.social3Href": "\"SOCIAL 3 URL\""
116
+ },
117
+ "listingEnabled": false,
118
+ "footerAttribution": "default"
119
+ }
@@ -0,0 +1,72 @@
1
+ 'use client';
2
+
3
+ import { useEffect, useState } from 'react';
4
+ import { parseEmbedUrl, type ParsedEmbed } from '@/lib/embeds';
5
+ import { cn } from '@/lib/utils';
6
+
7
+ type Props = {
8
+ embed: ParsedEmbed;
9
+ title?: string;
10
+ className?: string;
11
+ };
12
+
13
+ function youtubeEmbedSrc(embedSrc: string): string {
14
+ if (typeof window === 'undefined') return embedSrc;
15
+ try {
16
+ const u = new URL(embedSrc);
17
+ const host = u.hostname.replace(/^www\./, '');
18
+ if (host !== 'youtube.com' && host !== 'youtube-nocookie.com') return embedSrc;
19
+ if (!u.pathname.startsWith('/embed/')) return embedSrc;
20
+ u.searchParams.set('origin', window.location.origin);
21
+ return u.toString();
22
+ } catch {
23
+ return embedSrc;
24
+ }
25
+ }
26
+
27
+ export function SafeEmbed({ embed, title, className }: Props) {
28
+ const isAutoHeight = embed.aspectRatio === 'auto';
29
+ // SSR + first client paint use embedSrc without window.origin; patch after mount.
30
+ const [iframeSrc, setIframeSrc] = useState(embed.embedSrc);
31
+
32
+ useEffect(() => {
33
+ setIframeSrc(
34
+ embed.provider === 'youtube' ? youtubeEmbedSrc(embed.embedSrc) : embed.embedSrc,
35
+ );
36
+ }, [embed.embedSrc, embed.provider]);
37
+ return (
38
+ <div
39
+ className={cn(
40
+ 'relative w-full overflow-hidden rounded-[var(--radius)] border border-[var(--card-border)] bg-[var(--card)]',
41
+ className,
42
+ )}
43
+ style={isAutoHeight ? { minHeight: '352px' } : { aspectRatio: embed.aspectRatio }}
44
+ >
45
+ <iframe
46
+ src={iframeSrc}
47
+ title={title ?? `${embed.provider} embed`}
48
+ sandbox="allow-scripts allow-same-origin allow-presentation allow-popups"
49
+ referrerPolicy="strict-origin-when-cross-origin"
50
+ loading="lazy"
51
+ className="absolute inset-0 h-full w-full border-0"
52
+ allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
53
+ />
54
+ </div>
55
+ );
56
+ }
57
+
58
+ export function SafeEmbedFromUrl({
59
+ url,
60
+ kind,
61
+ title,
62
+ className,
63
+ }: {
64
+ url: string;
65
+ kind: 'videoEmbed' | 'iframeEmbed';
66
+ title?: string;
67
+ className?: string;
68
+ }) {
69
+ const result = parseEmbedUrl(url, kind);
70
+ if (!result.ok) return null;
71
+ return <SafeEmbed embed={result.embed} title={title} className={className} />;
72
+ }
@@ -0,0 +1,65 @@
1
+ 'use client';
2
+
3
+ import {
4
+ forwardRef,
5
+ type AnchorHTMLAttributes,
6
+ type ButtonHTMLAttributes,
7
+ type ReactNode,
8
+ } from "react";
9
+ import { cn } from "@/lib/utils";
10
+ import { useSiteStructural } from "@/components/site/SiteStructuralContext";
11
+
12
+ export type SiteButtonVariant = "primary" | "secondary";
13
+
14
+ type SiteButtonBaseProps = {
15
+ variant?: SiteButtonVariant;
16
+ className?: string;
17
+ children?: ReactNode;
18
+ };
19
+
20
+ export type SiteButtonProps = SiteButtonBaseProps &
21
+ (
22
+ | (SiteButtonBaseProps & { href: string } & Omit<AnchorHTMLAttributes<HTMLAnchorElement>, keyof SiteButtonBaseProps | "href">)
23
+ | (SiteButtonBaseProps & { href?: undefined } & Omit<ButtonHTMLAttributes<HTMLButtonElement>, keyof SiteButtonBaseProps>)
24
+ );
25
+
26
+ function variantClass(variant: SiteButtonVariant): string {
27
+ return variant === "primary" ? "site-btn-primary" : "site-btn-secondary";
28
+ }
29
+
30
+ export const SiteButton = forwardRef<HTMLAnchorElement | HTMLButtonElement, SiteButtonProps>(
31
+ function SiteButton({ variant = "primary", href, className, children, ...rest }, ref) {
32
+ const { buttonRecipe } = useSiteStructural();
33
+ const density = buttonRecipe?.variants[variant].density;
34
+ const modifierClass = buttonRecipe?.variants[variant].modifierClass;
35
+ const classes = cn(variantClass(variant), modifierClass, className);
36
+
37
+ if (href != null) {
38
+ const anchorProps = rest as Omit<AnchorHTMLAttributes<HTMLAnchorElement>, keyof SiteButtonBaseProps>;
39
+ return (
40
+ <a
41
+ ref={ref as React.Ref<HTMLAnchorElement>}
42
+ href={href}
43
+ className={classes}
44
+ data-density={density}
45
+ {...anchorProps}
46
+ >
47
+ {children}
48
+ </a>
49
+ );
50
+ }
51
+
52
+ const buttonProps = rest as Omit<ButtonHTMLAttributes<HTMLButtonElement>, keyof SiteButtonBaseProps>;
53
+ return (
54
+ <button
55
+ ref={ref as React.Ref<HTMLButtonElement>}
56
+ type={buttonProps.type ?? "button"}
57
+ className={classes}
58
+ data-density={density}
59
+ {...buttonProps}
60
+ >
61
+ {children}
62
+ </button>
63
+ );
64
+ },
65
+ );
@@ -0,0 +1,46 @@
1
+ import type { AnchorHTMLAttributes, HTMLAttributes, ReactNode } from 'react';
2
+ import { cn } from '@/lib/utils';
3
+
4
+ type SiteCardBaseProps = {
5
+ title?: ReactNode;
6
+ children?: ReactNode;
7
+ className?: string;
8
+ /** Opt non-link cards into the skin hover lift (anchor cards get it automatically). */
9
+ interactive?: boolean;
10
+ };
11
+
12
+ type SiteCardProps =
13
+ | (SiteCardBaseProps & { href: string } & Omit<AnchorHTMLAttributes<HTMLAnchorElement>, keyof SiteCardBaseProps | 'href'>)
14
+ | (SiteCardBaseProps & { href?: undefined } & Omit<HTMLAttributes<HTMLDivElement>, keyof SiteCardBaseProps>);
15
+
16
+ /**
17
+ * Hosted-site card surface — radius / border / shadow / bg all skin-driven via `.site-card`.
18
+ * Default padding is `p-6`; override with `className` (twMerge wins, e.g. `p-0` for edge-to-edge media).
19
+ */
20
+ export function SiteCard({ title, children, className, href, interactive, ...rest }: SiteCardProps) {
21
+ const classes = cn('site-card flex flex-col', 'p-6', className);
22
+ const content = (
23
+ <>
24
+ {title ? <p className="site-type-sm mb-1 font-semibold">{title}</p> : null}
25
+ {children}
26
+ </>
27
+ );
28
+
29
+ if (href != null) {
30
+ return (
31
+ <a href={href} className={classes} {...(rest as AnchorHTMLAttributes<HTMLAnchorElement>)}>
32
+ {content}
33
+ </a>
34
+ );
35
+ }
36
+
37
+ return (
38
+ <div
39
+ className={classes}
40
+ data-interactive={interactive ? 'true' : undefined}
41
+ {...(rest as HTMLAttributes<HTMLDivElement>)}
42
+ >
43
+ {content}
44
+ </div>
45
+ );
46
+ }
@@ -0,0 +1,56 @@
1
+ 'use client';
2
+
3
+ import {
4
+ codeBlockHasContent,
5
+ parseCodeBlock,
6
+ type CodeBlockLanguage,
7
+ } from '@/lib/codeBlock';
8
+ import { cn } from '@/lib/utils';
9
+
10
+ type Props = {
11
+ raw: string;
12
+ className?: string;
13
+ };
14
+
15
+ const LANGUAGE_LABELS: Record<CodeBlockLanguage, string> = {
16
+ plain: 'Plain',
17
+ typescript: 'TypeScript',
18
+ javascript: 'JavaScript',
19
+ tsx: 'TSX',
20
+ jsx: 'JSX',
21
+ python: 'Python',
22
+ bash: 'Bash',
23
+ html: 'HTML',
24
+ css: 'CSS',
25
+ json: 'JSON',
26
+ sql: 'SQL',
27
+ };
28
+
29
+ export function SiteCodeBlock({ raw, className }: Props) {
30
+ if (!codeBlockHasContent(raw)) return null;
31
+ const parsed = parseCodeBlock(raw);
32
+ if (!parsed.ok) return null;
33
+ const { language, code } = parsed.value;
34
+ return (
35
+ <div className={cn('relative', className)}>
36
+ <span
37
+ className="absolute right-2 top-2 z-10 rounded px-1.5 py-0.5 font-mono text-[10px] uppercase tracking-wide"
38
+ style={{ color: 'var(--muted-foreground)', background: 'var(--background)' }}
39
+ >
40
+ {LANGUAGE_LABELS[language]}
41
+ </span>
42
+ <pre
43
+ className="overflow-x-auto font-mono text-sm leading-relaxed"
44
+ style={{
45
+ background: 'var(--code-block-bg, var(--muted))',
46
+ border: '1px solid var(--code-block-border, var(--border))',
47
+ color: 'var(--code-block-text, var(--foreground))',
48
+ borderRadius: 'var(--code-block-radius, var(--radius))',
49
+ padding: 'var(--code-block-padding, 1rem)',
50
+ }}
51
+ >
52
+ <code className="whitespace-pre-wrap break-words">{code}</code>
53
+ </pre>
54
+ </div>
55
+ );
56
+ }
@@ -0,0 +1,50 @@
1
+ import type { ReactNode } from 'react';
2
+ import { cn } from '@/lib/utils';
3
+
4
+ export type SiteHeadingLevel = 'hero' | 'display' | 'title' | 'heading';
5
+ export type SiteHeadingAlign = 'inherit' | 'center' | 'start';
6
+
7
+ const LEVEL_CLASS: Record<SiteHeadingLevel, string> = {
8
+ hero: 'site-type-hero',
9
+ display: 'site-type-display',
10
+ title: 'site-type-title',
11
+ heading: 'site-type-heading',
12
+ };
13
+
14
+ const ALIGN_CLASS: Record<Exclude<SiteHeadingAlign, 'inherit'>, string> = {
15
+ center: 'text-center',
16
+ start: 'text-left',
17
+ };
18
+
19
+ type Props = {
20
+ level?: SiteHeadingLevel;
21
+ /** 'inherit' lets the skin drive alignment via --heading-align (display only). */
22
+ align?: SiteHeadingAlign;
23
+ as?: 'h1' | 'h2' | 'h3' | 'h4';
24
+ children: ReactNode;
25
+ className?: string;
26
+ };
27
+
28
+ /** Hosted-site heading — fluid type + skin alignment via .site-comparison-heading or explicit align. */
29
+ export function SiteHeading({
30
+ level = 'display',
31
+ align = 'inherit',
32
+ as: Tag = 'h2',
33
+ children,
34
+ className,
35
+ }: Props) {
36
+ const alignClass =
37
+ align === 'inherit'
38
+ ? level === 'display'
39
+ ? 'site-comparison-heading'
40
+ : undefined
41
+ : ALIGN_CLASS[align];
42
+
43
+ return (
44
+ <Tag
45
+ className={cn(LEVEL_CLASS[level], 'font-bold leading-tight', alignClass, className)}
46
+ >
47
+ {children}
48
+ </Tag>
49
+ );
50
+ }
@@ -0,0 +1,71 @@
1
+ import type { ReactNode } from 'react';
2
+ import { cn } from '@/lib/utils';
3
+
4
+ export type SiteMobileSliderSize = 'default' | 'compact' | 'wide';
5
+
6
+ const SLIDE_WIDTH: Record<SiteMobileSliderSize, string> = {
7
+ default: 'w-[min(88cqw,22rem)]',
8
+ compact: 'w-[min(72cqw,11.5rem)]',
9
+ wide: 'w-[min(92cqw,26rem)]',
10
+ };
11
+
12
+ type SliderProps = {
13
+ children: ReactNode;
14
+ /** Grid classes from the @md/site breakpoint upward. */
15
+ desktopClass: string;
16
+ className?: string;
17
+ gapClass?: string;
18
+ };
19
+
20
+ /** Horizontal scroll-snap rail on narrow viewports; grid (or flex) from @md/site up. */
21
+ export function SiteMobileSlider({
22
+ children,
23
+ desktopClass,
24
+ className,
25
+ gapClass = 'gap-4 @md/site:gap-6',
26
+ }: SliderProps) {
27
+ return (
28
+ <div
29
+ className={cn(
30
+ 'site-mobile-slider -mx-[var(--site-px)] px-[var(--site-px)] @md/site:mx-0 @md/site:px-0',
31
+ className,
32
+ )}
33
+ >
34
+ <div
35
+ className={cn(
36
+ 'flex overflow-x-auto overscroll-x-contain scroll-smooth snap-x snap-mandatory pb-2',
37
+ gapClass,
38
+ '[scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden',
39
+ '@md/site:grid @md/site:overflow-visible @md/site:snap-none @md/site:pb-0',
40
+ desktopClass,
41
+ )}
42
+ >
43
+ {children}
44
+ </div>
45
+ </div>
46
+ );
47
+ }
48
+
49
+ type SlideProps = {
50
+ children: ReactNode;
51
+ size?: SiteMobileSliderSize;
52
+ className?: string;
53
+ };
54
+
55
+ export function SiteMobileSliderSlide({
56
+ children,
57
+ size = 'default',
58
+ className,
59
+ }: SlideProps) {
60
+ return (
61
+ <div
62
+ className={cn(
63
+ 'shrink-0 snap-start snap-always @md/site:w-auto @md/site:min-w-0 @md/site:shrink',
64
+ SLIDE_WIDTH[size],
65
+ className,
66
+ )}
67
+ >
68
+ {children}
69
+ </div>
70
+ );
71
+ }