Skip to content

Commit 0f16d6a

Browse files
committed
More docs improvements
1 parent 2a5daac commit 0f16d6a

File tree

41 files changed

+1724
-1039
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1724
-1039
lines changed

README.md

Lines changed: 349 additions & 415 deletions
Large diffs are not rendered by default.

examples/basic/README.md

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
# Basic DOMStack Example
1+
# Basic DOMStack Example with TypeScript
22

3-
This example demonstrates a fundamental website built with DOMStack, showcasing core features without advanced customization.
3+
This example demonstrates a fundamental website built with DOMStack using TypeScript, showcasing core features without advanced customization.
44

55
## Overview
66

77
The basic example illustrates:
8-
- Multiple page types (Markdown, HTML, JavaScript)
8+
- Multiple page types (Markdown, HTML, JavaScript/TypeScript)
99
- Layout system and page nesting
1010
- Asset handling
11-
- Client-side JavaScript integration
11+
- Client-side TypeScript integration
1212
- CSS styling (global and page-specific)
1313
- Variables and metadata
14+
- TypeScript integration with proper type definitions
1415

1516
## Getting Started
1617

@@ -41,34 +42,46 @@ The built site will be in the `public` directory.
4142

4243
```
4344
src/
44-
├── layouts/ # Layout templates
45-
│ ├── root.layout.js # Main layout
46-
│ └── child.layout.js # Nested layout
47-
├── md-page/ # Markdown page examples
48-
├── js-page/ # JavaScript page examples
49-
├── html-page/ # HTML page examples
50-
├── global.css # Global styles
51-
├── global.client.js # Global client-side JavaScript
52-
├── global.vars.js # Global variables
53-
└── README.md # Main content (becomes index.html)
45+
├── layouts/ # Layout templates
46+
│ ├── root.layout.ts # Main layout (TypeScript)
47+
│ └── child.layout.ts # Nested layout (TypeScript)
48+
├── md-page/ # Markdown page examples
49+
│ ├── page.vars.ts # Page variables (TypeScript)
50+
│ └── client.ts # Page-specific client script (TypeScript)
51+
├── js-page/ # JavaScript page examples (kept as JS for demonstration)
52+
│ ├── loose-assets/ # Contains TypeScript files
53+
│ │ ├── page.ts # TypeScript page
54+
│ │ ├── client.ts # TypeScript client
55+
│ │ └── shared-lib.ts # TypeScript shared library
56+
├── html-page/ # HTML page examples
57+
│ └── client.ts # Page-specific client script (TypeScript)
58+
├── global.css # Global styles
59+
├── global.client.ts # Global client-side TypeScript
60+
├── global.vars.ts # Global variables (TypeScript)
61+
└── README.md # Main content (becomes index.html)
5462
```
5563

56-
## Key Features Demonstrated
64+
### Key Features Demonstrated
5765

5866
### Page Types
5967
- **Markdown pages** - Simple content authoring with frontmatter
60-
- **JavaScript pages** - Dynamic content generation with full JS capabilities
68+
- **JavaScript/TypeScript pages** - Dynamic content generation with full JS/TS capabilities
6169
- **HTML pages** - Direct HTML control for complex layouts
6270

6371
### Layouts
64-
The example demonstrates DOMStack's layout system with nested layouts that wrap page content.
72+
The example demonstrates DOMStack's layout system with nested layouts that wrap page content, fully typed with TypeScript interfaces.
6573

6674
### Assets
6775
Static assets like images are co-located with content and automatically copied to the output directory.
6876

6977
### Styling
7078
Both global and page-specific CSS is demonstrated, showing how to scope styles appropriately.
7179

80+
### TypeScript Integration
81+
- **Strong typing** - Full TypeScript support with interfaces for layouts, pages, and components
82+
- **JSDoc example** - The js-page directory is kept as JavaScript with JSDoc comments to demonstrate compatibility
83+
- **Type definitions** - Proper type definitions for page variables, layout functions, and client scripts
84+
7285
## Learn More
7386

7487
This is one of several examples in the DOMStack repository. For more advanced features, check out the other examples like:
@@ -77,4 +90,4 @@ This is one of several examples in the DOMStack repository. For more advanced fe
7790
- tailwind
7891
- and more...
7992

80-
For complete documentation, visit the [DOMStack GitHub repository](https://github.com/bcomnes/domstack).
93+
For complete documentation, visit the [DOMStack GitHub repository](https://github.com/bcomnes/domstack).

examples/basic/package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,23 @@
77
"start": "npm run watch",
88
"build": "npm run clean && domstack",
99
"clean": "rm -rf public && mkdir -p public",
10-
"watch": "npm run clean && run-p watch:*",
11-
"watch:serve": "browser-sync start --server 'public' --files 'public'",
12-
"watch:domstack": "npm run build -- --watch"
10+
"watch": "npm run clean && dom --watch",
11+
"test": "tsc"
1312
},
1413
"keywords": [],
1514
"author": "Bret Comnes <[email protected]> (https://bret.io/)",
1615
"license": "MIT",
1716
"devDependencies": {
18-
"browser-sync": "^2.26.7",
19-
"npm-run-all2": "^6.0.0"
17+
"npm-run-all2": "^6.0.0",
18+
"typescript": "~5.8.2",
19+
"@voxpelli/tsconfig": "^15.0.0"
2020
},
2121
"dependencies": {
2222
"@domstack/cli": "file:../../.",
2323
"htm": "^3.1.1",
2424
"preact": "^10.26.6",
2525
"preact-render-to-string": "^6.5.13",
26-
"mine.css": "^9.0.1"
26+
"mine.css": "^9.0.1",
27+
"highlight.js": "^11.9.0"
2728
}
2829
}
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
console.log('This client bundle only loads in the root page.')
22

3-
// Each page folder can have a client.js file in it.
4-
// The client.js file is treated as an entry point script for just the
3+
// Each page folder can have a client.ts file in it.
4+
// The client.ts file is treated as an entry point script for just the
55
// page it is associated with, but all dependencies are de-duped via
66
// esbuild.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1+
// @ts-expect-error
12
import { toggleTheme } from 'mine.css'
23

4+
declare global {
5+
interface Window {
6+
toggleTheme: typeof toggleTheme;
7+
}
8+
}
9+
310
window.toggleTheme = toggleTheme
411

512
console.log('The global client is loaded on every page.')

examples/basic/src/global.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
@import 'mine.css/dist/mine.css';
22
@import 'mine.css/dist/layout.css';
3+
@import 'highlight.js/styles/github-dark-dimmed.css';
34

45
/* The global.css in the root directory of the site is loaded on every page. */
56

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
// The global.vars.js file should export default either an object, function that
1+
// The global.vars.ts file should export default either an object, function that
22
// returns an object or an async function that returns an object.
33
//
44
// These variables are available to every page, and have the lowest precedence.
55

6-
export default async function () {
6+
interface GlobalVars {
7+
siteName: string;
8+
[key: string]: unknown;
9+
}
10+
11+
export default async function (): Promise<GlobalVars> {
712
return {
813
siteName: 'domstack basic',
914
}

examples/basic/src/js-page/loose-assets/client.js

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import sharedData from './shared-lib.ts'
2+
3+
console.log(sharedData.shared)

0 commit comments

Comments
 (0)