@sigx/ssg 0.1.6

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 (70) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +358 -0
  3. package/dist/build.d.ts +17 -0
  4. package/dist/build.d.ts.map +1 -0
  5. package/dist/build.js +309 -0
  6. package/dist/build.js.map +1 -0
  7. package/dist/cli.d.ts +3 -0
  8. package/dist/cli.d.ts.map +1 -0
  9. package/dist/cli.js +62 -0
  10. package/dist/cli.js.map +1 -0
  11. package/dist/client.d.ts +28 -0
  12. package/dist/client.d.ts.map +1 -0
  13. package/dist/client.js +38 -0
  14. package/dist/client.js.map +1 -0
  15. package/dist/config.d.ts +33 -0
  16. package/dist/config.d.ts.map +1 -0
  17. package/dist/dev.d.ts +43 -0
  18. package/dist/dev.d.ts.map +1 -0
  19. package/dist/dev.js +71 -0
  20. package/dist/dev.js.map +1 -0
  21. package/dist/errors.d.ts +58 -0
  22. package/dist/errors.d.ts.map +1 -0
  23. package/dist/index.d.ts +14 -0
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +58 -0
  26. package/dist/index.js.map +1 -0
  27. package/dist/layouts/index.d.ts +7 -0
  28. package/dist/layouts/index.d.ts.map +1 -0
  29. package/dist/layouts/resolver.d.ts +49 -0
  30. package/dist/layouts/resolver.d.ts.map +1 -0
  31. package/dist/layouts/virtual.d.ts +34 -0
  32. package/dist/layouts/virtual.d.ts.map +1 -0
  33. package/dist/mdx/frontmatter.d.ts +42 -0
  34. package/dist/mdx/frontmatter.d.ts.map +1 -0
  35. package/dist/mdx/index.d.ts +9 -0
  36. package/dist/mdx/index.d.ts.map +1 -0
  37. package/dist/mdx/plugin.d.ts +32 -0
  38. package/dist/mdx/plugin.d.ts.map +1 -0
  39. package/dist/mdx/rehype-headings.d.ts +39 -0
  40. package/dist/mdx/rehype-headings.d.ts.map +1 -0
  41. package/dist/mdx/shiki.d.ts +32 -0
  42. package/dist/mdx/shiki.d.ts.map +1 -0
  43. package/dist/plugin-DxH1VUGC.js +547 -0
  44. package/dist/plugin-DxH1VUGC.js.map +1 -0
  45. package/dist/routing/index.d.ts +12 -0
  46. package/dist/routing/index.d.ts.map +1 -0
  47. package/dist/routing/navigation.d.ts +44 -0
  48. package/dist/routing/navigation.d.ts.map +1 -0
  49. package/dist/routing/resolver.d.ts +66 -0
  50. package/dist/routing/resolver.d.ts.map +1 -0
  51. package/dist/routing/scanner.d.ts +60 -0
  52. package/dist/routing/scanner.d.ts.map +1 -0
  53. package/dist/routing/virtual-navigation.d.ts +39 -0
  54. package/dist/routing/virtual-navigation.d.ts.map +1 -0
  55. package/dist/routing/virtual.d.ts +28 -0
  56. package/dist/routing/virtual.d.ts.map +1 -0
  57. package/dist/sitemap.d.ts +55 -0
  58. package/dist/sitemap.d.ts.map +1 -0
  59. package/dist/types.d.ts +562 -0
  60. package/dist/types.d.ts.map +1 -0
  61. package/dist/virtual-entries-Bz97SKQ0.js +1053 -0
  62. package/dist/virtual-entries-Bz97SKQ0.js.map +1 -0
  63. package/dist/vite/index.d.ts +6 -0
  64. package/dist/vite/index.d.ts.map +1 -0
  65. package/dist/vite/plugin.d.ts +35 -0
  66. package/dist/vite/plugin.d.ts.map +1 -0
  67. package/dist/vite/plugin.js +3 -0
  68. package/dist/vite/virtual-entries.d.ts +59 -0
  69. package/dist/vite/virtual-entries.d.ts.map +1 -0
  70. package/package.json +92 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Andreas Ekdahl
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,358 @@
1
+ # @sigx/ssg
2
+
3
+ Static Site Generator for SignalX with file-based routing, MDX support, and pluggable themes.
4
+
5
+ ## Features
6
+
7
+ - 🗂 **File-based routing** - Pages in `src/pages/` become routes automatically
8
+ - 📑 **Layout system** - Wrap pages with reusable layouts
9
+ - 📝 **MDX support** - Write content with Markdown and SignalX components
10
+ - 🎨 **Pluggable themes** - Install theme packages or create your own
11
+ - **Vite HMR** - Instant updates during development
12
+ - ⚡ **Fast builds** - Parallel rendering with streaming
13
+ - 🚀 **Zero-config mode** - Works out of the box with sensible defaults
14
+ - 🗺️ **Sitemap generation** - Automatic sitemap.xml and robots.txt
15
+ - 🛠️ **CLI tools** - `ssg dev`, `ssg build`, and `ssg preview` commands
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ npm install @sigx/ssg sigx @sigx/router vite
21
+ ```
22
+
23
+ ## Quick Start
24
+
25
+ ### Zero-config mode
26
+
27
+ The simplest way to get started - just create pages and run:
28
+
29
+ ```bash
30
+ # Create a page
31
+ mkdir -p src/pages
32
+ echo 'export default () => <h1>Hello World</h1>' > src/pages/index.tsx
33
+
34
+ # Start development
35
+ npx ssg dev
36
+
37
+ # Build for production
38
+ npx ssg build
39
+ ```
40
+
41
+ ### With configuration
42
+
43
+ Create `ssg.config.ts`:
44
+
45
+ ```ts
46
+ // ssg.config.ts
47
+ import { defineSSGConfig } from '@sigx/ssg';
48
+
49
+ export default defineSSGConfig({
50
+ site: {
51
+ title: 'My Site',
52
+ description: 'Built with SignalX SSG',
53
+ url: 'https://example.com',
54
+ fonts: ['Inter:wght@400;500;600;700'],
55
+ },
56
+ });
57
+ ```
58
+
59
+ ### With custom Vite config (optional)
60
+
61
+ ```ts
62
+ // vite.config.ts
63
+ import { defineConfig } from 'vite';
64
+ import { sigxPlugin } from '@sigx/vite';
65
+ import { ssgPlugin } from '@sigx/ssg/vite';
66
+
67
+ export default defineConfig({
68
+ plugins: [
69
+ sigxPlugin(),
70
+ ssgPlugin(),
71
+ ],
72
+ });
73
+ ```
74
+
75
+ ### Create pages
76
+
77
+ ```tsx
78
+ // src/pages/index.tsx
79
+ import { component } from 'sigx';
80
+
81
+ export default component(() => {
82
+ return () => (
83
+ <div>
84
+ <h1>Welcome to my site!</h1>
85
+ </div>
86
+ );
87
+ });
88
+ ```
89
+
90
+ ### 4. Build
91
+
92
+ ```bash
93
+ npx ssg build
94
+ ```
95
+
96
+ ## File-based Routing
97
+
98
+ Pages in `src/pages/` are automatically converted to routes:
99
+
100
+ | File | Route |
101
+ |------|-------|
102
+ | `src/pages/index.tsx` | `/` |
103
+ | `src/pages/about.tsx` | `/about` |
104
+ | `src/pages/blog/index.tsx` | `/blog` |
105
+ | `src/pages/blog/[slug].tsx` | `/blog/:slug` |
106
+ | `src/pages/docs/[...path].tsx` | `/docs/*path` |
107
+
108
+ ### Dynamic Routes
109
+
110
+ For dynamic routes, export a `getStaticPaths` function:
111
+
112
+ ```tsx
113
+ // src/pages/blog/[slug].tsx
114
+ import { component } from 'sigx';
115
+
116
+ export async function getStaticPaths() {
117
+ // Fetch your data from any source
118
+ const posts = await fetchBlogPosts();
119
+ return posts.map(post => ({
120
+ params: { slug: post.slug },
121
+ props: { post },
122
+ }));
123
+ }
124
+
125
+ export default component(({ props }) => {
126
+ return () => (
127
+ <article>
128
+ <h1>{props.post.data.title}</h1>
129
+ </article>
130
+ );
131
+ });
132
+ ```
133
+
134
+ ## Layouts
135
+
136
+ Create layouts in `src/layouts/`:
137
+
138
+ ```tsx
139
+ // src/layouts/default.tsx
140
+ import { component } from 'sigx';
141
+
142
+ export default component(({ slots, props }) => {
143
+ return () => (
144
+ <div class="layout">
145
+ <header>
146
+ <nav>My Site</nav>
147
+ </header>
148
+ <main>
149
+ {slots.default()}
150
+ </main>
151
+ <footer>© 2024</footer>
152
+ </div>
153
+ );
154
+ });
155
+ ```
156
+
157
+ Specify layout in frontmatter or export:
158
+
159
+ ```mdx
160
+ ---
161
+ title: My Page
162
+ layout: docs
163
+ ---
164
+
165
+ # Content here
166
+ ```
167
+
168
+ Or in TSX:
169
+
170
+ ```tsx
171
+ export const layout = 'docs';
172
+ ```
173
+
174
+ ## MDX
175
+
176
+ Write content with MDX:
177
+
178
+ ```mdx
179
+ ---
180
+ title: Hello World
181
+ date: 2024-01-01
182
+ ---
183
+
184
+ # {frontmatter.title}
185
+
186
+ This is **markdown** with SignalX components!
187
+
188
+ <Counter initial={5} />
189
+ ```
190
+
191
+ ## Themes
192
+
193
+ Install a theme package:
194
+
195
+ ```bash
196
+ npm install @sigx/ssg-theme-daisyui
197
+ ```
198
+
199
+ Configure in ssg.config.ts:
200
+
201
+ ```ts
202
+ export default defineSSGConfig({
203
+ theme: '@sigx/ssg-theme-daisyui',
204
+ });
205
+ ```
206
+
207
+ Themes provide:
208
+ - Pre-built layouts (default, docs, blog, etc.)
209
+ - UI components
210
+ - CSS styles
211
+
212
+ ## Hydration
213
+
214
+ SSG pages are pre-rendered at build time as static HTML. Interactive components are "hydrated" on the client side to become reactive.
215
+
216
+ ### Islands Architecture
217
+
218
+ SignalX SSG supports selective hydration through **islands architecture**. Each interactive component can specify when it should be hydrated using client directives:
219
+
220
+ ```tsx
221
+ import { Counter } from './components/Counter';
222
+
223
+ export default component(() => {
224
+ return () => (
225
+ <div>
226
+ {/* Static content - no JS needed */}
227
+ <h1>Welcome to my site</h1>
228
+
229
+ {/* Interactive islands with different hydration strategies */}
230
+ <Counter client:load />
231
+ <LazyWidget client:idle />
232
+ <OffscreenChart client:visible />
233
+ <MobileMenu client:media="(max-width: 768px)" />
234
+ <BrowserOnlyWidget client:only />
235
+ </div>
236
+ );
237
+ });
238
+ ```
239
+
240
+ ### Hydration Strategies
241
+
242
+ | Directive | When it Hydrates | Use Case |
243
+ |-----------|------------------|----------|
244
+ | `client:load` | Immediately on page load | Critical interactive elements |
245
+ | `client:idle` | When browser is idle (`requestIdleCallback`) | Non-critical interactivity |
246
+ | `client:visible` | When scrolled into viewport (`IntersectionObserver`) | Below-the-fold components |
247
+ | `client:media="query"` | When media query matches | Mobile-only components |
248
+ | `client:only` | Not SSR'd, renders only on client | Browser API dependencies |
249
+
250
+ ### Example: Interactive Counter
251
+
252
+ ```tsx
253
+ // src/components/Counter.tsx
254
+ import { component, signal } from 'sigx';
255
+
256
+ export const Counter = component(() => {
257
+ const count = signal(0);
258
+
259
+ return () => (
260
+ <div class="counter">
261
+ <button onClick={() => count.value--}>-</button>
262
+ <span>{count.value}</span>
263
+ <button onClick={() => count.value++}>+</button>
264
+ </div>
265
+ );
266
+ }, { name: 'Counter' });
267
+ ```
268
+
269
+ ```tsx
270
+ // src/pages/index.tsx
271
+ import { Counter } from '../components/Counter';
272
+
273
+ export default component(() => {
274
+ return () => (
275
+ <main>
276
+ <h1>Counter Demo</h1>
277
+ <Counter client:load />
278
+ </main>
279
+ );
280
+ });
281
+ ```
282
+
283
+ ### How It Works
284
+
285
+ 1. **Build time**: Pages are rendered to static HTML with component markers
286
+ 2. **Page load**: Browser receives pre-rendered HTML (fast First Contentful Paint)
287
+ 3. **Hydration**: JavaScript attaches event handlers and reactivity to existing DOM
288
+ 4. **Interactivity**: Components become fully interactive without re-rendering
289
+
290
+ ### Benefits
291
+
292
+ - **Fast initial load** - HTML is ready immediately, no JavaScript blocking
293
+ - **SEO friendly** - Search engines see full content
294
+ - **Progressive enhancement** - Content is visible before JS loads
295
+ - **Reduced JavaScript** - Only hydrate what needs to be interactive
296
+ - **Fine-grained control** - Choose when each component becomes interactive
297
+
298
+ ## Configuration
299
+
300
+ Full configuration options:
301
+
302
+ ```ts
303
+ defineSSGConfig({
304
+ // Directories
305
+ pages: 'src/pages',
306
+ layouts: 'src/layouts',
307
+ content: 'src/content',
308
+ outDir: 'dist',
309
+
310
+ // Site metadata
311
+ site: {
312
+ title: 'My Site',
313
+ description: 'Site description',
314
+ url: 'https://example.com',
315
+ lang: 'en',
316
+ favicon: '/favicon.ico',
317
+ fonts: ['Inter:wght@400;500;600;700'],
318
+ ogImage: 'https://example.com/og.png',
319
+ twitter: 'myhandle',
320
+ themeColor: '#000000',
321
+ },
322
+
323
+ // Theme
324
+ theme: '@sigx/ssg-theme-daisyui',
325
+ defaultLayout: 'default',
326
+
327
+ // Markdown options
328
+ markdown: {
329
+ shiki: {
330
+ light: 'github-light',
331
+ dark: 'github-dark',
332
+ },
333
+ },
334
+ });
335
+ ```
336
+
337
+ ## CLI
338
+
339
+ ```bash
340
+ # Start development server
341
+ npx ssg dev
342
+
343
+ # Build static site (generates sitemap.xml and robots.txt)
344
+ npx ssg build
345
+
346
+ # Preview production build
347
+ npx ssg preview
348
+
349
+ # With custom config
350
+ npx ssg build --config=./my-config.ts
351
+
352
+ # With options
353
+ npx ssg dev --port=3000 --open
354
+ ```
355
+
356
+ ## License
357
+
358
+ MIT
@@ -0,0 +1,17 @@
1
+ /**
2
+ * SSG Build CLI
3
+ *
4
+ * Static site generation build process:
5
+ * 1. Load configuration
6
+ * 2. Scan routes and expand dynamic paths
7
+ * 3. Build with Vite for production
8
+ * 4. Render each route to static HTML
9
+ * 5. Write output files
10
+ * 6. Generate sitemap and robots.txt
11
+ */
12
+ import type { BuildOptions, BuildResult } from './types';
13
+ /**
14
+ * Build static site
15
+ */
16
+ export declare function build(options?: BuildOptions): Promise<BuildResult>;
17
+ //# sourceMappingURL=build.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAOH,OAAO,KAAK,EAAa,YAAY,EAAE,WAAW,EAAyC,MAAM,SAAS,CAAC;AAc3G;;GAEG;AACH,wBAAsB,KAAK,CAAC,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,WAAW,CAAC,CAwP5E"}