uniweb 0.1.4 → 0.1.5
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/package.json +1 -1
- package/src/index.js +292 -0
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -261,6 +261,110 @@ async function createWorkspace(projectDir, projectName) {
|
|
|
261
261
|
dist
|
|
262
262
|
.DS_Store
|
|
263
263
|
*.local
|
|
264
|
+
`)
|
|
265
|
+
|
|
266
|
+
// README.md
|
|
267
|
+
writeFile(join(projectDir, 'README.md'), `# ${projectName}
|
|
268
|
+
|
|
269
|
+
A Uniweb workspace with a site and foundation for co-development.
|
|
270
|
+
|
|
271
|
+
## Quick Start
|
|
272
|
+
|
|
273
|
+
\`\`\`bash
|
|
274
|
+
pnpm install
|
|
275
|
+
pnpm dev
|
|
276
|
+
\`\`\`
|
|
277
|
+
|
|
278
|
+
Open [http://localhost:3000](http://localhost:3000) to see your site.
|
|
279
|
+
|
|
280
|
+
## Project Structure
|
|
281
|
+
|
|
282
|
+
\`\`\`
|
|
283
|
+
${projectName}/
|
|
284
|
+
├── packages/
|
|
285
|
+
│ ├── site/ # Your website
|
|
286
|
+
│ │ ├── pages/ # Content pages (markdown + YAML)
|
|
287
|
+
│ │ ├── src/ # Site entry point
|
|
288
|
+
│ │ └── vite.config.js
|
|
289
|
+
│ └── foundation/ # Your component library
|
|
290
|
+
│ └── src/
|
|
291
|
+
│ ├── components/ # React components
|
|
292
|
+
│ ├── meta.js # Foundation metadata
|
|
293
|
+
│ └── styles.css # Tailwind styles
|
|
294
|
+
├── package.json
|
|
295
|
+
└── pnpm-workspace.yaml
|
|
296
|
+
\`\`\`
|
|
297
|
+
|
|
298
|
+
## Development
|
|
299
|
+
|
|
300
|
+
### Standard Mode (recommended)
|
|
301
|
+
|
|
302
|
+
\`\`\`bash
|
|
303
|
+
pnpm dev
|
|
304
|
+
\`\`\`
|
|
305
|
+
|
|
306
|
+
Edit components in \`packages/foundation/src/components/\` and see changes instantly via HMR.
|
|
307
|
+
Edit content in \`packages/site/pages/\` to add or modify pages.
|
|
308
|
+
|
|
309
|
+
### Runtime Loading Mode
|
|
310
|
+
|
|
311
|
+
\`\`\`bash
|
|
312
|
+
pnpm dev:runtime
|
|
313
|
+
\`\`\`
|
|
314
|
+
|
|
315
|
+
Tests production behavior where the foundation is loaded as a separate module.
|
|
316
|
+
Use this to debug issues that only appear in production.
|
|
317
|
+
|
|
318
|
+
## Building for Production
|
|
319
|
+
|
|
320
|
+
\`\`\`bash
|
|
321
|
+
# Build both foundation and site
|
|
322
|
+
pnpm build
|
|
323
|
+
\`\`\`
|
|
324
|
+
|
|
325
|
+
Output:
|
|
326
|
+
- \`packages/foundation/dist/\` — Bundled foundation (JS + CSS + schema)
|
|
327
|
+
- \`packages/site/dist/\` — Production-ready site
|
|
328
|
+
|
|
329
|
+
## Adding Components
|
|
330
|
+
|
|
331
|
+
1. Create a new folder in \`packages/foundation/src/components/YourComponent/\`
|
|
332
|
+
2. Add \`index.jsx\` with your React component
|
|
333
|
+
3. Add \`meta.js\` describing the component's content slots and options
|
|
334
|
+
4. Export from \`packages/foundation/src/index.js\`
|
|
335
|
+
|
|
336
|
+
## Adding Pages
|
|
337
|
+
|
|
338
|
+
1. Create a folder in \`packages/site/pages/your-page/\`
|
|
339
|
+
2. Add \`page.yml\` with page metadata
|
|
340
|
+
3. Add markdown files (\`1-section.md\`, \`2-section.md\`, etc.) for each section
|
|
341
|
+
|
|
342
|
+
Each markdown file specifies which component to use:
|
|
343
|
+
|
|
344
|
+
\`\`\`markdown
|
|
345
|
+
---
|
|
346
|
+
component: Hero
|
|
347
|
+
title: Your Title
|
|
348
|
+
subtitle: Your subtitle
|
|
349
|
+
---
|
|
350
|
+
|
|
351
|
+
Optional body content here.
|
|
352
|
+
\`\`\`
|
|
353
|
+
|
|
354
|
+
## What is Uniweb?
|
|
355
|
+
|
|
356
|
+
Uniweb is a **Component Web Platform** that bridges content and components.
|
|
357
|
+
Foundations define the vocabulary (available components, options, design rules).
|
|
358
|
+
Sites provide content that flows through Foundations.
|
|
359
|
+
|
|
360
|
+
Learn more:
|
|
361
|
+
- [Uniweb on GitHub](https://github.com/uniweb)
|
|
362
|
+
- [CLI Documentation](https://github.com/uniweb/cli)
|
|
363
|
+
- [uniweb.app](https://uniweb.app) — Full publishing platform
|
|
364
|
+
|
|
365
|
+
## License
|
|
366
|
+
|
|
367
|
+
MIT
|
|
264
368
|
`)
|
|
265
369
|
|
|
266
370
|
// Create site package
|
|
@@ -433,6 +537,98 @@ ctaUrl: "#"
|
|
|
433
537
|
Your content goes here.
|
|
434
538
|
`)
|
|
435
539
|
|
|
540
|
+
// README.md (only for standalone site, not workspace)
|
|
541
|
+
if (!isWorkspace) {
|
|
542
|
+
writeFile(join(projectDir, 'README.md'), `# ${projectName}
|
|
543
|
+
|
|
544
|
+
A Uniweb site — a content-driven website powered by a Foundation component library.
|
|
545
|
+
|
|
546
|
+
## Quick Start
|
|
547
|
+
|
|
548
|
+
\`\`\`bash
|
|
549
|
+
pnpm install
|
|
550
|
+
pnpm dev
|
|
551
|
+
\`\`\`
|
|
552
|
+
|
|
553
|
+
Open [http://localhost:3000](http://localhost:3000) to see your site.
|
|
554
|
+
|
|
555
|
+
## Project Structure
|
|
556
|
+
|
|
557
|
+
\`\`\`
|
|
558
|
+
${projectName}/
|
|
559
|
+
├── pages/ # Your content
|
|
560
|
+
│ └── home/
|
|
561
|
+
│ ├── page.yml # Page metadata
|
|
562
|
+
│ └── 1-hero.md # Section content
|
|
563
|
+
├── src/
|
|
564
|
+
│ └── main.jsx # Site entry point
|
|
565
|
+
├── site.yml # Site configuration
|
|
566
|
+
├── vite.config.js
|
|
567
|
+
└── package.json
|
|
568
|
+
\`\`\`
|
|
569
|
+
|
|
570
|
+
## Adding Pages
|
|
571
|
+
|
|
572
|
+
1. Create a folder in \`pages/your-page/\`
|
|
573
|
+
2. Add \`page.yml\`:
|
|
574
|
+
|
|
575
|
+
\`\`\`yaml
|
|
576
|
+
title: Your Page Title
|
|
577
|
+
order: 2
|
|
578
|
+
\`\`\`
|
|
579
|
+
|
|
580
|
+
3. Add section files (\`1-hero.md\`, \`2-features.md\`, etc.):
|
|
581
|
+
|
|
582
|
+
\`\`\`markdown
|
|
583
|
+
---
|
|
584
|
+
component: Hero
|
|
585
|
+
title: Section Title
|
|
586
|
+
subtitle: Section subtitle
|
|
587
|
+
---
|
|
588
|
+
|
|
589
|
+
Optional markdown content here.
|
|
590
|
+
\`\`\`
|
|
591
|
+
|
|
592
|
+
## How It Works
|
|
593
|
+
|
|
594
|
+
- Each folder in \`pages/\` becomes a route (\`/home\`, \`/about\`, etc.)
|
|
595
|
+
- Section files are numbered to control order (\`1-*.md\`, \`2-*.md\`)
|
|
596
|
+
- The \`component\` field specifies which Foundation component renders the section
|
|
597
|
+
- Other frontmatter fields become the component's content
|
|
598
|
+
|
|
599
|
+
## Changing the Foundation
|
|
600
|
+
|
|
601
|
+
Edit \`package.json\` to use a different foundation:
|
|
602
|
+
|
|
603
|
+
\`\`\`json
|
|
604
|
+
{
|
|
605
|
+
"dependencies": {
|
|
606
|
+
"@your-org/your-foundation": "^1.0.0"
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
\`\`\`
|
|
610
|
+
|
|
611
|
+
Then update imports in \`src/main.jsx\` and \`vite.config.js\`.
|
|
612
|
+
|
|
613
|
+
## Building for Production
|
|
614
|
+
|
|
615
|
+
\`\`\`bash
|
|
616
|
+
pnpm build
|
|
617
|
+
\`\`\`
|
|
618
|
+
|
|
619
|
+
Output is in \`dist/\` — ready to deploy to any static host.
|
|
620
|
+
|
|
621
|
+
## Learn More
|
|
622
|
+
|
|
623
|
+
- [Uniweb on GitHub](https://github.com/uniweb)
|
|
624
|
+
- [uniweb.app](https://uniweb.app)
|
|
625
|
+
|
|
626
|
+
## License
|
|
627
|
+
|
|
628
|
+
MIT
|
|
629
|
+
`)
|
|
630
|
+
}
|
|
631
|
+
|
|
436
632
|
success(`Created site: ${projectName}`)
|
|
437
633
|
}
|
|
438
634
|
|
|
@@ -677,6 +873,102 @@ export default {
|
|
|
677
873
|
}
|
|
678
874
|
`)
|
|
679
875
|
|
|
876
|
+
// README.md (only for standalone foundation, not workspace)
|
|
877
|
+
if (!isWorkspace) {
|
|
878
|
+
writeFile(join(projectDir, 'README.md'), `# ${projectName}
|
|
879
|
+
|
|
880
|
+
A Uniweb Foundation — a React component library for content-driven websites.
|
|
881
|
+
|
|
882
|
+
## Quick Start
|
|
883
|
+
|
|
884
|
+
\`\`\`bash
|
|
885
|
+
pnpm install
|
|
886
|
+
pnpm dev # Start Vite dev server for component development
|
|
887
|
+
pnpm build # Build for production
|
|
888
|
+
\`\`\`
|
|
889
|
+
|
|
890
|
+
## Project Structure
|
|
891
|
+
|
|
892
|
+
\`\`\`
|
|
893
|
+
${projectName}/
|
|
894
|
+
├── src/
|
|
895
|
+
│ ├── components/ # Your components
|
|
896
|
+
│ │ └── Hero/
|
|
897
|
+
│ │ ├── index.jsx # React component
|
|
898
|
+
│ │ └── meta.js # Component metadata
|
|
899
|
+
│ ├── meta.js # Foundation metadata
|
|
900
|
+
│ ├── index.js # Exports
|
|
901
|
+
│ └── styles.css # Tailwind styles
|
|
902
|
+
├── package.json
|
|
903
|
+
├── vite.config.js
|
|
904
|
+
└── tailwind.config.js
|
|
905
|
+
\`\`\`
|
|
906
|
+
|
|
907
|
+
## Adding Components
|
|
908
|
+
|
|
909
|
+
1. Create \`src/components/YourComponent/index.jsx\`:
|
|
910
|
+
|
|
911
|
+
\`\`\`jsx
|
|
912
|
+
export function YourComponent({ content }) {
|
|
913
|
+
const { title, description } = content
|
|
914
|
+
return (
|
|
915
|
+
<section className="py-12 px-6">
|
|
916
|
+
<h2>{title}</h2>
|
|
917
|
+
<p>{description}</p>
|
|
918
|
+
</section>
|
|
919
|
+
)
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
export default YourComponent
|
|
923
|
+
\`\`\`
|
|
924
|
+
|
|
925
|
+
2. Create \`src/components/YourComponent/meta.js\`:
|
|
926
|
+
|
|
927
|
+
\`\`\`js
|
|
928
|
+
export default {
|
|
929
|
+
title: 'Your Component',
|
|
930
|
+
description: 'What this component does',
|
|
931
|
+
category: 'Content',
|
|
932
|
+
elements: {
|
|
933
|
+
title: { label: 'Title', required: true },
|
|
934
|
+
description: { label: 'Description' },
|
|
935
|
+
},
|
|
936
|
+
}
|
|
937
|
+
\`\`\`
|
|
938
|
+
|
|
939
|
+
3. Export from \`src/index.js\`:
|
|
940
|
+
|
|
941
|
+
\`\`\`js
|
|
942
|
+
export { YourComponent } from './components/YourComponent/index.jsx'
|
|
943
|
+
\`\`\`
|
|
944
|
+
|
|
945
|
+
## Build Output
|
|
946
|
+
|
|
947
|
+
After \`pnpm build\`:
|
|
948
|
+
|
|
949
|
+
\`\`\`
|
|
950
|
+
dist/
|
|
951
|
+
├── foundation.js # Bundled components
|
|
952
|
+
├── assets/style.css # Compiled Tailwind CSS
|
|
953
|
+
└── schema.json # Component metadata for editors
|
|
954
|
+
\`\`\`
|
|
955
|
+
|
|
956
|
+
## What is a Foundation?
|
|
957
|
+
|
|
958
|
+
A Foundation defines the vocabulary for Uniweb sites:
|
|
959
|
+
- **Components** — The building blocks creators can use
|
|
960
|
+
- **Elements** — Content slots (title, description, images, etc.)
|
|
961
|
+
- **Properties** — Configuration options exposed to creators
|
|
962
|
+
- **Presets** — Pre-configured variations of components
|
|
963
|
+
|
|
964
|
+
Learn more at [github.com/uniweb](https://github.com/uniweb)
|
|
965
|
+
|
|
966
|
+
## License
|
|
967
|
+
|
|
968
|
+
MIT
|
|
969
|
+
`)
|
|
970
|
+
}
|
|
971
|
+
|
|
680
972
|
success(`Created foundation: ${projectName}`)
|
|
681
973
|
}
|
|
682
974
|
|