Skip to content

Commit 5fb4032

Browse files
committed
More example improvements
1 parent 0d3b3ff commit 5fb4032

File tree

35 files changed

+185
-127
lines changed

35 files changed

+185
-127
lines changed

.github/dependabot.yml

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,55 @@ updates:
1414
directory: "/examples/basic"
1515
schedule:
1616
interval: "daily"
17+
- package-ecosystem: "npm"
18+
directory: "/examples/css-modules/"
19+
schedule:
20+
interval: "daily"
1721
- package-ecosystem: "npm"
1822
directory: "/examples/default-layout/"
1923
schedule:
2024
interval: "daily"
25+
- package-ecosystem: "npm"
26+
directory: "/examples/esbuild-settings"
27+
schedule:
28+
interval: "daily"
29+
- package-ecosystem: "npm"
30+
directory: "/examples/markdown-settings/"
31+
schedule:
32+
interval: "daily"
2133
- package-ecosystem: "npm"
2234
directory: "/examples/nested-dest/"
2335
schedule:
2436
interval: "daily"
2537
- package-ecosystem: "npm"
26-
directory: "/examples/preact/"
38+
directory: "/examples/preact-isomorphic/"
39+
schedule:
40+
interval: "daily"
41+
- package-ecosystem: "npm"
42+
directory: "/examples/react/"
2743
schedule:
2844
interval: "daily"
2945
- package-ecosystem: "npm"
3046
directory: "/examples/string-layouts/"
3147
schedule:
3248
interval: "daily"
49+
- package-ecosystem: "npm"
50+
directory: "/examples/tailwind/"
51+
schedule:
52+
interval: "daily"
53+
- package-ecosystem: "npm"
54+
directory: "/examples/type-stripping/"
55+
schedule:
56+
interval: "daily"
57+
- package-ecosystem: "npm"
58+
directory: "/examples/uhtml-isomorphic/"
59+
schedule:
60+
interval: "daily"
61+
- package-ecosystem: "npm"
62+
directory: "/examples/worker-examples/"
63+
schedule:
64+
interval: "daily"
65+
# Enable version updates for pnpm
3366
# Enable updates to github actions
3467
- package-ecosystem: "github-actions"
3568
directory: "/"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[![Types in JS](https://img.shields.io/badge/types_in_js-yes-brightgreen)](https://github.com/voxpelli/types-in-js)
66
[![Neocities][neocities-img]](https://domstack.net)
77

8-
`domstack`: Cut the gordian knot of modern web development and build websites with actual html, md, css, js, ts and jsx.
8+
`domstack`: Cut the [gordian knot](https://en.wikipedia.org/wiki/Gordian_Knot) of modern web development and build websites with a stack of html, md, css, js, ts, jsx. DOMStack provides a few project based conventions around esbuild ande Node.js that lets you quickly, cleanly and easily build websites and web apps using all of your favorite technolgies without any framework specific impurities. It's also extreemly fast.
99

1010
```console
1111
npm install @domstack/cli

examples/basic/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"npm-run-all2": "^6.0.0"
2020
},
2121
"dependencies": {
22-
"@domstack/cli": "../../.",
22+
"@domstack/cli": "file:../../.",
2323
"htm": "^3.1.1",
2424
"preact": "^10.26.6",
2525
"preact-render-to-string": "^6.5.13",

examples/basic/src/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Navigate through different page types:
3737
- [Loose Markdown File](./loose-file.md)
3838
- [Markdown Page Example](./md-page/README.md)
3939
- [Nested Markdown Page](./md-page/sub-page/README.md)
40-
- [JavaScript Page Example](./js-page/page.js)
40+
- [JavaScript Page Example](./js-page/)
4141
- [HTML Page Example](./html-page/page.html)
4242

4343
## How It Works

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import { html } from 'htm/preact'
2-
import { render } from 'preact-render-to-string'
32

43
import sharedData from './shared-lib.js'
54

65
export default async function JSPage () {
7-
return render(html`
6+
return html`
87
<div>
98
<p>
109
You can keep loose assets basically anywhere in the <pre>src</pre> directory.
@@ -17,7 +16,7 @@ export default async function JSPage () {
1716
</p>
1817
<p>${sharedData.shared}</p>
1918
</div>
20-
`)
19+
`
2120
}
2221

2322
export const vars = {

examples/basic/src/js-page/page.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
1+
/**
2+
* @import { PageFunction } from '@domstack/cli'
3+
* @import { PageVars } from '../layouts/root.layout.js
4+
*/
15
import { html } from 'htm/preact'
2-
import { render } from 'preact-render-to-string'
36

7+
/**
8+
* @type { PageFunction <PageVars>}
9+
*/
410
export default async function JSPage ({
511
vars: {
612
siteName,
713
title,
814
}
915
}) {
10-
return render(html`
16+
return html`
1117
<div class="js-page-example">
1218
<h1>JavaScript Page Example</h1>
13-
19+
1420
<section class="explanation">
1521
<h2>What is a JavaScript Page?</h2>
1622
<p>
17-
The JavaScript page type is the most powerful and flexible option in DOMStack.
23+
The JavaScript page type is the most powerful and flexible option in DOMStack.
1824
It allows you to:
1925
</p>
2026
<ul>
@@ -29,12 +35,12 @@ export default async function JSPage ({
2935
<h2>How to Implement</h2>
3036
<p>
3137
Export a default function (async or sync) that returns a string or any
32-
type that your layout can handle. In this example, we're using
38+
type that your layout can handle. In this example, we're using
3339
<a href="https://github.com/developit/htm"><code>htm/preact</code></a> for JSX-like syntax.
3440
</p>
3541
<div class="code-example">
3642
<pre><code>export default async function MyPage({ vars }) {
37-
return render(html\`<div>Content here</div>\`)
43+
return html\`<div>Content here</div>\`
3844
}</code></pre>
3945
</div>
4046
</section>
@@ -61,7 +67,7 @@ export default async function JSPage ({
6167
6268
<a href="../" class="back-link">← Back to Home</a>
6369
</div>
64-
`)
70+
`
6571
}
6672

6773
// Define page-specific variables

examples/basic/src/layouts/child.layout.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1+
/**
2+
* @import { LayoutFunction } from '@domstack/cli'
3+
* @import { PageVars } from './root.layout.js'
4+
*/
15
import { html } from 'htm/preact'
26
import { render } from 'preact-render-to-string'
37

48
import defaultRootLayout from './root.layout.js'
59

10+
/** @type{LayoutFunction<PageVars>} */
611
export default function articleLayout (args) {
712
const { children, ...rest } = args
813
const wrappedChildren = render(html`

examples/basic/src/layouts/root.layout.js

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,29 @@
77
//
88
// All other variables are set on a page level basis, either by hand or by data extraction from the page type.
99

10+
/**
11+
* @import { LayoutFunction } from '@domstack/cli'
12+
*/
13+
1014
import { html } from 'htm/preact'
1115
import { render } from 'preact-render-to-string'
1216

17+
/**
18+
* @typedef {{
19+
* title: string,
20+
* siteName: string,
21+
* basePath?: string,
22+
}} PageVars
23+
*/
24+
25+
/**
26+
* @type {LayoutFunction<PageVars>}
27+
*/
1328
export default async function RootLayout ({
1429
vars: {
1530
title,
1631
siteName,
32+
basePath
1733
},
1834
scripts,
1935
styles,
@@ -24,24 +40,23 @@ export default async function RootLayout ({
2440
<html>
2541
${render(html`
2642
<head>
27-
<meta charset="utf-8">
43+
<meta charset="utf-8" />
2844
<title>${siteName}${title ? ` | ${title}` : ''}</title>
2945
<meta name="viewport" content="width=device-width, user-scalable=no" />
3046
${scripts
31-
? scripts.map(script => html`<script src="${script}" type='module'></script>`)
47+
? scripts.map(script => html`<script type='module' src="${script.startsWith('/') ? `${basePath ?? ''}${script}` : script}" />`)
3248
: null}
3349
${styles
34-
? styles.map(style => html`<link rel="stylesheet" href="${style}" />`)
50+
? styles.map(style => html`<link rel="stylesheet" href="${style.startsWith('/') ? `${basePath ?? ''}${style}` : style}" />`)
3551
: null}
3652
</head>
3753
`)}
3854
${render(html`
39-
<body>
40-
<div class="mine-layout">
41-
${typeof children === 'string'
42-
? html`<div dangerouslySetInnerHTML=${{ __html: children }}></div>`
43-
: children /* Support both preact and string children */}
44-
</div>
55+
<body className="safe-area-inset">
56+
${typeof children === 'string'
57+
? html`<main className="mine-layout app-main" dangerouslySetInnerHTML="${{ __html: children }}"/>`
58+
: html`<main className="mine-layout app-main">${children}</main>`
59+
}
4560
</body>
4661
`)}
4762
</html>

examples/css-modules/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"start": "npm run watch",
77
"build": "npm run clean && domstack",
88
"clean": "rm -rf public && mkdir -p public",
9-
"watch": "npm run clean && tb --watch"
9+
"watch": "npm run clean && dom --watch"
1010
},
1111
"author": "Bret Comnes <[email protected]> (https://bret.io/)",
1212
"license": "MIT",
@@ -17,7 +17,7 @@
1717
"mine.css": "^9.0.1",
1818
"preact": "^10.24.0",
1919
"preact-render-to-string": "^6.5.11",
20-
"@domstack/cli": "../../."
20+
"@domstack/cli": "file:../../."
2121
},
2222
"devDependencies": {
2323
"npm-run-all2": "^6.0.0"
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
// @ts-ignore
21
import { toggleTheme } from 'mine.css'
3-
// @ts-ignore
42
window.toggleTheme = toggleTheme

0 commit comments

Comments
 (0)