@opentf/create-afw 0.5.0 → 0.7.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/README.md +5 -8
- package/esdev/templates/app/_gitignore +18 -0
- package/esdev/templates/app/_option/language/js/entry.js +4 -0
- package/esdev/templates/app/_option/language/js/index.html +13 -0
- package/esdev/templates/app/_option/language/js/jsconfig.json +6 -0
- package/esdev/templates/app/_option/language/js/tests/ui/Counter.test.js +10 -0
- package/esdev/templates/app/_option/language/ts/entry.ts +4 -0
- package/esdev/templates/app/_option/language/ts/index.html +13 -0
- package/esdev/templates/app/_option/language/ts/tests/ui/Counter.test.ts +10 -0
- package/esdev/templates/app/_option/language/ts/tsconfig.json +28 -0
- package/esdev/templates/app/_option/render/client/_option/language/js/app/_config.js +6 -0
- package/esdev/templates/app/_option/render/client/_option/language/ts/app/_config.ts +6 -0
- package/esdev/templates/app/_option/render/client/_option/server/no/_option/styling/css/_option/language/js/README.md +14 -0
- package/esdev/templates/app/_option/render/client/_option/server/no/_option/styling/css/_option/language/js/app/layout.jsx +13 -0
- package/esdev/templates/app/_option/render/client/_option/server/no/_option/styling/css/_option/language/js/package.json +19 -0
- package/esdev/templates/app/_option/render/client/_option/server/no/_option/styling/css/_option/language/ts/README.md +15 -0
- package/esdev/templates/app/_option/render/client/_option/server/no/_option/styling/css/_option/language/ts/app/layout.tsx +13 -0
- package/esdev/templates/app/_option/render/client/_option/server/no/_option/styling/css/_option/language/ts/package.json +21 -0
- package/esdev/templates/app/_option/render/client/_option/server/no/_option/styling/tailwind/_option/language/js/README.md +15 -0
- package/esdev/templates/app/_option/render/client/_option/server/no/_option/styling/tailwind/_option/language/js/app/layout.jsx +13 -0
- package/esdev/templates/app/_option/render/client/_option/server/no/_option/styling/tailwind/_option/language/js/package.json +20 -0
- package/esdev/templates/app/_option/render/client/_option/server/no/_option/styling/tailwind/_option/language/ts/README.md +16 -0
- package/esdev/templates/app/_option/render/client/_option/server/no/_option/styling/tailwind/_option/language/ts/app/layout.tsx +13 -0
- package/esdev/templates/app/_option/render/client/_option/server/no/_option/styling/tailwind/_option/language/ts/package.json +22 -0
- package/esdev/templates/app/_option/render/client/_option/server/no/esdev.json +18 -0
- package/esdev/templates/app/_option/render/client/_option/server/yes/_option/styling/css/_option/language/js/README.md +15 -0
- package/esdev/templates/app/_option/render/client/_option/server/yes/_option/styling/css/_option/language/js/app/layout.jsx +14 -0
- package/esdev/templates/app/_option/render/client/_option/server/yes/_option/styling/css/_option/language/js/package.json +19 -0
- package/esdev/templates/app/_option/render/client/_option/server/yes/_option/styling/css/_option/language/ts/README.md +16 -0
- package/esdev/templates/app/_option/render/client/_option/server/yes/_option/styling/css/_option/language/ts/app/layout.tsx +14 -0
- package/esdev/templates/app/_option/render/client/_option/server/yes/_option/styling/css/_option/language/ts/package.json +21 -0
- package/esdev/templates/app/_option/render/client/_option/server/yes/_option/styling/tailwind/_option/language/js/README.md +16 -0
- package/esdev/templates/app/_option/render/client/_option/server/yes/_option/styling/tailwind/_option/language/js/app/layout.jsx +14 -0
- package/esdev/templates/app/_option/render/client/_option/server/yes/_option/styling/tailwind/_option/language/js/package.json +20 -0
- package/esdev/templates/app/_option/render/client/_option/server/yes/_option/styling/tailwind/_option/language/ts/README.md +17 -0
- package/esdev/templates/app/_option/render/client/_option/server/yes/_option/styling/tailwind/_option/language/ts/app/layout.tsx +14 -0
- package/esdev/templates/app/_option/render/client/_option/server/yes/_option/styling/tailwind/_option/language/ts/package.json +22 -0
- package/esdev/templates/app/_option/render/client/_option/server/yes/esdev.json +28 -0
- package/esdev/templates/app/_option/render/mixed/_option/language/js/app/_config.js +6 -0
- package/esdev/templates/app/_option/render/mixed/_option/language/js/app/about/_config.js +4 -0
- package/esdev/templates/app/_option/render/mixed/_option/language/js/app/dashboard/_config.js +5 -0
- package/esdev/templates/app/_option/render/mixed/_option/language/js/app/dashboard/loader.js +4 -0
- package/esdev/templates/app/_option/render/mixed/_option/language/ts/app/_config.ts +6 -0
- package/esdev/templates/app/_option/render/mixed/_option/language/ts/app/about/_config.ts +4 -0
- package/esdev/templates/app/_option/render/mixed/_option/language/ts/app/dashboard/_config.ts +5 -0
- package/esdev/templates/app/_option/render/mixed/_option/language/ts/app/dashboard/loader.ts +4 -0
- package/esdev/templates/app/_option/render/mixed/_option/server/yes/_option/styling/css/_option/language/js/README.md +15 -0
- package/esdev/templates/app/_option/render/mixed/_option/server/yes/_option/styling/css/_option/language/js/app/layout.jsx +15 -0
- package/esdev/templates/app/_option/render/mixed/_option/server/yes/_option/styling/css/_option/language/js/package.json +19 -0
- package/esdev/templates/app/_option/render/mixed/_option/server/yes/_option/styling/css/_option/language/ts/README.md +16 -0
- package/esdev/templates/app/_option/render/mixed/_option/server/yes/_option/styling/css/_option/language/ts/app/layout.tsx +15 -0
- package/esdev/templates/app/_option/render/mixed/_option/server/yes/_option/styling/css/_option/language/ts/package.json +21 -0
- package/esdev/templates/app/_option/render/mixed/_option/server/yes/_option/styling/tailwind/_option/language/js/README.md +16 -0
- package/esdev/templates/app/_option/render/mixed/_option/server/yes/_option/styling/tailwind/_option/language/js/app/layout.jsx +15 -0
- package/esdev/templates/app/_option/render/mixed/_option/server/yes/_option/styling/tailwind/_option/language/js/package.json +20 -0
- package/esdev/templates/app/_option/render/mixed/_option/server/yes/_option/styling/tailwind/_option/language/ts/README.md +17 -0
- package/esdev/templates/app/_option/render/mixed/_option/server/yes/_option/styling/tailwind/_option/language/ts/app/layout.tsx +15 -0
- package/esdev/templates/app/_option/render/mixed/_option/server/yes/_option/styling/tailwind/_option/language/ts/package.json +22 -0
- package/esdev/templates/app/_option/render/mixed/_option/server/yes/esdev.json +28 -0
- package/esdev/templates/app/_option/render/mixed/_option/styling/css/_option/language/js/app/dashboard/page.jsx +13 -0
- package/esdev/templates/app/_option/render/mixed/_option/styling/css/_option/language/ts/app/dashboard/page.tsx +13 -0
- package/esdev/templates/app/_option/render/mixed/_option/styling/tailwind/_option/language/js/app/dashboard/page.jsx +13 -0
- package/esdev/templates/app/_option/render/mixed/_option/styling/tailwind/_option/language/ts/app/dashboard/page.tsx +13 -0
- package/esdev/templates/app/_option/render/server/_option/language/js/app/_config.js +6 -0
- package/esdev/templates/app/_option/render/server/_option/language/ts/app/_config.ts +6 -0
- package/esdev/templates/app/_option/render/server/_option/server/yes/_option/styling/css/_option/language/js/README.md +15 -0
- package/esdev/templates/app/_option/render/server/_option/server/yes/_option/styling/css/_option/language/js/app/layout.jsx +14 -0
- package/esdev/templates/app/_option/render/server/_option/server/yes/_option/styling/css/_option/language/js/package.json +19 -0
- package/esdev/templates/app/_option/render/server/_option/server/yes/_option/styling/css/_option/language/ts/README.md +16 -0
- package/esdev/templates/app/_option/render/server/_option/server/yes/_option/styling/css/_option/language/ts/app/layout.tsx +14 -0
- package/esdev/templates/app/_option/render/server/_option/server/yes/_option/styling/css/_option/language/ts/package.json +21 -0
- package/esdev/templates/app/_option/render/server/_option/server/yes/_option/styling/tailwind/_option/language/js/README.md +16 -0
- package/esdev/templates/app/_option/render/server/_option/server/yes/_option/styling/tailwind/_option/language/js/app/layout.jsx +14 -0
- package/esdev/templates/app/_option/render/server/_option/server/yes/_option/styling/tailwind/_option/language/js/package.json +20 -0
- package/esdev/templates/app/_option/render/server/_option/server/yes/_option/styling/tailwind/_option/language/ts/README.md +17 -0
- package/esdev/templates/app/_option/render/server/_option/server/yes/_option/styling/tailwind/_option/language/ts/app/layout.tsx +14 -0
- package/esdev/templates/app/_option/render/server/_option/server/yes/_option/styling/tailwind/_option/language/ts/package.json +22 -0
- package/esdev/templates/app/_option/render/server/_option/server/yes/esdev.json +28 -0
- package/esdev/templates/app/_option/render/static/_option/language/js/app/_config.js +6 -0
- package/esdev/templates/app/_option/render/static/_option/language/ts/app/_config.ts +6 -0
- package/esdev/templates/app/_option/render/static/_option/server/no/_option/styling/css/_option/language/js/README.md +14 -0
- package/esdev/templates/app/_option/render/static/_option/server/no/_option/styling/css/_option/language/js/app/layout.jsx +13 -0
- package/esdev/templates/app/_option/render/static/_option/server/no/_option/styling/css/_option/language/js/package.json +20 -0
- package/esdev/templates/app/_option/render/static/_option/server/no/_option/styling/css/_option/language/ts/README.md +15 -0
- package/esdev/templates/app/_option/render/static/_option/server/no/_option/styling/css/_option/language/ts/app/layout.tsx +13 -0
- package/esdev/templates/app/_option/render/static/_option/server/no/_option/styling/css/_option/language/ts/package.json +22 -0
- package/esdev/templates/app/_option/render/static/_option/server/no/_option/styling/tailwind/_option/language/js/README.md +15 -0
- package/esdev/templates/app/_option/render/static/_option/server/no/_option/styling/tailwind/_option/language/js/app/layout.jsx +13 -0
- package/esdev/templates/app/_option/render/static/_option/server/no/_option/styling/tailwind/_option/language/js/package.json +21 -0
- package/esdev/templates/app/_option/render/static/_option/server/no/_option/styling/tailwind/_option/language/ts/README.md +16 -0
- package/esdev/templates/app/_option/render/static/_option/server/no/_option/styling/tailwind/_option/language/ts/app/layout.tsx +13 -0
- package/esdev/templates/app/_option/render/static/_option/server/no/_option/styling/tailwind/_option/language/ts/package.json +23 -0
- package/esdev/templates/app/_option/render/static/_option/server/no/esdev.json +32 -0
- package/esdev/templates/app/_option/render/static/_option/server/no/ssg.js +131 -0
- package/esdev/templates/app/_option/render/static/_option/server/yes/_option/styling/css/_option/language/js/README.md +15 -0
- package/esdev/templates/app/_option/render/static/_option/server/yes/_option/styling/css/_option/language/js/app/layout.jsx +14 -0
- package/esdev/templates/app/_option/render/static/_option/server/yes/_option/styling/css/_option/language/js/package.json +19 -0
- package/esdev/templates/app/_option/render/static/_option/server/yes/_option/styling/css/_option/language/ts/README.md +16 -0
- package/esdev/templates/app/_option/render/static/_option/server/yes/_option/styling/css/_option/language/ts/app/layout.tsx +14 -0
- package/esdev/templates/app/_option/render/static/_option/server/yes/_option/styling/css/_option/language/ts/package.json +21 -0
- package/esdev/templates/app/_option/render/static/_option/server/yes/_option/styling/tailwind/_option/language/js/README.md +16 -0
- package/esdev/templates/app/_option/render/static/_option/server/yes/_option/styling/tailwind/_option/language/js/app/layout.jsx +14 -0
- package/esdev/templates/app/_option/render/static/_option/server/yes/_option/styling/tailwind/_option/language/js/package.json +20 -0
- package/esdev/templates/app/_option/render/static/_option/server/yes/_option/styling/tailwind/_option/language/ts/README.md +17 -0
- package/esdev/templates/app/_option/render/static/_option/server/yes/_option/styling/tailwind/_option/language/ts/app/layout.tsx +14 -0
- package/esdev/templates/app/_option/render/static/_option/server/yes/_option/styling/tailwind/_option/language/ts/package.json +22 -0
- package/esdev/templates/app/_option/render/static/_option/server/yes/esdev.json +28 -0
- package/esdev/templates/app/_option/server/yes/_option/language/js/app/_middleware.js +9 -0
- package/esdev/templates/app/_option/server/yes/_option/language/js/app/api/hello/route.js +4 -0
- package/esdev/templates/app/_option/server/yes/_option/language/js/app/todos/loader.js +7 -0
- package/esdev/templates/app/_option/server/yes/_option/language/js/app/todos/todos.server.js +15 -0
- package/esdev/templates/app/_option/server/yes/_option/language/js/tests/server/api.test.js +8 -0
- package/esdev/templates/app/_option/server/yes/_option/language/ts/app/_middleware.ts +9 -0
- package/esdev/templates/app/_option/server/yes/_option/language/ts/app/api/hello/route.ts +4 -0
- package/esdev/templates/app/_option/server/yes/_option/language/ts/app/todos/loader.ts +7 -0
- package/esdev/templates/app/_option/server/yes/_option/language/ts/app/todos/todos.server.ts +15 -0
- package/esdev/templates/app/_option/server/yes/_option/language/ts/tests/server/api.test.ts +8 -0
- package/esdev/templates/app/_option/server/yes/_option/styling/css/_option/language/js/app/todos/page.jsx +29 -0
- package/esdev/templates/app/_option/server/yes/_option/styling/css/_option/language/ts/app/todos/page.tsx +29 -0
- package/esdev/templates/app/_option/server/yes/_option/styling/tailwind/_option/language/js/app/todos/page.jsx +29 -0
- package/esdev/templates/app/_option/server/yes/_option/styling/tailwind/_option/language/ts/app/todos/page.tsx +29 -0
- package/esdev/templates/app/_option/server/yes/server.js +53 -0
- package/esdev/templates/app/_option/styling/css/_option/language/js/app/Counter.jsx +10 -0
- package/esdev/templates/app/_option/styling/css/_option/language/js/app/page.jsx +13 -0
- package/esdev/templates/app/_option/styling/css/_option/language/ts/app/Counter.tsx +10 -0
- package/esdev/templates/app/_option/styling/css/_option/language/ts/app/page.tsx +13 -0
- package/esdev/templates/app/_option/styling/css/app/global.css +16 -0
- package/esdev/templates/app/_option/styling/tailwind/_option/language/js/app/Counter.jsx +10 -0
- package/esdev/templates/app/_option/styling/tailwind/_option/language/js/app/page.jsx +13 -0
- package/esdev/templates/app/_option/styling/tailwind/_option/language/ts/app/Counter.tsx +10 -0
- package/esdev/templates/app/_option/styling/tailwind/_option/language/ts/app/page.tsx +13 -0
- package/esdev/templates/app/_option/styling/tailwind/app/global.css +7 -0
- package/esdev/templates/app/app/about/page.md +7 -0
- package/esdev/templates/app/template.json +96 -0
- package/esdev/templates/catalog.json +15 -0
- package/esdev/templates/docs/_gitignore +18 -0
- package/esdev/templates/docs/_option/blog/no/_option/language/js/README.md +14 -0
- package/esdev/templates/docs/_option/blog/no/_option/language/js/app/page.jsx +15 -0
- package/esdev/templates/docs/_option/blog/no/_option/language/js/tests/ui/Home.test.js +9 -0
- package/esdev/templates/docs/_option/blog/no/_option/language/ts/README.md +15 -0
- package/esdev/templates/docs/_option/blog/no/_option/language/ts/app/page.tsx +15 -0
- package/esdev/templates/docs/_option/blog/no/_option/language/ts/tests/ui/Home.test.ts +9 -0
- package/esdev/templates/docs/_option/blog/no/afw.config.js +13 -0
- package/esdev/templates/docs/_option/blog/yes/_option/language/js/README.md +14 -0
- package/esdev/templates/docs/_option/blog/yes/_option/language/js/app/blog/layout.jsx +7 -0
- package/esdev/templates/docs/_option/blog/yes/_option/language/js/app/blog/page.jsx +13 -0
- package/esdev/templates/docs/_option/blog/yes/_option/language/js/app/page.jsx +15 -0
- package/esdev/templates/docs/_option/blog/yes/_option/language/js/tests/ui/Home.test.js +10 -0
- package/esdev/templates/docs/_option/blog/yes/_option/language/ts/README.md +15 -0
- package/esdev/templates/docs/_option/blog/yes/_option/language/ts/app/blog/layout.tsx +7 -0
- package/esdev/templates/docs/_option/blog/yes/_option/language/ts/app/blog/page.tsx +13 -0
- package/esdev/templates/docs/_option/blog/yes/_option/language/ts/app/page.tsx +15 -0
- package/esdev/templates/docs/_option/blog/yes/_option/language/ts/tests/ui/Home.test.ts +10 -0
- package/esdev/templates/docs/_option/blog/yes/afw.config.js +15 -0
- package/esdev/templates/docs/_option/blog/yes/app/blog/hello-world/page.mdx +10 -0
- package/esdev/templates/docs/_option/language/js/app/_config.js +4 -0
- package/esdev/templates/docs/_option/language/js/app/docs/layout.jsx +6 -0
- package/esdev/templates/docs/_option/language/js/app/layout.jsx +3 -0
- package/esdev/templates/docs/_option/language/js/entry.js +6 -0
- package/esdev/templates/docs/_option/language/js/index.html +12 -0
- package/esdev/templates/docs/_option/language/js/jsconfig.json +6 -0
- package/esdev/templates/docs/_option/language/js/package.json +21 -0
- package/esdev/templates/docs/_option/language/ts/app/_config.ts +4 -0
- package/esdev/templates/docs/_option/language/ts/app/docs/layout.tsx +6 -0
- package/esdev/templates/docs/_option/language/ts/app/layout.tsx +3 -0
- package/esdev/templates/docs/_option/language/ts/entry.ts +6 -0
- package/esdev/templates/docs/_option/language/ts/index.html +12 -0
- package/esdev/templates/docs/_option/language/ts/package.json +23 -0
- package/esdev/templates/docs/_option/language/ts/tsconfig.json +30 -0
- package/esdev/templates/docs/app/docs/_meta.js +5 -0
- package/esdev/templates/docs/app/docs/getting-started/page.mdx +11 -0
- package/esdev/templates/docs/app/docs/guides/writing-pages/page.mdx +20 -0
- package/esdev/templates/docs/app/docs/page.mdx +14 -0
- package/esdev/templates/docs/app/global.css +1 -0
- package/esdev/templates/docs/esdev.json +39 -0
- package/esdev/templates/docs/ssg.js +131 -0
- package/esdev/templates/docs/template.json +43 -0
- package/esdev/templates/library/_gitignore +18 -0
- package/esdev/templates/library/_option/language/js/entry.js +4 -0
- package/esdev/templates/library/_option/language/js/index.html +13 -0
- package/esdev/templates/library/_option/language/js/index.js +2 -0
- package/esdev/templates/library/_option/language/js/jsconfig.json +6 -0
- package/esdev/templates/library/_option/language/js/tests/ui/Counter.test.js +10 -0
- package/esdev/templates/library/_option/language/ts/entry.ts +4 -0
- package/esdev/templates/library/_option/language/ts/index.html +13 -0
- package/esdev/templates/library/_option/language/ts/index.ts +2 -0
- package/esdev/templates/library/_option/language/ts/tests/ui/Counter.test.ts +10 -0
- package/esdev/templates/library/_option/language/ts/tsconfig.json +30 -0
- package/esdev/templates/library/_option/styling/css/_option/language/js/README.md +12 -0
- package/esdev/templates/library/_option/styling/css/_option/language/js/app/page.jsx +10 -0
- package/esdev/templates/library/_option/styling/css/_option/language/js/package.json +26 -0
- package/esdev/templates/library/_option/styling/css/_option/language/js/src/Counter.jsx +10 -0
- package/esdev/templates/library/_option/styling/css/_option/language/ts/README.md +13 -0
- package/esdev/templates/library/_option/styling/css/_option/language/ts/app/page.tsx +10 -0
- package/esdev/templates/library/_option/styling/css/_option/language/ts/package.json +28 -0
- package/esdev/templates/library/_option/styling/css/_option/language/ts/src/Counter.tsx +10 -0
- package/esdev/templates/library/_option/styling/css/app/global.css +16 -0
- package/esdev/templates/library/_option/styling/tailwind/_option/language/js/README.md +13 -0
- package/esdev/templates/library/_option/styling/tailwind/_option/language/js/app/page.jsx +10 -0
- package/esdev/templates/library/_option/styling/tailwind/_option/language/js/package.json +27 -0
- package/esdev/templates/library/_option/styling/tailwind/_option/language/js/src/Counter.jsx +10 -0
- package/esdev/templates/library/_option/styling/tailwind/_option/language/ts/README.md +14 -0
- package/esdev/templates/library/_option/styling/tailwind/_option/language/ts/app/page.tsx +10 -0
- package/esdev/templates/library/_option/styling/tailwind/_option/language/ts/package.json +29 -0
- package/esdev/templates/library/_option/styling/tailwind/_option/language/ts/src/Counter.tsx +10 -0
- package/esdev/templates/library/_option/styling/tailwind/app/global.css +7 -0
- package/esdev/templates/library/esdev.json +18 -0
- package/esdev/templates/library/template.json +44 -0
- package/index.js +12 -21
- package/package.json +14 -9
- package/templates.js +257 -77
- package/versions.json +4 -4
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"plugins": [
|
|
3
|
+
{
|
|
4
|
+
"module": "@opentf/esdev-plugin-afw",
|
|
5
|
+
"options": {
|
|
6
|
+
"appDir": "app"
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
],
|
|
10
|
+
"build": {
|
|
11
|
+
"targets": {
|
|
12
|
+
"web": {
|
|
13
|
+
"entry": "index.html",
|
|
14
|
+
"outdir": "dist"
|
|
15
|
+
},
|
|
16
|
+
"server": {
|
|
17
|
+
"entry": "server.js",
|
|
18
|
+
"out": "dist/server.js"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"dev": {
|
|
23
|
+
"run": "server",
|
|
24
|
+
"app": {
|
|
25
|
+
"port": 3000
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Runs for every request: pages, API routes, loader data and server functions alike.
|
|
2
|
+
// Authenticate here (set `context.locals.user`); each server function checks what
|
|
3
|
+
// that user may read or change.
|
|
4
|
+
export default async function middleware(request, context, next) {
|
|
5
|
+
context.locals.requestId = crypto.randomUUID();
|
|
6
|
+
const response = await next();
|
|
7
|
+
response.headers.set("x-request-id", String(context.locals.requestId));
|
|
8
|
+
return response;
|
|
9
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Loaders run on the server and feed their page through `router.data`. A server
|
|
2
|
+
// function called from server code runs directly, with no HTTP request.
|
|
3
|
+
import { listTodos } from "./todos.server.js";
|
|
4
|
+
|
|
5
|
+
export default async function loader({ locals }) {
|
|
6
|
+
return { todos: await listTodos(undefined, { locals }) };
|
|
7
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Server functions: this module runs only on the server. Components import the
|
|
2
|
+
// functions below and call them like async functions; the browser gets fetch stubs.
|
|
3
|
+
import { action, query } from "@opentf/afw/server";
|
|
4
|
+
|
|
5
|
+
// In memory for the example: use your database here.
|
|
6
|
+
const todos = ["Try the dev server", "Add an API route", "Deploy with npm start"];
|
|
7
|
+
|
|
8
|
+
export const listTodos = query(async () => todos);
|
|
9
|
+
|
|
10
|
+
export const addTodo = action(async ({ title }) => {
|
|
11
|
+
const text = String(title ?? "").trim();
|
|
12
|
+
if (!text) throw new Response(null, { status: 400 });
|
|
13
|
+
todos.push(text);
|
|
14
|
+
return todos;
|
|
15
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { expect, test } from "@opentf/afw-test/test";
|
|
2
|
+
import { GET } from "../../app/api/hello/route.js";
|
|
3
|
+
|
|
4
|
+
test("GET /api/hello greets by name", async () => {
|
|
5
|
+
const response = GET(new Request("http://localhost/api/hello?name=AFW"), { query: { name: "AFW" }, locals: { requestId: "r1" } });
|
|
6
|
+
expect(response.status).toBe(200);
|
|
7
|
+
expect(await response.json()).toEqual({ message: "Hello, AFW!", requestId: "r1" });
|
|
8
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Runs for every request: pages, API routes, loader data and server functions alike.
|
|
2
|
+
// Authenticate here (set `context.locals.user`); each server function checks what
|
|
3
|
+
// that user may read or change.
|
|
4
|
+
export default async function middleware(request: Request, context: { locals: Record<string, unknown> }, next: () => Promise<Response>) {
|
|
5
|
+
context.locals.requestId = crypto.randomUUID();
|
|
6
|
+
const response = await next();
|
|
7
|
+
response.headers.set("x-request-id", String(context.locals.requestId));
|
|
8
|
+
return response;
|
|
9
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// GET /api/hello?name=… — API routes run on Node, so any npm package works here.
|
|
2
|
+
export function GET(request: Request, { query, locals }: { query: Record<string, string>; locals: Record<string, unknown> }) {
|
|
3
|
+
return Response.json({ message: `Hello, ${query.name ?? "world"}!`, requestId: locals.requestId });
|
|
4
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Loaders run on the server and feed their page through `router.data`. A server
|
|
2
|
+
// function called from server code runs directly, with no HTTP request.
|
|
3
|
+
import { listTodos } from "./todos.server.ts";
|
|
4
|
+
|
|
5
|
+
export default async function loader({ locals }: { locals: Record<string, unknown> }) {
|
|
6
|
+
return { todos: await listTodos(undefined, { locals }) };
|
|
7
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Server functions: this module runs only on the server. Components import the
|
|
2
|
+
// functions below and call them like async functions; the browser gets fetch stubs.
|
|
3
|
+
import { action, query } from "@opentf/afw/server";
|
|
4
|
+
|
|
5
|
+
// In memory for the example: use your database here.
|
|
6
|
+
const todos: string[] = ["Try the dev server", "Add an API route", "Deploy with npm start"];
|
|
7
|
+
|
|
8
|
+
export const listTodos = query(async () => todos);
|
|
9
|
+
|
|
10
|
+
export const addTodo = action(async ({ title }: { title: string }) => {
|
|
11
|
+
const text = String(title ?? "").trim();
|
|
12
|
+
if (!text) throw new Response(null, { status: 400 });
|
|
13
|
+
todos.push(text);
|
|
14
|
+
return todos;
|
|
15
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { expect, test } from "@opentf/afw-test/test";
|
|
2
|
+
import { GET } from "../../app/api/hello/route.ts";
|
|
3
|
+
|
|
4
|
+
test("GET /api/hello greets by name", async () => {
|
|
5
|
+
const response = GET(new Request("http://localhost/api/hello?name=AFW"), { query: { name: "AFW" }, locals: { requestId: "r1" } });
|
|
6
|
+
expect(response.status).toBe(200);
|
|
7
|
+
expect(await response.json()).toEqual({ message: "Hello, AFW!", requestId: "r1" });
|
|
8
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { invalidate, router } from "@opentf/afw";
|
|
2
|
+
import { addTodo } from "./todos.server.js";
|
|
3
|
+
|
|
4
|
+
export const metadata = { title: "Todos" };
|
|
5
|
+
|
|
6
|
+
export default function Todos() {
|
|
7
|
+
let title = $state("");
|
|
8
|
+
const todos = $derived(router.data?.todos ?? []);
|
|
9
|
+
|
|
10
|
+
async function add(event) {
|
|
11
|
+
event.preventDefault();
|
|
12
|
+
await addTodo({ title });
|
|
13
|
+
title = "";
|
|
14
|
+
await invalidate(); // reload this page's loader data
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<section>
|
|
19
|
+
<h1>Todos</h1>
|
|
20
|
+
<ul>
|
|
21
|
+
{todos.map((todo) => <li>{todo}</li>)}
|
|
22
|
+
</ul>
|
|
23
|
+
<form onsubmit={add}>
|
|
24
|
+
<input value={title} oninput={(e) => (title = (e.target).value)} placeholder="New todo" />
|
|
25
|
+
<button type="submit">Add</button>
|
|
26
|
+
</form>
|
|
27
|
+
</section>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { invalidate, router } from "@opentf/afw";
|
|
2
|
+
import { addTodo } from "./todos.server.ts";
|
|
3
|
+
|
|
4
|
+
export const metadata = { title: "Todos" };
|
|
5
|
+
|
|
6
|
+
export default function Todos() {
|
|
7
|
+
let title = $state("");
|
|
8
|
+
const todos = $derived((router.data as { todos?: string[] } | undefined)?.todos ?? []);
|
|
9
|
+
|
|
10
|
+
async function add(event: SubmitEvent) {
|
|
11
|
+
event.preventDefault();
|
|
12
|
+
await addTodo({ title });
|
|
13
|
+
title = "";
|
|
14
|
+
await invalidate(); // reload this page's loader data
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<section>
|
|
19
|
+
<h1>Todos</h1>
|
|
20
|
+
<ul>
|
|
21
|
+
{todos.map((todo: string) => <li>{todo}</li>)}
|
|
22
|
+
</ul>
|
|
23
|
+
<form onsubmit={add}>
|
|
24
|
+
<input value={title} oninput={(e: Event) => (title = (e.target as HTMLInputElement).value)} placeholder="New todo" />
|
|
25
|
+
<button type="submit">Add</button>
|
|
26
|
+
</form>
|
|
27
|
+
</section>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { invalidate, router } from "@opentf/afw";
|
|
2
|
+
import { addTodo } from "./todos.server.js";
|
|
3
|
+
|
|
4
|
+
export const metadata = { title: "Todos" };
|
|
5
|
+
|
|
6
|
+
export default function Todos() {
|
|
7
|
+
let title = $state("");
|
|
8
|
+
const todos = $derived(router.data?.todos ?? []);
|
|
9
|
+
|
|
10
|
+
async function add(event) {
|
|
11
|
+
event.preventDefault();
|
|
12
|
+
await addTodo({ title });
|
|
13
|
+
title = "";
|
|
14
|
+
await invalidate(); // reload this page's loader data
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<section>
|
|
19
|
+
<h1 class="mb-4 text-2xl font-bold">Todos</h1>
|
|
20
|
+
<ul class="mb-4 list-disc pl-6">
|
|
21
|
+
{todos.map((todo) => <li>{todo}</li>)}
|
|
22
|
+
</ul>
|
|
23
|
+
<form onsubmit={add}>
|
|
24
|
+
<input class="rounded-md border px-2 py-1" value={title} oninput={(e) => (title = (e.target).value)} placeholder="New todo" />
|
|
25
|
+
<button class="ml-2 rounded-md bg-sky-600 px-3 py-1 text-white" type="submit">Add</button>
|
|
26
|
+
</form>
|
|
27
|
+
</section>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { invalidate, router } from "@opentf/afw";
|
|
2
|
+
import { addTodo } from "./todos.server.ts";
|
|
3
|
+
|
|
4
|
+
export const metadata = { title: "Todos" };
|
|
5
|
+
|
|
6
|
+
export default function Todos() {
|
|
7
|
+
let title = $state("");
|
|
8
|
+
const todos = $derived((router.data as { todos?: string[] } | undefined)?.todos ?? []);
|
|
9
|
+
|
|
10
|
+
async function add(event: SubmitEvent) {
|
|
11
|
+
event.preventDefault();
|
|
12
|
+
await addTodo({ title });
|
|
13
|
+
title = "";
|
|
14
|
+
await invalidate(); // reload this page's loader data
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<section>
|
|
19
|
+
<h1 class="mb-4 text-2xl font-bold">Todos</h1>
|
|
20
|
+
<ul class="mb-4 list-disc pl-6">
|
|
21
|
+
{todos.map((todo: string) => <li>{todo}</li>)}
|
|
22
|
+
</ul>
|
|
23
|
+
<form onsubmit={add}>
|
|
24
|
+
<input class="rounded-md border px-2 py-1" value={title} oninput={(e: Event) => (title = (e.target as HTMLInputElement).value)} placeholder="New todo" />
|
|
25
|
+
<button class="ml-2 rounded-md bg-sky-600 px-3 py-1 text-white" type="submit">Add</button>
|
|
26
|
+
</form>
|
|
27
|
+
</section>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// Production + dev server. `@afw/server` is generated from `app/`: it runs the
|
|
2
|
+
// middleware around API routes, server functions, loader data and pages, so a new
|
|
3
|
+
// route, loader or middleware needs no edit here. What stays yours is how static
|
|
4
|
+
// files are served.
|
|
5
|
+
import { serve } from "runtime:http";
|
|
6
|
+
import { file } from "runtime:fs";
|
|
7
|
+
import { env } from "runtime:process";
|
|
8
|
+
import * as app from "@afw/server";
|
|
9
|
+
|
|
10
|
+
// Beside this bundle: `dist/` in production, `.dev/dist/` under `esdev start`.
|
|
11
|
+
const outDir = new URL("./", import.meta.url);
|
|
12
|
+
|
|
13
|
+
// Built assets. Pages are not files: `/` and `*.html` go to the page step. Only a
|
|
14
|
+
// regular file is one: `/assets/` names a directory, which goes on to the fallback's
|
|
15
|
+
// 404 like any other path that is not a file.
|
|
16
|
+
async function files(request) {
|
|
17
|
+
const { pathname } = new URL(request.url);
|
|
18
|
+
if (pathname === "/" || pathname.endsWith(".html")) return null;
|
|
19
|
+
const asset = file(new URL(`.${pathname}`, outDir));
|
|
20
|
+
const isFile = await asset.stat().then((stat) => stat.isFile, () => false);
|
|
21
|
+
if (!isFile) return null;
|
|
22
|
+
// The runtime's type for the extension: module scripts are refused without a
|
|
23
|
+
// JavaScript one.
|
|
24
|
+
const type = asset.type || "application/octet-stream";
|
|
25
|
+
return new Response(asset.stream(), { headers: { "content-type": type } });
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// A static route's page as the build prerendered it (`<path>/index.html`), or null.
|
|
29
|
+
async function readStatic(pathname) {
|
|
30
|
+
const page = file(new URL(`.${pathname.replace(/\/?$/, "/")}index.html`, outDir));
|
|
31
|
+
return (await page.exists()) ? page.text() : null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const shell = await file(new URL("./index.html", outDir)).text();
|
|
35
|
+
const html = (body) => new Response(body, { headers: { "content-type": "text/html; charset=utf-8" } });
|
|
36
|
+
|
|
37
|
+
// Pages: rendered per route policy when the app renders any page on the server or at
|
|
38
|
+
// build time (`app/_config.js`); otherwise every page is the shell, rendered in the
|
|
39
|
+
// browser, which shows its own 404 for an unknown path.
|
|
40
|
+
const renderPage = app.createPageRenderer
|
|
41
|
+
? app.createPageRenderer({ shell, readStatic })
|
|
42
|
+
: async (request) => (["GET", "HEAD"].includes(request.method.toUpperCase()) ? html(request.method.toUpperCase() === "HEAD" ? null : shell) : null);
|
|
43
|
+
|
|
44
|
+
const server = serve(
|
|
45
|
+
{ port: Number(env.PORT ?? "3000") },
|
|
46
|
+
app.createHandler({
|
|
47
|
+
files,
|
|
48
|
+
renderPage,
|
|
49
|
+
fallback: () => new Response("Not found", { status: 404 }),
|
|
50
|
+
}),
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
console.log(`listening on http://localhost:${(await server.addr).port}`);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import Counter from "./Counter.jsx";
|
|
2
|
+
|
|
3
|
+
export const metadata = { title: "{{name}}" };
|
|
4
|
+
|
|
5
|
+
export default function Home() {
|
|
6
|
+
return (
|
|
7
|
+
<section>
|
|
8
|
+
<h1>{{name}}</h1>
|
|
9
|
+
<p>Edit <code>app/page.jsx</code> and save: the page updates in place.</p>
|
|
10
|
+
<Counter start={0} />
|
|
11
|
+
</section>
|
|
12
|
+
);
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import Counter from "./Counter.tsx";
|
|
2
|
+
|
|
3
|
+
export const metadata = { title: "{{name}}" };
|
|
4
|
+
|
|
5
|
+
export default function Home() {
|
|
6
|
+
return (
|
|
7
|
+
<section>
|
|
8
|
+
<h1>{{name}}</h1>
|
|
9
|
+
<p>Edit <code>app/page.tsx</code> and save: the page updates in place.</p>
|
|
10
|
+
<Counter start={0} />
|
|
11
|
+
</section>
|
|
12
|
+
);
|
|
13
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export default function Counter({ start = 0 }) {
|
|
2
|
+
let count = $state(start);
|
|
3
|
+
const doubled = $derived(count * 2);
|
|
4
|
+
|
|
5
|
+
return (
|
|
6
|
+
<p>
|
|
7
|
+
<button class="rounded-md bg-sky-600 px-3 py-1 text-white" onclick={() => count++}>Count: {count}</button> Doubled: {doubled}
|
|
8
|
+
</p>
|
|
9
|
+
);
|
|
10
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import Counter from "./Counter.jsx";
|
|
2
|
+
|
|
3
|
+
export const metadata = { title: "{{name}}" };
|
|
4
|
+
|
|
5
|
+
export default function Home() {
|
|
6
|
+
return (
|
|
7
|
+
<section>
|
|
8
|
+
<h1 class="mb-4 text-3xl font-bold">{{name}}</h1>
|
|
9
|
+
<p>Edit <code>app/page.jsx</code> and save: the page updates in place.</p>
|
|
10
|
+
<Counter start={0} />
|
|
11
|
+
</section>
|
|
12
|
+
);
|
|
13
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export default function Counter({ start = 0 }: { start?: number }) {
|
|
2
|
+
let count = $state(start);
|
|
3
|
+
const doubled = $derived(count * 2);
|
|
4
|
+
|
|
5
|
+
return (
|
|
6
|
+
<p>
|
|
7
|
+
<button class="rounded-md bg-sky-600 px-3 py-1 text-white" onclick={() => count++}>Count: {count}</button> Doubled: {doubled}
|
|
8
|
+
</p>
|
|
9
|
+
);
|
|
10
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import Counter from "./Counter.tsx";
|
|
2
|
+
|
|
3
|
+
export const metadata = { title: "{{name}}" };
|
|
4
|
+
|
|
5
|
+
export default function Home() {
|
|
6
|
+
return (
|
|
7
|
+
<section>
|
|
8
|
+
<h1 class="mb-4 text-3xl font-bold">{{name}}</h1>
|
|
9
|
+
<p>Edit <code>app/page.tsx</code> and save: the page updates in place.</p>
|
|
10
|
+
<Counter start={0} />
|
|
11
|
+
</section>
|
|
12
|
+
);
|
|
13
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
{
|
|
2
|
+
"label": "App",
|
|
3
|
+
"description": "An app: choose how pages render and whether it has a server",
|
|
4
|
+
"group": "AFW",
|
|
5
|
+
"options": [
|
|
6
|
+
{
|
|
7
|
+
"name": "render",
|
|
8
|
+
"question": "How should pages render by default? (any folder can change it later with its own _config.js)",
|
|
9
|
+
"kind": "choice",
|
|
10
|
+
"default": "client",
|
|
11
|
+
"choices": [
|
|
12
|
+
{
|
|
13
|
+
"value": "client",
|
|
14
|
+
"label": "Client",
|
|
15
|
+
"description": "Rendered in the browser: apps behind a login"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"value": "server",
|
|
19
|
+
"label": "Server",
|
|
20
|
+
"description": "Rendered per request: content sites, search, anything with SEO"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"value": "static",
|
|
24
|
+
"label": "Static",
|
|
25
|
+
"description": "Built once at build time: marketing sites, docs, blogs"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"value": "mixed",
|
|
29
|
+
"label": "Mixed",
|
|
30
|
+
"description": "Server by default, plus a static page and a client section to copy"
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"name": "server",
|
|
36
|
+
"question": "Add a server? (API routes, middleware, loaders and server functions)",
|
|
37
|
+
"kind": "confirm",
|
|
38
|
+
"default": "no",
|
|
39
|
+
"when": {
|
|
40
|
+
"render": [
|
|
41
|
+
"client",
|
|
42
|
+
"static"
|
|
43
|
+
]
|
|
44
|
+
},
|
|
45
|
+
"otherwise": "yes",
|
|
46
|
+
"choices": [
|
|
47
|
+
{
|
|
48
|
+
"value": "yes",
|
|
49
|
+
"label": "Yes",
|
|
50
|
+
"description": "API routes, middleware, loaders and server functions"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"value": "no",
|
|
54
|
+
"label": "No",
|
|
55
|
+
"description": "Pages only"
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"name": "styling",
|
|
61
|
+
"question": "Select a styling:",
|
|
62
|
+
"kind": "choice",
|
|
63
|
+
"unattended": "css",
|
|
64
|
+
"choices": [
|
|
65
|
+
{
|
|
66
|
+
"value": "css",
|
|
67
|
+
"label": "CSS",
|
|
68
|
+
"description": "CSS"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"value": "tailwind",
|
|
72
|
+
"label": "Tailwind CSS",
|
|
73
|
+
"description": "Tailwind CSS"
|
|
74
|
+
}
|
|
75
|
+
]
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"name": "language",
|
|
79
|
+
"question": "Select a language:",
|
|
80
|
+
"kind": "choice",
|
|
81
|
+
"default": "ts",
|
|
82
|
+
"choices": [
|
|
83
|
+
{
|
|
84
|
+
"value": "ts",
|
|
85
|
+
"label": "TypeScript",
|
|
86
|
+
"description": "TypeScript: .tsx sources and a tsconfig.json"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"value": "js",
|
|
90
|
+
"label": "JavaScript",
|
|
91
|
+
"description": "JavaScript: .jsx sources"
|
|
92
|
+
}
|
|
93
|
+
]
|
|
94
|
+
}
|
|
95
|
+
]
|
|
96
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# {{name}}
|
|
2
|
+
|
|
3
|
+
A documentation site built with [AFW](https://afw.opentechf.org) and `@opentf/afw-docs` on esdev and ES-Runtime.
|
|
4
|
+
|
|
5
|
+
| Command | What it does |
|
|
6
|
+
| --- | --- |
|
|
7
|
+
| `{{pm}} run dev` | Start the dev server |
|
|
8
|
+
| `{{pm}} run build` | Build for production |
|
|
9
|
+
| `{{pm}} run preview` | Preview the production build |
|
|
10
|
+
| `{{pm}} run test` | Run the tests with esdev |
|
|
11
|
+
|
|
12
|
+
- Docs pages live in `app/docs/`; `app/docs/_meta.js` orders the sidebar.
|
|
13
|
+
- `{{pm}} run build` prerenders every page and writes the search index, `sitemap.xml` and `llms.txt`.
|
|
14
|
+
- Set your site's URL in `afw.config.js`.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Link } from "@opentf/afw";
|
|
2
|
+
|
|
3
|
+
export const metadata = { title: "{{name}}", description: "Documentation." };
|
|
4
|
+
|
|
5
|
+
export default function Home() {
|
|
6
|
+
return (
|
|
7
|
+
<main class="afwd-prose">
|
|
8
|
+
<h1>{{name}}</h1>
|
|
9
|
+
<p>Documentation, written in MDX.</p>
|
|
10
|
+
<p>
|
|
11
|
+
<Link href="/docs">Read the docs</Link>
|
|
12
|
+
</p>
|
|
13
|
+
</main>
|
|
14
|
+
);
|
|
15
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { expect, test } from "@opentf/afw-test/test";
|
|
2
|
+
import { render } from "@opentf/afw-test";
|
|
3
|
+
import Home from "../../app/page.jsx";
|
|
4
|
+
|
|
5
|
+
test("the home page links to the docs", () => {
|
|
6
|
+
const { getByRole } = render(Home);
|
|
7
|
+
expect(getByRole("heading", { level: 1 }).textContent).toBe("{{name}}");
|
|
8
|
+
expect(getByRole("link", { name: "Read the docs" }).getAttribute("href")).toBe("/docs");
|
|
9
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# {{name}}
|
|
2
|
+
|
|
3
|
+
A documentation site built with [AFW](https://afw.opentechf.org) and `@opentf/afw-docs` on esdev and ES-Runtime.
|
|
4
|
+
|
|
5
|
+
| Command | What it does |
|
|
6
|
+
| --- | --- |
|
|
7
|
+
| `{{pm}} run dev` | Start the dev server |
|
|
8
|
+
| `{{pm}} run build` | Build for production |
|
|
9
|
+
| `{{pm}} run preview` | Preview the production build |
|
|
10
|
+
| `{{pm}} run test` | Run the tests with esdev |
|
|
11
|
+
| `{{pm}} run typecheck` | Check types |
|
|
12
|
+
|
|
13
|
+
- Docs pages live in `app/docs/`; `app/docs/_meta.js` orders the sidebar.
|
|
14
|
+
- `{{pm}} run build` prerenders every page and writes the search index, `sitemap.xml` and `llms.txt`.
|
|
15
|
+
- Set your site's URL in `afw.config.js`.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Link } from "@opentf/afw";
|
|
2
|
+
|
|
3
|
+
export const metadata = { title: "{{name}}", description: "Documentation." };
|
|
4
|
+
|
|
5
|
+
export default function Home() {
|
|
6
|
+
return (
|
|
7
|
+
<main class="afwd-prose">
|
|
8
|
+
<h1>{{name}}</h1>
|
|
9
|
+
<p>Documentation, written in MDX.</p>
|
|
10
|
+
<p>
|
|
11
|
+
<Link href="/docs">Read the docs</Link>
|
|
12
|
+
</p>
|
|
13
|
+
</main>
|
|
14
|
+
);
|
|
15
|
+
}
|