underpost 2.90.0 → 2.90.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/.env.production +2 -0
- package/README.md +3 -2
- package/bin/build.js +4 -0
- package/bin/deploy.js +16 -0
- package/cli.md +56 -2
- package/examples/QUICK-REFERENCE.md +499 -0
- package/examples/README.md +447 -0
- package/examples/STATIC-GENERATOR-GUIDE.md +807 -0
- package/examples/ssr-components/CustomPage.js +579 -0
- package/examples/static-config-example.json +183 -0
- package/examples/static-config-simple.json +57 -0
- package/manifests/deployment/dd-default-development/deployment.yaml +2 -2
- package/manifests/deployment/dd-test-development/deployment.yaml +2 -2
- package/package.json +1 -1
- package/src/api/document/document.model.js +7 -0
- package/src/api/document/document.service.js +4 -1
- package/src/cli/index.js +105 -1
- package/src/cli/run.js +1 -1
- package/src/cli/static.js +820 -0
- package/src/client/components/core/Input.js +6 -4
- package/src/client/components/core/Modal.js +13 -18
- package/src/client/components/core/Panel.js +26 -6
- package/src/client/components/core/PanelForm.js +67 -52
- package/src/index.js +10 -1
- package/src/server/client-build.js +9 -15
|
@@ -0,0 +1,447 @@
|
|
|
1
|
+
# Underpost Static Site Generator - Examples
|
|
2
|
+
|
|
3
|
+
This directory contains comprehensive examples and documentation for the Underpost Static Site Generator.
|
|
4
|
+
|
|
5
|
+
## Contents
|
|
6
|
+
|
|
7
|
+
### Documentation
|
|
8
|
+
|
|
9
|
+
- **[STATIC-GENERATOR-GUIDE.md](./STATIC-GENERATOR-GUIDE.md)** - Complete guide covering all features, best practices, and advanced usage patterns
|
|
10
|
+
|
|
11
|
+
### Configuration Examples
|
|
12
|
+
|
|
13
|
+
- **[static-config-example.json](./static-config-example.json)** - Fully documented configuration file template with all available options
|
|
14
|
+
|
|
15
|
+
### SSR Component Examples
|
|
16
|
+
|
|
17
|
+
- **[ssr-components/CustomPage.js](./ssr-components/CustomPage.js)** - Complete example of a custom landing page with:
|
|
18
|
+
- Semantic HTML structure
|
|
19
|
+
- Accessibility features
|
|
20
|
+
- Responsive design
|
|
21
|
+
- Progressive enhancement
|
|
22
|
+
- Inline critical CSS
|
|
23
|
+
- Interactive JavaScript
|
|
24
|
+
|
|
25
|
+
## Quick Start
|
|
26
|
+
|
|
27
|
+
### 1. Generate a Config Template
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
underpost static --generate-config ./my-static-config.json
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
This creates a template configuration file with all available options documented.
|
|
34
|
+
|
|
35
|
+
### 2. Customize Your Config
|
|
36
|
+
|
|
37
|
+
Edit the generated config file with your specific requirements:
|
|
38
|
+
|
|
39
|
+
```json
|
|
40
|
+
{
|
|
41
|
+
"page": "./src/client/ssr/body/YourPage.js",
|
|
42
|
+
"outputPath": "./dist/index.html",
|
|
43
|
+
"metadata": {
|
|
44
|
+
"title": "Your App Title",
|
|
45
|
+
"description": "Your app description"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### 3. Build Your Static Page
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
underpost static --config-file ./my-static-config.json
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Example Usage Scenarios
|
|
57
|
+
|
|
58
|
+
### Basic Static Page
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
underpost static \
|
|
62
|
+
--page ./src/client/ssr/body/DefaultSplashScreen.js \
|
|
63
|
+
--output-path ./dist/index.html \
|
|
64
|
+
--title "My App"
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Landing Page with SEO
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
underpost static \
|
|
71
|
+
--page ./examples/ssr-components/CustomPage.js \
|
|
72
|
+
--output-path ./dist/landing.html \
|
|
73
|
+
--title "Welcome to My App" \
|
|
74
|
+
--description "The best app for your needs" \
|
|
75
|
+
--keywords "app,solution,innovation" \
|
|
76
|
+
--theme-color "#667eea" \
|
|
77
|
+
--canonical-url "https://myapp.com"
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Complete Customization
|
|
81
|
+
|
|
82
|
+
Use the provided `static-config-example.json`:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
# Copy the example
|
|
86
|
+
cp ./examples/static-config-example.json ./my-config.json
|
|
87
|
+
|
|
88
|
+
# Edit with your settings
|
|
89
|
+
nano ./my-config.json
|
|
90
|
+
|
|
91
|
+
# Build
|
|
92
|
+
underpost static --config-file ./my-config.json
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Available Examples
|
|
96
|
+
|
|
97
|
+
### 1. Complete Configuration Example
|
|
98
|
+
|
|
99
|
+
**File:** `static-config-example.json`
|
|
100
|
+
|
|
101
|
+
**What it demonstrates:**
|
|
102
|
+
- Complete metadata configuration
|
|
103
|
+
- Script injection (head and body)
|
|
104
|
+
- Stylesheet management
|
|
105
|
+
- Icon configuration
|
|
106
|
+
- SSR component inclusion
|
|
107
|
+
- Microdata/structured data
|
|
108
|
+
- Custom payload injection
|
|
109
|
+
|
|
110
|
+
**Use case:** Production-ready web application with full SEO and PWA support
|
|
111
|
+
|
|
112
|
+
### 2. Custom Landing Page Component
|
|
113
|
+
|
|
114
|
+
**File:** `ssr-components/CustomPage.js`
|
|
115
|
+
|
|
116
|
+
**What it demonstrates:**
|
|
117
|
+
- Hero section with call-to-action
|
|
118
|
+
- Feature showcase grid
|
|
119
|
+
- Content sections
|
|
120
|
+
- Contact form
|
|
121
|
+
- Footer with links
|
|
122
|
+
- Responsive design
|
|
123
|
+
- Accessibility features
|
|
124
|
+
- Progressive enhancement
|
|
125
|
+
|
|
126
|
+
**Use case:** Marketing landing page or product showcase
|
|
127
|
+
|
|
128
|
+
## Configuration Options Reference
|
|
129
|
+
|
|
130
|
+
### Metadata Options
|
|
131
|
+
|
|
132
|
+
```json
|
|
133
|
+
{
|
|
134
|
+
"metadata": {
|
|
135
|
+
"title": "Page title",
|
|
136
|
+
"description": "SEO description",
|
|
137
|
+
"keywords": ["keyword1", "keyword2"],
|
|
138
|
+
"author": "Author name",
|
|
139
|
+
"themeColor": "#ffffff",
|
|
140
|
+
"canonicalURL": "https://example.com",
|
|
141
|
+
"thumbnail": "https://example.com/image.png",
|
|
142
|
+
"locale": "en-US",
|
|
143
|
+
"siteName": "Site Name"
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Script Options
|
|
149
|
+
|
|
150
|
+
```json
|
|
151
|
+
{
|
|
152
|
+
"scripts": {
|
|
153
|
+
"head": [
|
|
154
|
+
{
|
|
155
|
+
"src": "https://cdn.example.com/script.js",
|
|
156
|
+
"async": true,
|
|
157
|
+
"integrity": "sha384-...",
|
|
158
|
+
"crossorigin": "anonymous"
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"content": "window.config = {};",
|
|
162
|
+
"type": "text/javascript"
|
|
163
|
+
}
|
|
164
|
+
],
|
|
165
|
+
"body": [
|
|
166
|
+
{
|
|
167
|
+
"src": "/app.js",
|
|
168
|
+
"type": "module",
|
|
169
|
+
"defer": true
|
|
170
|
+
}
|
|
171
|
+
]
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Style Options
|
|
177
|
+
|
|
178
|
+
```json
|
|
179
|
+
{
|
|
180
|
+
"styles": [
|
|
181
|
+
{ "href": "/main.css" },
|
|
182
|
+
{ "content": "body { margin: 0; }" },
|
|
183
|
+
{ "href": "/print.css", "media": "print" }
|
|
184
|
+
]
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Icon Options
|
|
189
|
+
|
|
190
|
+
```json
|
|
191
|
+
{
|
|
192
|
+
"icons": {
|
|
193
|
+
"favicon": "/favicon.ico",
|
|
194
|
+
"appleTouchIcon": "/apple-touch-icon.png",
|
|
195
|
+
"manifest": "/manifest.json",
|
|
196
|
+
"additional": [
|
|
197
|
+
{
|
|
198
|
+
"rel": "icon",
|
|
199
|
+
"type": "image/png",
|
|
200
|
+
"sizes": "32x32",
|
|
201
|
+
"href": "/favicon-32x32.png"
|
|
202
|
+
}
|
|
203
|
+
]
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### Component Options
|
|
209
|
+
|
|
210
|
+
```json
|
|
211
|
+
{
|
|
212
|
+
"headComponents": [
|
|
213
|
+
"./src/client/ssr/head/Seo.js",
|
|
214
|
+
"./src/client/ssr/head/Pwa.js"
|
|
215
|
+
],
|
|
216
|
+
"bodyComponents": [
|
|
217
|
+
"./src/client/ssr/body/Header.js"
|
|
218
|
+
]
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### Structured Data (Microdata)
|
|
223
|
+
|
|
224
|
+
```json
|
|
225
|
+
{
|
|
226
|
+
"microdata": [
|
|
227
|
+
{
|
|
228
|
+
"@context": "https://schema.org",
|
|
229
|
+
"@type": "WebSite",
|
|
230
|
+
"name": "My Site",
|
|
231
|
+
"url": "https://example.com"
|
|
232
|
+
}
|
|
233
|
+
]
|
|
234
|
+
}
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
## Common Use Cases
|
|
238
|
+
|
|
239
|
+
### 1. Simple Blog Post
|
|
240
|
+
|
|
241
|
+
```json
|
|
242
|
+
{
|
|
243
|
+
"page": "./src/client/ssr/body/BlogPost.js",
|
|
244
|
+
"outputPath": "./dist/blog/my-post.html",
|
|
245
|
+
"metadata": {
|
|
246
|
+
"title": "My Blog Post Title",
|
|
247
|
+
"description": "Summary of the blog post",
|
|
248
|
+
"author": "John Doe",
|
|
249
|
+
"keywords": ["blogging", "tutorial"]
|
|
250
|
+
},
|
|
251
|
+
"microdata": [
|
|
252
|
+
{
|
|
253
|
+
"@context": "https://schema.org",
|
|
254
|
+
"@type": "BlogPosting",
|
|
255
|
+
"headline": "My Blog Post Title",
|
|
256
|
+
"author": {
|
|
257
|
+
"@type": "Person",
|
|
258
|
+
"name": "John Doe"
|
|
259
|
+
},
|
|
260
|
+
"datePublished": "2024-01-01"
|
|
261
|
+
}
|
|
262
|
+
]
|
|
263
|
+
}
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### 2. E-commerce Product Page
|
|
267
|
+
|
|
268
|
+
```json
|
|
269
|
+
{
|
|
270
|
+
"page": "./src/client/ssr/body/ProductPage.js",
|
|
271
|
+
"outputPath": "./dist/products/widget.html",
|
|
272
|
+
"metadata": {
|
|
273
|
+
"title": "Premium Widget - Buy Now",
|
|
274
|
+
"description": "High-quality widget with free shipping",
|
|
275
|
+
"thumbnail": "https://shop.com/widget.jpg"
|
|
276
|
+
},
|
|
277
|
+
"microdata": [
|
|
278
|
+
{
|
|
279
|
+
"@context": "https://schema.org",
|
|
280
|
+
"@type": "Product",
|
|
281
|
+
"name": "Premium Widget",
|
|
282
|
+
"offers": {
|
|
283
|
+
"@type": "Offer",
|
|
284
|
+
"price": "29.99",
|
|
285
|
+
"priceCurrency": "USD"
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
]
|
|
289
|
+
}
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
### 3. Documentation Page
|
|
293
|
+
|
|
294
|
+
```json
|
|
295
|
+
{
|
|
296
|
+
"page": "./src/client/ssr/body/DocsPage.js",
|
|
297
|
+
"outputPath": "./dist/docs/index.html",
|
|
298
|
+
"headComponents": [
|
|
299
|
+
"./src/client/ssr/head/Seo.js"
|
|
300
|
+
],
|
|
301
|
+
"styles": [
|
|
302
|
+
{ "href": "/docs/prism.css" },
|
|
303
|
+
{ "href": "/docs/docs.css" }
|
|
304
|
+
],
|
|
305
|
+
"scripts": {
|
|
306
|
+
"body": [
|
|
307
|
+
{ "src": "/docs/prism.js", "defer": true },
|
|
308
|
+
{ "src": "/docs/search.js", "defer": true }
|
|
309
|
+
]
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
### 4. Multi-language Pages
|
|
315
|
+
|
|
316
|
+
```bash
|
|
317
|
+
# English version
|
|
318
|
+
underpost static --config-file ./config-en.json --lang en --dir ltr
|
|
319
|
+
|
|
320
|
+
# Spanish version
|
|
321
|
+
underpost static --config-file ./config-es.json --lang es --dir ltr
|
|
322
|
+
|
|
323
|
+
# Arabic version
|
|
324
|
+
underpost static --config-file ./config-ar.json --lang ar --dir rtl
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
## Best Practices
|
|
328
|
+
|
|
329
|
+
### 1. SEO Optimization
|
|
330
|
+
|
|
331
|
+
✅ Always include title, description, and keywords
|
|
332
|
+
✅ Use canonical URLs
|
|
333
|
+
✅ Add Open Graph metadata
|
|
334
|
+
✅ Include structured data (JSON-LD)
|
|
335
|
+
✅ Optimize images in metadata
|
|
336
|
+
|
|
337
|
+
### 2. Performance
|
|
338
|
+
|
|
339
|
+
✅ Minify HTML in production
|
|
340
|
+
✅ Use async/defer for scripts
|
|
341
|
+
✅ Inline critical CSS
|
|
342
|
+
✅ Optimize asset loading order
|
|
343
|
+
|
|
344
|
+
### 3. Accessibility
|
|
345
|
+
|
|
346
|
+
✅ Use semantic HTML
|
|
347
|
+
✅ Include ARIA labels
|
|
348
|
+
✅ Ensure keyboard navigation
|
|
349
|
+
✅ Test with screen readers
|
|
350
|
+
|
|
351
|
+
### 4. Progressive Enhancement
|
|
352
|
+
|
|
353
|
+
✅ Ensure content works without JavaScript
|
|
354
|
+
✅ Add interactive features progressively
|
|
355
|
+
✅ Test on various devices
|
|
356
|
+
✅ Provide fallbacks
|
|
357
|
+
|
|
358
|
+
## Advanced Techniques
|
|
359
|
+
|
|
360
|
+
### Custom SSR Component Template
|
|
361
|
+
|
|
362
|
+
```javascript
|
|
363
|
+
/**
|
|
364
|
+
* Custom Component Template
|
|
365
|
+
* @description Brief description of the component
|
|
366
|
+
*/
|
|
367
|
+
SrrComponent = () => html`
|
|
368
|
+
<div class="custom-component">
|
|
369
|
+
<!-- Your HTML here -->
|
|
370
|
+
</div>
|
|
371
|
+
|
|
372
|
+
<style>
|
|
373
|
+
/* Component-specific styles */
|
|
374
|
+
</style>
|
|
375
|
+
|
|
376
|
+
<script>
|
|
377
|
+
// Component-specific JavaScript
|
|
378
|
+
document.addEventListener('DOMContentLoaded', function() {
|
|
379
|
+
// Your code here
|
|
380
|
+
});
|
|
381
|
+
</script>
|
|
382
|
+
`;
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
### Programmatic Usage
|
|
386
|
+
|
|
387
|
+
```javascript
|
|
388
|
+
import UnderpostStatic from './src/cli/static.js';
|
|
389
|
+
|
|
390
|
+
// Generate multiple pages
|
|
391
|
+
const pages = [
|
|
392
|
+
{ slug: 'home', title: 'Home' },
|
|
393
|
+
{ slug: 'about', title: 'About' },
|
|
394
|
+
{ slug: 'contact', title: 'Contact' }
|
|
395
|
+
];
|
|
396
|
+
|
|
397
|
+
for (const page of pages) {
|
|
398
|
+
await UnderpostStatic.API.callback({
|
|
399
|
+
page: `./src/client/ssr/body/${page.slug}.js`,
|
|
400
|
+
outputPath: `./dist/${page.slug}.html`,
|
|
401
|
+
metadata: {
|
|
402
|
+
title: page.title
|
|
403
|
+
}
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
## Troubleshooting
|
|
409
|
+
|
|
410
|
+
### Component Not Found
|
|
411
|
+
|
|
412
|
+
**Error:** `Page component does not exist`
|
|
413
|
+
|
|
414
|
+
**Solution:** Verify the path is correct and the file exists
|
|
415
|
+
|
|
416
|
+
### Invalid JSON
|
|
417
|
+
|
|
418
|
+
**Error:** `Error loading config file: Unexpected token`
|
|
419
|
+
|
|
420
|
+
**Solution:** Validate your JSON using a linter or online validator
|
|
421
|
+
|
|
422
|
+
### Missing Metadata
|
|
423
|
+
|
|
424
|
+
**Warning:** No metadata generated
|
|
425
|
+
|
|
426
|
+
**Solution:** Ensure metadata object is properly configured in your config
|
|
427
|
+
|
|
428
|
+
## Getting Help
|
|
429
|
+
|
|
430
|
+
- Read the [Complete Guide](./STATIC-GENERATOR-GUIDE.md)
|
|
431
|
+
- Check the [example config](./static-config-example.json)
|
|
432
|
+
- Review the [custom page example](./ssr-components/CustomPage.js)
|
|
433
|
+
- Check the main project documentation
|
|
434
|
+
|
|
435
|
+
## Contributing
|
|
436
|
+
|
|
437
|
+
To add new examples:
|
|
438
|
+
|
|
439
|
+
1. Create your example file
|
|
440
|
+
2. Add comprehensive comments
|
|
441
|
+
3. Update this README
|
|
442
|
+
4. Test your example thoroughly
|
|
443
|
+
5. Submit a pull request
|
|
444
|
+
|
|
445
|
+
## License
|
|
446
|
+
|
|
447
|
+
Part of the Underpost framework. See main project license.
|