@moku-labs/web 0.1.0-alpha.3 → 0.2.0
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/LICENSE +1 -1
- package/README.md +71 -23
- package/dist/chunk-DQk6qfdC.mjs +18 -0
- package/dist/index.cjs +5514 -36
- package/dist/index.d.cts +2078 -104
- package/dist/index.d.mts +2078 -104
- package/dist/index.mjs +5394 -28
- package/package.json +60 -60
- package/dist/bin/moku.cjs +0 -1383
- package/dist/bin/moku.d.cts +0 -1
- package/dist/bin/moku.d.mts +0 -1
- package/dist/bin/moku.mjs +0 -1383
- package/dist/factory-BHhulW27.d.mts +0 -90
- package/dist/factory-D0m7Xil2.d.cts +0 -90
- package/dist/factory-DVcAQYEZ.cjs +0 -1710
- package/dist/factory-DwpBwjDk.mjs +0 -1602
- package/dist/index-CddOHo8I.d.mts +0 -413
- package/dist/plugins/head/build.cjs +0 -35
- package/dist/plugins/head/build.d.cts +0 -17
- package/dist/plugins/head/build.d.mts +0 -17
- package/dist/plugins/head/build.mjs +0 -27
- package/dist/plugins/spa/index.cjs +0 -26
- package/dist/plugins/spa/index.d.cts +0 -30
- package/dist/plugins/spa/index.d.mts +0 -30
- package/dist/plugins/spa/index.mjs +0 -24
- package/dist/primitives-BBo4wxUL.d.cts +0 -69
- package/dist/primitives-BYUp6kae.cjs +0 -100
- package/dist/primitives-Dlfi3JTx.d.mts +0 -69
- package/dist/primitives-gO5i1tD8.mjs +0 -58
- package/dist/project-1pAh4RxJ.cjs +0 -1270
- package/dist/project-BaG_ipVz.mjs +0 -1203
- package/dist/route-builder-CKvvehVO.d.cts +0 -413
- package/dist/test.cjs +0 -82
- package/dist/test.d.cts +0 -61
- package/dist/test.d.mts +0 -61
- package/dist/test.mjs +0 -79
- package/dist/wrangler-BHdkyMRj.cjs +0 -423
- package/dist/wrangler-Coyrznz4.mjs +0 -369
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,38 +1,86 @@
|
|
|
1
1
|
# @moku-labs/web
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**A content static-site generator + SPA web framework for TypeScript.** Built on
|
|
4
|
+
[@moku-labs/core](https://github.com/moku-labs/core) — three layers of isolation, plugins all the
|
|
5
|
+
way down, types doing the heavy lifting.
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
## Quick Start
|
|
8
|
-
|
|
9
|
-
```bash
|
|
7
|
+
```
|
|
10
8
|
bun add @moku-labs/web
|
|
11
9
|
```
|
|
12
10
|
|
|
11
|
+
> Status: `0.1.0` — early. The API is settling but not yet frozen.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## What it is
|
|
16
|
+
|
|
17
|
+
`@moku-labs/web` composes a small set of focused plugins into one framework: author Markdown
|
|
18
|
+
content, declare type-safe routes, generate SEO-complete HTML + feeds + sitemap at build time, and
|
|
19
|
+
optionally hydrate islands and deploy to Cloudflare Pages.
|
|
20
|
+
|
|
21
|
+
The consumer surface is one `createApp` call plus a typed routing DSL — you never import from
|
|
22
|
+
`@moku-labs/core` directly.
|
|
23
|
+
|
|
24
|
+
## Quick start
|
|
25
|
+
|
|
13
26
|
```ts
|
|
14
|
-
import { createApp,
|
|
27
|
+
import { createApp, defineRoutes, route } from "@moku-labs/web";
|
|
28
|
+
|
|
29
|
+
const routes = defineRoutes({
|
|
30
|
+
home: route("/")
|
|
31
|
+
.render(() => <h1>My Blog</h1>)
|
|
32
|
+
.head(() => ({ title: "My Blog" })),
|
|
33
|
+
article: route("/{lang:?}/{slug}/")
|
|
34
|
+
.generate((locale) => listSlugs(locale).map((slug) => ({ lang: locale, slug })))
|
|
35
|
+
.load(({ slug }, locale) => loadArticle(slug, locale)) // widens ctx.data
|
|
36
|
+
.render((ctx) => <Article article={ctx.data} />)
|
|
37
|
+
.head((ctx) => ({ title: ctx.data.title, description: ctx.data.description }))
|
|
38
|
+
});
|
|
15
39
|
|
|
16
40
|
const app = createApp({
|
|
17
|
-
mode:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
41
|
+
config: { mode: "production" },
|
|
42
|
+
pluginConfigs: {
|
|
43
|
+
site: { name: "My Blog", url: "https://blog.dev", author: "Me", description: "A personal blog." },
|
|
44
|
+
i18n: { locales: ["en", "uk"], defaultLocale: "en" },
|
|
45
|
+
content: { contentDir: "./content" },
|
|
46
|
+
router: { routes, mode: "ssg" },
|
|
47
|
+
head: { titleTemplate: "%s — My Blog" },
|
|
48
|
+
build: { outDir: "dist", feeds: true, sitemap: true }
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
await app.build.run(); // → static site in dist/ (HTML, feed.xml, sitemap.xml)
|
|
27
53
|
```
|
|
28
54
|
|
|
29
|
-
|
|
55
|
+
Content lives on disk as `content/{slug}/{locale}.md` with YAML frontmatter
|
|
56
|
+
(`title`, `date`, `description`, `tags`, `language`, optional `draft`/`author`). Drafts are excluded
|
|
57
|
+
from production builds.
|
|
58
|
+
|
|
59
|
+
## Plugins
|
|
60
|
+
|
|
61
|
+
| Plugin | Responsibility |
|
|
62
|
+
|---|---|
|
|
63
|
+
| `site` | Site identity (name, URL, author) + canonical URL helper |
|
|
64
|
+
| `i18n` | Locales, default-locale fallback, translations, hreflang/ogLocale maps |
|
|
65
|
+
| `router` | Type-safe route DSL (`route`/`defineRoutes`), matching, URL/file derivation |
|
|
66
|
+
| `content` | Markdown pipeline → sanitized HTML, frontmatter, reading time, locale model |
|
|
67
|
+
| `head` | SEO `<head>` composition: title template, canonical, OG/Twitter, JSON-LD, hreflang |
|
|
68
|
+
| `build` | SSG orchestrator: pages, feeds (RSS/Atom/JSON), sitemap, OG images |
|
|
69
|
+
| `spa` | Client runtime: island hydration + intercepted navigation |
|
|
70
|
+
| `deploy` | Cloudflare Pages: `wrangler.jsonc` scaffolding + deploy |
|
|
71
|
+
| `log`, `env` | Core plugins: structured logging + validated environment access |
|
|
30
72
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
73
|
+
SEO primitives are exported for route `.head()` handlers: `meta`, `og`, `twitter`, `jsonLd`,
|
|
74
|
+
`canonical`, `hreflang`, `feedLink`, `buildArticleHead`.
|
|
75
|
+
|
|
76
|
+
## Scripts
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
bun run build # build with tsdown
|
|
80
|
+
bun run test # vitest (unit + integration)
|
|
81
|
+
bun run lint # biome + eslint
|
|
82
|
+
```
|
|
35
83
|
|
|
36
84
|
## License
|
|
37
85
|
|
|
38
|
-
MIT
|
|
86
|
+
MIT © moku-labs
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __exportAll = (all, no_symbols) => {
|
|
4
|
+
let target = {};
|
|
5
|
+
for (var name in all) {
|
|
6
|
+
__defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
if (!no_symbols) {
|
|
12
|
+
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
13
|
+
}
|
|
14
|
+
return target;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { __exportAll as t };
|