uniweb 0.1.3 → 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 +323 -1
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
|
|
@@ -300,16 +404,46 @@ async function createSite(projectDir, projectName, isWorkspace = false) {
|
|
|
300
404
|
},
|
|
301
405
|
devDependencies: {
|
|
302
406
|
'@vitejs/plugin-react': '^4.2.1',
|
|
407
|
+
autoprefixer: '^10.4.18',
|
|
408
|
+
postcss: '^8.4.35',
|
|
303
409
|
react: '^18.2.0',
|
|
304
410
|
'react-dom': '^18.2.0',
|
|
305
411
|
'react-router-dom': '^6.22.0',
|
|
412
|
+
tailwindcss: '^3.4.1',
|
|
306
413
|
vite: '^5.1.0',
|
|
307
414
|
'vite-plugin-svgr': '^4.2.0',
|
|
308
415
|
},
|
|
309
416
|
})
|
|
310
417
|
|
|
311
|
-
//
|
|
418
|
+
// Foundation import name
|
|
312
419
|
const foundationImport = isWorkspace ? 'foundation' : 'foundation-example'
|
|
420
|
+
|
|
421
|
+
// tailwind.config.js - scan foundation components
|
|
422
|
+
const foundationPath = isWorkspace ? '../foundation' : `./node_modules/${foundationImport}`
|
|
423
|
+
writeFile(join(projectDir, 'tailwind.config.js'), `export default {
|
|
424
|
+
content: ['${foundationPath}/src/**/*.{js,jsx,ts,tsx}'],
|
|
425
|
+
theme: {
|
|
426
|
+
extend: {
|
|
427
|
+
colors: {
|
|
428
|
+
primary: '#3b82f6',
|
|
429
|
+
secondary: '#64748b',
|
|
430
|
+
},
|
|
431
|
+
},
|
|
432
|
+
},
|
|
433
|
+
plugins: [],
|
|
434
|
+
}
|
|
435
|
+
`)
|
|
436
|
+
|
|
437
|
+
// postcss.config.js
|
|
438
|
+
writeFile(join(projectDir, 'postcss.config.js'), `export default {
|
|
439
|
+
plugins: {
|
|
440
|
+
tailwindcss: {},
|
|
441
|
+
autoprefixer: {},
|
|
442
|
+
},
|
|
443
|
+
}
|
|
444
|
+
`)
|
|
445
|
+
|
|
446
|
+
// vite.config.js
|
|
313
447
|
writeFile(join(projectDir, 'vite.config.js'), `import { defineConfig } from 'vite'
|
|
314
448
|
import react from '@vitejs/plugin-react'
|
|
315
449
|
import svgr from 'vite-plugin-svgr'
|
|
@@ -403,6 +537,98 @@ ctaUrl: "#"
|
|
|
403
537
|
Your content goes here.
|
|
404
538
|
`)
|
|
405
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
|
+
|
|
406
632
|
success(`Created site: ${projectName}`)
|
|
407
633
|
}
|
|
408
634
|
|
|
@@ -647,6 +873,102 @@ export default {
|
|
|
647
873
|
}
|
|
648
874
|
`)
|
|
649
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
|
+
|
|
650
972
|
success(`Created foundation: ${projectName}`)
|
|
651
973
|
}
|
|
652
974
|
|