uniweb 0.2.43 → 0.2.44

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/README.md CHANGED
@@ -125,6 +125,52 @@ export function Hero({ content, params }) {
125
125
 
126
126
  Standard React. Standard Tailwind. The `{ content, params }` interface is only for _exposed_ components—the ones content creators select in markdown frontmatter. Internal components use regular React props.
127
127
 
128
+ ## Next Steps
129
+
130
+ After creating your project:
131
+
132
+ 1. **Explore the structure** — Browse `site/pages/` to see how content is organized. Each page folder contains `page.yml` (metadata) and `.md` files (sections).
133
+
134
+ 2. **Generate component docs** — Run `pnpm uniweb docs` to create `COMPONENTS.md` with all available components, their parameters, and presets.
135
+
136
+ 3. **Learn the configuration** — Run `uniweb docs site` or `uniweb docs page` for quick reference on configuration options.
137
+
138
+ 4. **Create a component** — Add a folder in `foundation/src/components/`, create `index.jsx` and `meta.js`, then rebuild. See the [meta.js guide](https://github.com/uniweb/cli/blob/main/docs/meta/README.md) for the full schema.
139
+
140
+ The `meta.js` file defines what content and parameters a component accepts. The runtime uses this metadata to apply defaults and guarantee content structure—no defensive null checks needed in your component code.
141
+
142
+ ### Your First Content Change
143
+
144
+ Open `site/pages/home/1-hero.md` and edit the headline:
145
+
146
+ ```markdown
147
+ ---
148
+ type: Hero
149
+ ---
150
+
151
+ # Your New Headline Here
152
+
153
+ Updated description text.
154
+
155
+ [Get Started](/about)
156
+ ```
157
+
158
+ Save and see the change instantly in your browser.
159
+
160
+ ### Your First Component Change
161
+
162
+ Open `foundation/src/components/Hero/index.jsx`. The component receives parsed content:
163
+
164
+ ```jsx
165
+ export function Hero({ content, params }) {
166
+ const { title } = content.main.header // "Your New Headline Here"
167
+ const { paragraphs } = content.main.body // ["Updated description text."]
168
+ // Edit the JSX below...
169
+ }
170
+ ```
171
+
172
+ Change the JSX, save, and the dev server hot-reloads your changes.
173
+
128
174
  ## Foundations Are Portable
129
175
 
130
176
  The `foundation/` folder ships with your project as a convenience, but a foundation is a self-contained artifact with no dependency on any specific site. Sites reference foundations by configuration, not by folder proximity.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uniweb",
3
- "version": "0.2.43",
3
+ "version": "0.2.44",
4
4
  "description": "Create structured Vite + React sites with content/code separation",
5
5
  "type": "module",
6
6
  "bin": {
@@ -37,9 +37,9 @@
37
37
  "js-yaml": "^4.1.0",
38
38
  "prompts": "^2.4.2",
39
39
  "tar": "^7.0.0",
40
- "@uniweb/build": "0.1.24",
41
- "@uniweb/kit": "0.1.6",
40
+ "@uniweb/build": "0.1.25",
42
41
  "@uniweb/runtime": "0.2.12",
43
- "@uniweb/core": "0.1.11"
42
+ "@uniweb/core": "0.1.11",
43
+ "@uniweb/kit": "0.1.7"
44
44
  }
45
45
  }
@@ -0,0 +1,67 @@
1
+ ## Configuration Reference
2
+
3
+ ### site.yml
4
+
5
+ Site-wide configuration in `site/site.yml`:
6
+
7
+ ```yaml
8
+ name: My Site # Site name
9
+ defaultLanguage: en # Default locale code
10
+ foundation: foundation # Foundation package name
11
+
12
+ # Page ordering (controls top-level navigation)
13
+ pages: [home, about, features] # First is homepage at /
14
+ # Or just name the homepage:
15
+ index: home
16
+
17
+ # Internationalization
18
+ i18n:
19
+ locales: [es, fr] # Non-default locales to build
20
+ localesDir: locales # Translation files directory
21
+
22
+ # Build options
23
+ build:
24
+ prerender: true # Enable static site generation
25
+ ```
26
+
27
+ ### page.yml
28
+
29
+ Page-level configuration in `site/pages/[page]/page.yml`:
30
+
31
+ ```yaml
32
+ title: About Us # Page title (used in <title> and nav)
33
+ description: Learn about us # Meta description
34
+ label: About # Short nav label (optional)
35
+ order: 2 # Navigation sort order
36
+
37
+ # Child page ordering
38
+ pages: [intro, guide, reference] # First is index for this route
39
+ index: intro # Or just name the index
40
+
41
+ # Navigation visibility
42
+ hidden: true # Hide from all navigation
43
+ hideInHeader: true # Hide from header only
44
+ hideInFooter: true # Hide from footer only
45
+
46
+ # Layout overrides
47
+ layout:
48
+ header: false # Don't render header
49
+ footer: false # Don't render footer
50
+
51
+ # Section ordering
52
+ sections: # Explicit section order
53
+ - hero
54
+ - features: # Nested = subsections
55
+ - logocloud
56
+ - stats
57
+ - pricing
58
+
59
+ # SEO
60
+ seo:
61
+ noindex: true
62
+ image: /og-image.png
63
+ changefreq: monthly
64
+ priority: 0.8
65
+ ```
66
+
67
+ Run `pnpm uniweb docs site` or `pnpm uniweb docs page` for complete reference.
@@ -1,10 +1,14 @@
1
1
  /**
2
2
  * Docs Command
3
3
  *
4
- * Generates markdown documentation from foundation schema.
4
+ * Generates markdown documentation from foundation schema and
5
+ * provides configuration references.
5
6
  *
6
7
  * Usage:
7
- * uniweb docs # Generate docs for current directory
8
+ * uniweb docs # Generate COMPONENTS.md
9
+ * uniweb docs site # Show site.yml reference
10
+ * uniweb docs page # Show page.yml reference
11
+ * uniweb docs meta # Show component meta.js reference
8
12
  * uniweb docs --output README.md # Custom output filename
9
13
  * uniweb docs --from-source # Build schema from source (no build required)
10
14
  * uniweb docs --target <path> # Specify foundation directory explicitly
@@ -53,6 +57,195 @@ function info(message) {
53
57
  console.log(`${colors.cyan}→${colors.reset} ${message}`)
54
58
  }
55
59
 
60
+ // =============================================================================
61
+ // Reference Content
62
+ // =============================================================================
63
+
64
+ const SITE_REFERENCE = `
65
+ ${colors.cyan}${colors.bright}site.yml Reference${colors.reset}
66
+
67
+ Site-wide configuration for your Uniweb project.
68
+
69
+ ${colors.bright}Core Settings:${colors.reset}
70
+ ${colors.cyan}name${colors.reset} Site name (used in metadata and browser tab)
71
+ ${colors.cyan}defaultLanguage${colors.reset} Default locale code (default: "en")
72
+ ${colors.cyan}foundation${colors.reset} Foundation package name ("foundation" for local)
73
+
74
+ ${colors.bright}Page Ordering:${colors.reset}
75
+ ${colors.cyan}pages${colors.reset} Array of page folder names
76
+ First item becomes homepage at /
77
+ Example: [home, about, docs, pricing]
78
+ ${colors.cyan}index${colors.reset} Alternative: just name the homepage
79
+ Rest are auto-discovered
80
+
81
+ ${colors.bright}Internationalization:${colors.reset}
82
+ ${colors.cyan}i18n.locales${colors.reset} Locales to build (array or "*" for all)
83
+ Example: [es, fr, de]
84
+ ${colors.cyan}i18n.localesDir${colors.reset} Translation files directory (default: "locales")
85
+
86
+ ${colors.bright}Build Options:${colors.reset}
87
+ ${colors.cyan}build.prerender${colors.reset} Enable static HTML generation (default: false)
88
+ Generates SEO-friendly static pages
89
+
90
+ ${colors.bright}Example:${colors.reset}
91
+ ${colors.dim}name: My Site
92
+ defaultLanguage: en
93
+ foundation: foundation
94
+ pages: [home, about, docs]
95
+ i18n:
96
+ locales: [es, fr]
97
+ build:
98
+ prerender: true${colors.reset}
99
+
100
+ ${colors.dim}Schema: https://raw.githubusercontent.com/uniweb/cli/main/schemas/site.schema.json${colors.reset}
101
+ `
102
+
103
+ const PAGE_REFERENCE = `
104
+ ${colors.cyan}${colors.bright}page.yml Reference${colors.reset}
105
+
106
+ Page-level configuration in site/pages/[page]/page.yml
107
+
108
+ ${colors.bright}Basic Metadata:${colors.reset}
109
+ ${colors.cyan}title${colors.reset} Page title (browser tab, nav, SEO)
110
+ ${colors.cyan}description${colors.reset} Meta description for SEO
111
+ ${colors.cyan}label${colors.reset} Short nav label (defaults to title)
112
+ ${colors.cyan}order${colors.reset} Navigation sort order (lower = first)
113
+
114
+ ${colors.bright}Child Page Ordering:${colors.reset}
115
+ ${colors.cyan}pages${colors.reset} Array of child page names
116
+ First becomes index for this route
117
+ ${colors.cyan}index${colors.reset} Alternative: just name the index page
118
+
119
+ ${colors.bright}Navigation Visibility:${colors.reset}
120
+ ${colors.cyan}hidden${colors.reset} Hide from all navigation (page still exists)
121
+ ${colors.cyan}hideInHeader${colors.reset} Hide from header nav only
122
+ ${colors.cyan}hideInFooter${colors.reset} Hide from footer nav only
123
+
124
+ ${colors.bright}Layout Overrides:${colors.reset}
125
+ ${colors.cyan}layout.header${colors.reset} Show header on this page (default: true)
126
+ ${colors.cyan}layout.footer${colors.reset} Show footer on this page (default: true)
127
+ ${colors.cyan}layout.leftPanel${colors.reset} Show left sidebar (default: true)
128
+ ${colors.cyan}layout.rightPanel${colors.reset} Show right sidebar (default: true)
129
+
130
+ ${colors.bright}Section Control:${colors.reset}
131
+ ${colors.cyan}sections${colors.reset} "*" for auto-discover, or explicit array
132
+ Nested arrays create subsections:
133
+ - hero
134
+ - features:
135
+ - logocloud
136
+ - stats
137
+
138
+ ${colors.bright}SEO Options:${colors.reset}
139
+ ${colors.cyan}seo.noindex${colors.reset} Prevent search engine indexing
140
+ ${colors.cyan}seo.image${colors.reset} Open Graph image URL
141
+ ${colors.cyan}seo.changefreq${colors.reset} Sitemap hint (daily, weekly, monthly...)
142
+ ${colors.cyan}seo.priority${colors.reset} Sitemap priority (0.0 to 1.0)
143
+
144
+ ${colors.bright}Example:${colors.reset}
145
+ ${colors.dim}title: About Us
146
+ description: Learn about our company
147
+ order: 2
148
+ hideInFooter: true
149
+ layout:
150
+ rightPanel: false
151
+ seo:
152
+ image: /about-og.png${colors.reset}
153
+
154
+ ${colors.dim}Schema: https://raw.githubusercontent.com/uniweb/cli/main/schemas/page.schema.json${colors.reset}
155
+ `
156
+
157
+ const META_REFERENCE = `
158
+ ${colors.cyan}${colors.bright}Component meta.js Reference${colors.reset}
159
+
160
+ Component metadata in foundation/src/components/[Name]/meta.js
161
+
162
+ ${colors.bright}Identity:${colors.reset}
163
+ ${colors.cyan}title${colors.reset} Display name in editor
164
+ ${colors.cyan}description${colors.reset} What the component does
165
+ ${colors.cyan}category${colors.reset} Grouping: "impact", "showcase", "structure"
166
+ ${colors.cyan}purpose${colors.reset} Single verb: Introduce, Express, Explain
167
+ ${colors.cyan}hidden${colors.reset} If true, not selectable in frontmatter
168
+
169
+ ${colors.bright}Content Expectations:${colors.reset}
170
+ ${colors.cyan}content${colors.reset} Object describing expected markdown structure
171
+ Keys: title, pretitle, subtitle, paragraphs, links, items
172
+ Values: "Description [count]"
173
+ Count: [1], [1-3], [2+]
174
+
175
+ ${colors.bright}Parameters:${colors.reset}
176
+ ${colors.cyan}params${colors.reset} Object of configurable parameters
177
+ Each param has: type, label, options, default
178
+ Types: "select", "boolean", "string", "number"
179
+
180
+ ${colors.bright}Presets:${colors.reset}
181
+ ${colors.cyan}presets${colors.reset} Named parameter combinations
182
+ Each preset: { label, params: {...} }
183
+
184
+ ${colors.bright}Special:${colors.reset}
185
+ ${colors.cyan}background${colors.reset} true if component supports background images
186
+ ${colors.cyan}data${colors.reset} Dynamic data binding ("articles", "events:5")
187
+
188
+ ${colors.bright}Example:${colors.reset}
189
+ ${colors.dim}export default {
190
+ title: 'Hero Banner',
191
+ description: 'Bold hero section with headline and CTA',
192
+ category: 'impact',
193
+ background: true,
194
+
195
+ content: {
196
+ pretitle: 'Eyebrow text',
197
+ title: 'Headline',
198
+ paragraphs: 'Description [1-2]',
199
+ links: 'CTA buttons [1-2]',
200
+ },
201
+
202
+ params: {
203
+ theme: {
204
+ type: 'select',
205
+ options: ['gradient', 'glass', 'dark'],
206
+ default: 'gradient',
207
+ },
208
+ layout: {
209
+ type: 'select',
210
+ options: ['center', 'left', 'split'],
211
+ default: 'center',
212
+ },
213
+ },
214
+
215
+ presets: {
216
+ default: { label: 'Centered', params: { theme: 'gradient', layout: 'center' } },
217
+ minimal: { label: 'Minimal', params: { theme: 'light', layout: 'left' } },
218
+ },
219
+ }${colors.reset}
220
+
221
+ ${colors.bright}Runtime Benefits:${colors.reset}
222
+ - Content structure is guaranteed (no null checks needed)
223
+ - Param defaults are applied automatically
224
+ - Components receive clean { content, params } props
225
+
226
+ ${colors.dim}Full guide: https://github.com/uniweb/cli/blob/main/docs/meta/README.md${colors.reset}
227
+ `
228
+
229
+ // =============================================================================
230
+ // Subcommand Handlers
231
+ // =============================================================================
232
+
233
+ function showSiteReference() {
234
+ log(SITE_REFERENCE)
235
+ }
236
+
237
+ function showPageReference() {
238
+ log(PAGE_REFERENCE)
239
+ }
240
+
241
+ function showMetaReference() {
242
+ log(META_REFERENCE)
243
+ }
244
+
245
+ // =============================================================================
246
+ // Original Docs Functionality
247
+ // =============================================================================
248
+
56
249
  /**
57
250
  * Parse command line arguments
58
251
  */
@@ -85,25 +278,32 @@ function parseArgs(args) {
85
278
  */
86
279
  function showHelp() {
87
280
  log(`
88
- ${colors.bright}uniweb docs${colors.reset} - Generate component documentation
281
+ ${colors.bright}uniweb docs${colors.reset} - Documentation and configuration references
89
282
 
90
283
  ${colors.dim}Usage:${colors.reset}
91
284
  uniweb docs Generate COMPONENTS.md
92
- uniweb docs --output DOCS.md Custom output filename
93
- uniweb docs --from-source Build schema from source (no build required)
94
- uniweb docs --target foundation Specify foundation directory explicitly
285
+ uniweb docs site Show site.yml configuration reference
286
+ uniweb docs page Show page.yml configuration reference
287
+ uniweb docs meta Show component meta.js reference
95
288
 
96
- ${colors.dim}Options:${colors.reset}
289
+ ${colors.dim}Generation Options:${colors.reset}
97
290
  -o, --output <file> Output filename (default: COMPONENTS.md)
98
291
  -s, --from-source Read meta.js files directly instead of schema.json
99
292
  -t, --target <path> Foundation directory (auto-detected if not specified)
100
293
  -h, --help Show this help message
101
294
 
295
+ ${colors.dim}Examples:${colors.reset}
296
+ uniweb docs Generate component docs
297
+ uniweb docs site Quick reference for site.yml options
298
+ uniweb docs page Quick reference for page.yml options
299
+ uniweb docs meta Learn about component meta.js schema
300
+ uniweb docs --output DOCS.md Custom output filename
301
+ uniweb docs --from-source Generate without building first
302
+
102
303
  ${colors.dim}Notes:${colors.reset}
103
304
  Run from a foundation directory to generate docs there.
104
- Run from a site directory to auto-detect the linked foundation
105
- and generate docs in the site folder for convenience.
106
- Run from workspace root to auto-detect foundations (prompts if multiple).
305
+ Run from a site directory to auto-detect the linked foundation.
306
+ Run from workspace root to auto-detect foundations.
107
307
  `)
108
308
  }
109
309
 
@@ -158,16 +358,11 @@ async function resolveFoundationFromSite(siteDir) {
158
358
  }
159
359
 
160
360
  /**
161
- * Main docs command
361
+ * Generate component documentation (original functionality)
162
362
  */
163
- export async function docs(args) {
363
+ async function generateComponentDocs(args) {
164
364
  const options = parseArgs(args)
165
365
 
166
- if (options.help) {
167
- showHelp()
168
- return
169
- }
170
-
171
366
  const projectDir = resolve(process.cwd())
172
367
  let foundationDir = projectDir
173
368
  let outputDir = projectDir
@@ -254,3 +449,40 @@ export async function docs(args) {
254
449
  process.exit(1)
255
450
  }
256
451
  }
452
+
453
+ // =============================================================================
454
+ // Main Command Entry Point
455
+ // =============================================================================
456
+
457
+ /**
458
+ * Main docs command - handles subcommands and generates documentation
459
+ */
460
+ export async function docs(args) {
461
+ // Check for subcommand as first argument
462
+ const firstArg = args[0]
463
+
464
+ // Handle reference subcommands
465
+ if (firstArg === 'site') {
466
+ showSiteReference()
467
+ return
468
+ }
469
+
470
+ if (firstArg === 'page') {
471
+ showPageReference()
472
+ return
473
+ }
474
+
475
+ if (firstArg === 'meta') {
476
+ showMetaReference()
477
+ return
478
+ }
479
+
480
+ // Handle help
481
+ if (firstArg === '--help' || firstArg === '-h') {
482
+ showHelp()
483
+ return
484
+ }
485
+
486
+ // Default: generate component documentation
487
+ await generateComponentDocs(args)
488
+ }
package/src/index.js CHANGED
@@ -341,6 +341,12 @@ ${colors.bright}Build Options:${colors.reset}
341
341
 
342
342
  Pre-rendering is enabled by default when build.prerender: true in site.yml
343
343
 
344
+ ${colors.bright}Docs Subcommands:${colors.reset}
345
+ docs Generate COMPONENTS.md from foundation schema
346
+ docs site Show site.yml configuration reference
347
+ docs page Show page.yml configuration reference
348
+ docs meta Show component meta.js reference
349
+
344
350
  ${colors.bright}Docs Options:${colors.reset}
345
351
  --output <file> Output filename (default: COMPONENTS.md)
346
352
  --from-source Read meta.js files directly instead of schema.json
@@ -0,0 +1,6 @@
1
+ {
2
+ "yaml.schemas": {
3
+ "https://raw.githubusercontent.com/uniweb/cli/main/schemas/site.schema.json": "**/site.yml",
4
+ "https://raw.githubusercontent.com/uniweb/cli/main/schemas/page.schema.json": "**/page.yml"
5
+ }
6
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "yaml.schemas": {
3
+ "https://raw.githubusercontent.com/uniweb/cli/main/schemas/site.schema.json": "site/site.yml",
4
+ "https://raw.githubusercontent.com/uniweb/cli/main/schemas/page.schema.json": "**/page.yml"
5
+ }
6
+ }