@inglorious/ssx 1.4.3 → 1.4.4
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 +48 -26
- package/package.json +2 -2
- package/src/router/router.test.js +11 -1
package/README.md
CHANGED
|
@@ -30,9 +30,9 @@ SSX takes your entity-based web apps and generates optimized static HTML with fu
|
|
|
30
30
|
- **Hot reload dev server** - See changes instantly
|
|
31
31
|
- **Lazy-loaded routes** - Code splitting automatically
|
|
32
32
|
- **lit-html hydration** - Interactive UI without the bloat
|
|
33
|
-
- **TypeScript
|
|
34
|
-
- **Image
|
|
35
|
-
- **Markdown
|
|
33
|
+
- **TypeScript ready** - Write your pages and entities in TypeScript
|
|
34
|
+
- **Image optimization** - Automatic compression for static assets
|
|
35
|
+
- **Markdown support** - Built-in support for `.md` pages with code highlighting and math
|
|
36
36
|
|
|
37
37
|
### 🚀 Production Ready
|
|
38
38
|
|
|
@@ -61,7 +61,7 @@ npm run dev
|
|
|
61
61
|
|
|
62
62
|
Or manually:
|
|
63
63
|
|
|
64
|
-
###
|
|
64
|
+
### TypeScript Example
|
|
65
65
|
|
|
66
66
|
```typescript
|
|
67
67
|
// src/pages/index.ts
|
|
@@ -85,7 +85,7 @@ export const index = {
|
|
|
85
85
|
}
|
|
86
86
|
```
|
|
87
87
|
|
|
88
|
-
###
|
|
88
|
+
### JavaScript Example
|
|
89
89
|
|
|
90
90
|
```javascript
|
|
91
91
|
// src/pages/index.js
|
|
@@ -195,14 +195,14 @@ Your file structure defines your routes:
|
|
|
195
195
|
src/pages/
|
|
196
196
|
├── index.js → /
|
|
197
197
|
├── about.js → /about
|
|
198
|
-
├── blog.js
|
|
198
|
+
├── blog.js → /blog
|
|
199
199
|
└── posts/
|
|
200
|
-
└── _slug.js
|
|
200
|
+
└── _slug.js → /posts/:slug
|
|
201
201
|
```
|
|
202
202
|
|
|
203
203
|
Dynamic routes use underscore prefix: `_id.js`, `_slug.js`, etc.
|
|
204
204
|
|
|
205
|
-
### ⚛️ Entity-Based State
|
|
205
|
+
### ⚛️ Entity-Based State and Behavior
|
|
206
206
|
|
|
207
207
|
```javascript
|
|
208
208
|
// src/pages/about.js
|
|
@@ -265,7 +265,9 @@ export async function load(entity) {
|
|
|
265
265
|
entity.posts = await response.json()
|
|
266
266
|
}
|
|
267
267
|
|
|
268
|
-
export const
|
|
268
|
+
export const metadata = {
|
|
269
|
+
title: "Blog",
|
|
270
|
+
}
|
|
269
271
|
```
|
|
270
272
|
|
|
271
273
|
The `load` function runs on the server during build. Data is serialized into the HTML and available immediately on the client.
|
|
@@ -309,9 +311,9 @@ export async function staticPaths() {
|
|
|
309
311
|
}
|
|
310
312
|
|
|
311
313
|
export const metadata = (entity) => ({
|
|
312
|
-
title: entity.post
|
|
314
|
+
title: entity.post?.title ?? "Post",
|
|
313
315
|
meta: {
|
|
314
|
-
description: entity.post
|
|
316
|
+
description: entity.post?.excerpt,
|
|
315
317
|
},
|
|
316
318
|
})
|
|
317
319
|
```
|
|
@@ -395,17 +397,17 @@ Routes are lazy-loaded on demand, keeping initial bundle size small.
|
|
|
395
397
|
|
|
396
398
|
SSX includes built-in image optimization using `vite-plugin-image-optimizer`.
|
|
397
399
|
|
|
398
|
-
- **Automatic compression** - PNG, JPEG, GIF, SVG, WebP, and AVIF are compressed at build time
|
|
399
|
-
- **Lossless &
|
|
400
|
+
- **Automatic compression** - PNG, JPEG, GIF, SVG, WebP, and AVIF are compressed at build time
|
|
401
|
+
- **Lossless & lossy** - Configurable settings via `vite` config in `site.config.js`
|
|
400
402
|
|
|
401
403
|
### 📝 Markdown Support
|
|
402
404
|
|
|
403
405
|
SSX treats `.md` files as first-class pages. You can create `src/pages/post.md` and it will be rendered automatically.
|
|
404
406
|
|
|
405
|
-
- **Frontmatter** - Metadata is exported as `metadata
|
|
406
|
-
- **Code
|
|
407
|
-
- **Math
|
|
408
|
-
- **Mermaid
|
|
407
|
+
- **Frontmatter** - Metadata is exported as `metadata`
|
|
408
|
+
- **Code highlighting** - Built-in syntax highlighting with `highlight.js`
|
|
409
|
+
- **Math support** - LaTeX support via `katex` (use `$E=mc^2$` or `$$...$$`)
|
|
410
|
+
- **Mermaid diagrams** - Use `mermaid` code blocks (requires client-side mermaid.js)
|
|
409
411
|
|
|
410
412
|
Configure the syntax highlighting theme in `site.config.js`:
|
|
411
413
|
|
|
@@ -417,6 +419,8 @@ export default {
|
|
|
417
419
|
}
|
|
418
420
|
```
|
|
419
421
|
|
|
422
|
+
Example markdown file:
|
|
423
|
+
|
|
420
424
|
```markdown
|
|
421
425
|
---
|
|
422
426
|
title: My Post
|
|
@@ -448,14 +452,6 @@ Options:
|
|
|
448
452
|
-f, --force Force clean build, ignore cache
|
|
449
453
|
```
|
|
450
454
|
|
|
451
|
-
### `preview`
|
|
452
|
-
|
|
453
|
-
Serves the built static site on port 3000 through the `serve` NPM package.
|
|
454
|
-
|
|
455
|
-
```bash
|
|
456
|
-
pnpm preview
|
|
457
|
-
```
|
|
458
|
-
|
|
459
455
|
### `ssx dev`
|
|
460
456
|
|
|
461
457
|
Starts the Vite development server on port 3000 with hot reload:
|
|
@@ -469,6 +465,14 @@ Options:
|
|
|
469
465
|
-p, --port <port> Dev server port (default: 3000)
|
|
470
466
|
```
|
|
471
467
|
|
|
468
|
+
### `preview`
|
|
469
|
+
|
|
470
|
+
Serves the built static site on port 3000 through the `serve` NPM package:
|
|
471
|
+
|
|
472
|
+
```bash
|
|
473
|
+
pnpm preview
|
|
474
|
+
```
|
|
475
|
+
|
|
472
476
|
---
|
|
473
477
|
|
|
474
478
|
## Project Structure
|
|
@@ -622,7 +626,25 @@ ssx build --force
|
|
|
622
626
|
# Force a clean rebuild of all pages
|
|
623
627
|
```
|
|
624
628
|
|
|
625
|
-
Incremental builds respect your page dependencies and invalidate cache when dependencies change.
|
|
629
|
+
Incremental builds respect your page dependencies and invalidate the cache when dependencies change.
|
|
630
|
+
|
|
631
|
+
---
|
|
632
|
+
|
|
633
|
+
## Component Compatibility
|
|
634
|
+
|
|
635
|
+
### Fully Supported
|
|
636
|
+
|
|
637
|
+
- All Inglorious Web components (`table`, `list`, `select`, `form`)
|
|
638
|
+
- Custom components using lit-html templates
|
|
639
|
+
- Plain HTML and CSS
|
|
640
|
+
|
|
641
|
+
### Limited Support
|
|
642
|
+
|
|
643
|
+
- Third-party Web Components (Shoelace, Material Web, etc.)
|
|
644
|
+
- Will not appear in pre-rendered HTML
|
|
645
|
+
- Require client-side JavaScript to initialize
|
|
646
|
+
- Best used for client-only interactive features
|
|
647
|
+
- Consider using Inglorious Web components for SSG content
|
|
626
648
|
|
|
627
649
|
---
|
|
628
650
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inglorious/ssx",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.4",
|
|
4
4
|
"description": "Server-Side-X. Xecution? Xperience? Who knows.",
|
|
5
5
|
"author": "IceOnFire <antony.mistretta@gmail.com> (https://ingloriouscoderz.it)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"svgo": "^4.0.0",
|
|
57
57
|
"vite": "^7.1.3",
|
|
58
58
|
"vite-plugin-image-optimizer": "^2.0.3",
|
|
59
|
-
"@inglorious/web": "4.0.
|
|
59
|
+
"@inglorious/web": "4.0.6"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"prettier": "^3.6.2",
|
|
@@ -97,7 +97,17 @@ describe("router", () => {
|
|
|
97
97
|
const consoleSpy = vi.spyOn(console, "warn").mockImplementation(() => {})
|
|
98
98
|
const pages = await getPages(PAGES_DIR)
|
|
99
99
|
|
|
100
|
-
|
|
100
|
+
// Verify that we got some pages
|
|
101
|
+
expect(pages.length).toBeGreaterThan(0)
|
|
102
|
+
|
|
103
|
+
// Verify specific pages exist and have correct structure
|
|
104
|
+
const rootPage = pages.find((p) => p.pattern === "/")
|
|
105
|
+
expect(rootPage).toBeDefined()
|
|
106
|
+
expect(rootPage.filePath).toMatch(/pages[/\\]index\.js$/)
|
|
107
|
+
|
|
108
|
+
const aboutPage = pages.find((p) => p.pattern === "/about")
|
|
109
|
+
expect(aboutPage).toBeDefined()
|
|
110
|
+
expect(aboutPage.filePath).toMatch(/pages[/\\]about\.js$/)
|
|
101
111
|
|
|
102
112
|
// Dynamic route without staticPaths should be skipped (and warn)
|
|
103
113
|
const blogPage = pages.find((p) => p.path.includes("/api/"))
|