@beatzball/create-litro 0.1.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.
Files changed (100) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/LICENSE +185 -0
  3. package/README.md +89 -0
  4. package/dist/recipes/11ty-blog/recipe.config.d.ts +4 -0
  5. package/dist/recipes/11ty-blog/recipe.config.d.ts.map +1 -0
  6. package/dist/recipes/11ty-blog/recipe.config.js +9 -0
  7. package/dist/recipes/11ty-blog/recipe.config.js.map +1 -0
  8. package/dist/recipes/11ty-blog/recipe.config.ts +11 -0
  9. package/dist/recipes/11ty-blog/template/app.ts +18 -0
  10. package/dist/recipes/11ty-blog/template/content/_data/metadata.js +10 -0
  11. package/dist/recipes/11ty-blog/template/content/blog/blog.11tydata.json +1 -0
  12. package/dist/recipes/11ty-blog/template/content/blog/getting-started/index.md +66 -0
  13. package/dist/recipes/11ty-blog/template/content/blog/hello-world.md +39 -0
  14. package/dist/recipes/11ty-blog/template/litro.recipe.json +7 -0
  15. package/dist/recipes/11ty-blog/template/nitro.config.ts +60 -0
  16. package/dist/recipes/11ty-blog/template/package.json +26 -0
  17. package/dist/recipes/11ty-blog/template/pages/blog/[slug].ts +65 -0
  18. package/dist/recipes/11ty-blog/template/pages/blog/index.ts +43 -0
  19. package/dist/recipes/11ty-blog/template/pages/index.ts +58 -0
  20. package/dist/recipes/11ty-blog/template/pages/tags/[tag].ts +53 -0
  21. package/dist/recipes/11ty-blog/template/public/.gitkeep +0 -0
  22. package/dist/recipes/11ty-blog/template/server/api/hello.ts +6 -0
  23. package/dist/recipes/11ty-blog/template/server/api/posts.ts +8 -0
  24. package/dist/recipes/11ty-blog/template/server/middleware/vite-dev.ts +29 -0
  25. package/dist/recipes/11ty-blog/template/server/routes/[...].ts +55 -0
  26. package/dist/recipes/11ty-blog/template/tsconfig.json +14 -0
  27. package/dist/recipes/11ty-blog/template/vite.config.ts +19 -0
  28. package/dist/recipes/fullstack/recipe.config.d.ts +4 -0
  29. package/dist/recipes/fullstack/recipe.config.d.ts.map +1 -0
  30. package/dist/recipes/fullstack/recipe.config.js +8 -0
  31. package/dist/recipes/fullstack/recipe.config.js.map +1 -0
  32. package/dist/recipes/fullstack/recipe.config.ts +10 -0
  33. package/dist/recipes/fullstack/template/app.ts +20 -0
  34. package/dist/recipes/fullstack/template/nitro.config.ts +67 -0
  35. package/dist/recipes/fullstack/template/package.json +26 -0
  36. package/dist/recipes/fullstack/template/pages/blog/[slug].ts +43 -0
  37. package/dist/recipes/fullstack/template/pages/blog/index.ts +22 -0
  38. package/dist/recipes/fullstack/template/pages/index.ts +43 -0
  39. package/dist/recipes/fullstack/template/public/.gitkeep +0 -0
  40. package/dist/recipes/fullstack/template/server/api/hello.ts +6 -0
  41. package/dist/recipes/fullstack/template/server/middleware/vite-dev.ts +31 -0
  42. package/dist/recipes/fullstack/template/server/routes/[...].ts +59 -0
  43. package/dist/recipes/fullstack/template/tsconfig.json +14 -0
  44. package/dist/recipes/fullstack/template/vite.config.ts +15 -0
  45. package/dist/src/index.d.ts +17 -0
  46. package/dist/src/index.d.ts.map +1 -0
  47. package/dist/src/index.js +200 -0
  48. package/dist/src/index.js.map +1 -0
  49. package/dist/src/scaffold.d.ts +35 -0
  50. package/dist/src/scaffold.d.ts.map +1 -0
  51. package/dist/src/scaffold.js +166 -0
  52. package/dist/src/scaffold.js.map +1 -0
  53. package/dist/src/scaffold.test.d.ts +2 -0
  54. package/dist/src/scaffold.test.d.ts.map +1 -0
  55. package/dist/src/scaffold.test.js +204 -0
  56. package/dist/src/scaffold.test.js.map +1 -0
  57. package/dist/src/types.d.ts +23 -0
  58. package/dist/src/types.d.ts.map +1 -0
  59. package/dist/src/types.js +2 -0
  60. package/dist/src/types.js.map +1 -0
  61. package/dist/tsconfig.tsbuildinfo +1 -0
  62. package/package.json +28 -0
  63. package/recipes/11ty-blog/recipe.config.ts +11 -0
  64. package/recipes/11ty-blog/template/app.ts +18 -0
  65. package/recipes/11ty-blog/template/content/_data/metadata.js +10 -0
  66. package/recipes/11ty-blog/template/content/blog/blog.11tydata.json +1 -0
  67. package/recipes/11ty-blog/template/content/blog/getting-started/index.md +66 -0
  68. package/recipes/11ty-blog/template/content/blog/hello-world.md +39 -0
  69. package/recipes/11ty-blog/template/litro.recipe.json +7 -0
  70. package/recipes/11ty-blog/template/nitro.config.ts +60 -0
  71. package/recipes/11ty-blog/template/package.json +26 -0
  72. package/recipes/11ty-blog/template/pages/blog/[slug].ts +65 -0
  73. package/recipes/11ty-blog/template/pages/blog/index.ts +43 -0
  74. package/recipes/11ty-blog/template/pages/index.ts +58 -0
  75. package/recipes/11ty-blog/template/pages/tags/[tag].ts +53 -0
  76. package/recipes/11ty-blog/template/public/.gitkeep +0 -0
  77. package/recipes/11ty-blog/template/server/api/hello.ts +6 -0
  78. package/recipes/11ty-blog/template/server/api/posts.ts +8 -0
  79. package/recipes/11ty-blog/template/server/middleware/vite-dev.ts +29 -0
  80. package/recipes/11ty-blog/template/server/routes/[...].ts +55 -0
  81. package/recipes/11ty-blog/template/tsconfig.json +14 -0
  82. package/recipes/11ty-blog/template/vite.config.ts +19 -0
  83. package/recipes/fullstack/recipe.config.ts +10 -0
  84. package/recipes/fullstack/template/app.ts +20 -0
  85. package/recipes/fullstack/template/nitro.config.ts +67 -0
  86. package/recipes/fullstack/template/package.json +26 -0
  87. package/recipes/fullstack/template/pages/blog/[slug].ts +43 -0
  88. package/recipes/fullstack/template/pages/blog/index.ts +22 -0
  89. package/recipes/fullstack/template/pages/index.ts +43 -0
  90. package/recipes/fullstack/template/public/.gitkeep +0 -0
  91. package/recipes/fullstack/template/server/api/hello.ts +6 -0
  92. package/recipes/fullstack/template/server/middleware/vite-dev.ts +31 -0
  93. package/recipes/fullstack/template/server/routes/[...].ts +59 -0
  94. package/recipes/fullstack/template/tsconfig.json +14 -0
  95. package/recipes/fullstack/template/vite.config.ts +15 -0
  96. package/src/index.ts +229 -0
  97. package/src/scaffold.test.ts +228 -0
  98. package/src/scaffold.ts +202 -0
  99. package/src/types.ts +26 -0
  100. package/tsconfig.json +10 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,19 @@
1
+ # create-litro
2
+
3
+ ## 0.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 618a9b8: Rename all packages to `@beatzball` scope. The unscoped `litro` package was blocked by npm's name-similarity protection (too close to `lit`, `listr`, etc.). All three packages are now published under the `@beatzball` org scope:
8
+
9
+ - `litro` → `@beatzball/litro`
10
+ - `litro-router` → `@beatzball/litro-router`
11
+ - `create-litro` → `@beatzball/create-litro`
12
+
13
+ The previously published unscoped `litro-router@0.0.2` and `create-litro@0.0.2` are deprecated on npm with a redirect notice.
14
+
15
+ ## 0.0.2
16
+
17
+ ### Patch Changes
18
+
19
+ - 4552934: Add `license`, `repository`, and `publishConfig` fields to all published packages; configure Changesets for automated version management, per-package changelogs, and npm publishing via GitHub Actions.
package/LICENSE ADDED
@@ -0,0 +1,185 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship made available under
36
+ the License, as indicated by a copyright notice that is included in
37
+ or attached to the work (an example is provided in the Appendix below).
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other modifications
42
+ represent, as a whole, an original work of authorship. For the purposes
43
+ of this License, Derivative Works shall not include works that remain
44
+ separable from, or merely link (or bind by name) to the interfaces of,
45
+ the Work and Derivative Works thereof.
46
+
47
+ "Contribution" shall mean, as submitted to the Licensor for inclusion
48
+ in the Work by the copyright owner or by an individual or Legal Entity
49
+ authorized to submit on behalf of the copyright owner. For the purposes
50
+ of this definition, "submitted" means any form of electronic, verbal,
51
+ or written communication sent to the Licensor or its representatives,
52
+ including but not limited to communication on electronic mailing lists,
53
+ source code control systems, and issue tracking systems that are managed
54
+ by, or on behalf of, the Licensor for the purpose of discussing and
55
+ improving the Work, but excluding communication that is conspicuously
56
+ marked or otherwise designated in writing by the copyright owner as
57
+ "Not a Contribution."
58
+
59
+ "Contributor" shall mean Licensor and any Legal Entity on behalf of
60
+ whom a Contribution has been received by the Licensor and subsequently
61
+ incorporated within the Work.
62
+
63
+ 2. Grant of Copyright License. Subject to the terms and conditions of
64
+ this License, each Contributor hereby grants to You a perpetual,
65
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
66
+ copyright license to reproduce, prepare Derivative Works of,
67
+ publicly display, publicly perform, sublicense, and distribute the
68
+ Work and such Derivative Works in Source or Object form.
69
+
70
+ 3. Grant of Patent License. Subject to the terms and conditions of
71
+ this License, each Contributor hereby grants to You a perpetual,
72
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
73
+ (except as stated in this section) patent license to make, have made,
74
+ use, offer to sell, sell, import, and otherwise transfer the Work,
75
+ where such license applies only to those patent claims licensable
76
+ by such Contributor that are necessarily infringed by their
77
+ Contribution(s) alone or by combination of their Contribution(s)
78
+ with the Work to which such Contribution(s) was submitted. If You
79
+ institute patent litigation against any entity (including a cross-claim
80
+ or counterclaim in a lawsuit) alleging that the Work or any
81
+ Contribution incorporated within the Work constitutes direct or
82
+ contributory patent infringement, then any patent licenses granted to
83
+ You under this License for that Work shall terminate as of the date
84
+ such litigation is filed.
85
+
86
+ 4. Redistribution. You may reproduce and distribute copies of the
87
+ Work or Derivative Works thereof in any medium, with or without
88
+ modifications, and in Source or Object form, provided that You
89
+ meet the following conditions:
90
+
91
+ (a) You must give any other recipients of the Work or Derivative
92
+ Works a copy of this License; and
93
+
94
+ (b) You must cause any modified files to carry prominent notices
95
+ stating that You changed the files; and
96
+
97
+ (c) You must retain, in the Source form of any Derivative Works
98
+ that You distribute, all copyright, patent, trademark, and
99
+ attribution notices from the Source form of the Work,
100
+ excluding those notices that do not pertain to any part of
101
+ the Derivative Works; and
102
+
103
+ (d) If the Work includes a "NOTICE" text file as part of its
104
+ distribution, You must include a readable copy of the
105
+ attribution notices contained within such NOTICE file, in
106
+ at least one of the following places: within a NOTICE text
107
+ file distributed as part of the Derivative Works; within
108
+ the Source form or documentation, if provided along with the
109
+ Derivative Works; or, within a display generated by the
110
+ Derivative Works, if and wherever such third-party notices
111
+ normally appear. The contents of the NOTICE file are for
112
+ informational purposes only and do not modify the License.
113
+ You may add Your own attribution notices within Derivative
114
+ Works that You distribute, alongside or in addition to the
115
+ NOTICE text from the Work, provided that such additional
116
+ attribution notices cannot be construed as modifying the License.
117
+
118
+ You may add Your own license statement for Your modifications and
119
+ may provide additional grant of rights to use, reproduce, modify,
120
+ and distribute Your modifications, or for such Derivative Works as
121
+ a whole, under terms and conditions of Your choice, provided Your
122
+ use, reproduction, modification, and distribution of the Work
123
+ otherwise complies with the conditions stated in this License.
124
+
125
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
126
+ any Contribution intentionally submitted for inclusion in the Work
127
+ by You to the Licensor shall be under the terms and conditions of
128
+ this License, without any additional terms or conditions.
129
+ Notwithstanding the above, nothing herein shall supersede or modify
130
+ the terms of any separate license agreement you may have executed
131
+ with Licensor regarding such Contributions.
132
+
133
+ 6. Trademarks. This License does not grant permission to use the trade
134
+ names, trademarks, service marks, or product names of the Licensor,
135
+ except as required for reasonable and customary use in describing the
136
+ origin of the Work and reproducing the content of the NOTICE file.
137
+
138
+ 7. Disclaimer of Warranty. Unless required by applicable law or
139
+ agreed to in writing, Licensor provides the Work (and each
140
+ Contributor provides its Contributions) on an "AS IS" BASIS,
141
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
142
+ implied, including, without limitation, any warranties or conditions
143
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
144
+ PARTICULAR PURPOSE. You are solely responsible for determining the
145
+ appropriateness of using or reproducing the Work and assume any
146
+ risks associated with Your exercise of permissions under this License.
147
+
148
+ 8. Limitation of Liability. In no event and under no legal theory,
149
+ whether in tort (including negligence), contract, or otherwise,
150
+ unless required by applicable law (such as deliberate and grossly
151
+ negligent acts) or agreed to in writing, shall any Contributor be
152
+ liable to You for damages, including any direct, indirect, special,
153
+ incidental, or exemplary damages of any character arising as a
154
+ result of this License or out of the use or inability to use the
155
+ Work (including but not limited to damages for loss of goodwill,
156
+ work stoppage, computer failure or malfunction, or all other
157
+ commercial damages or losses), even if such Contributor has been
158
+ advised of the possibility of such damages.
159
+
160
+ 9. Accepting Warranty or Liability. While redistributing the Work or
161
+ Derivative Works thereof, You may choose to offer, and charge a fee
162
+ for, acceptance of support, warranty, indemnity, or other liability
163
+ obligations and/or rights consistent with this License. However, in
164
+ accepting such obligations, You may offer such obligations only on
165
+ Your own behalf and on Your sole responsibility, not on behalf of
166
+ any other Contributor, and only if You agree to indemnify, defend,
167
+ and hold each Contributor harmless for any liability incurred by, or
168
+ claims asserted against, such Contributor by reason of your accepting
169
+ any such warranty or additional liability.
170
+
171
+ END OF TERMS AND CONDITIONS
172
+
173
+ Copyright 2026 beatzball
174
+
175
+ Licensed under the Apache License, Version 2.0 (the "License");
176
+ you may not use this file except in compliance with the License.
177
+ You may obtain a copy of the License at
178
+
179
+ http://www.apache.org/licenses/LICENSE-2.0
180
+
181
+ Unless required by applicable law or agreed to in writing, software
182
+ distributed under the License is distributed on an "AS IS" BASIS,
183
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
184
+ See the License for the specific language governing permissions and
185
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,89 @@
1
+ # create-litro
2
+
3
+ Scaffold a new [Litro](https://github.com/beatzball/litro) app.
4
+
5
+ ## Usage
6
+
7
+ ```bash
8
+ npm create litro@latest my-app
9
+ # or
10
+ pnpm create litro my-app
11
+ # or
12
+ yarn create litro my-app
13
+ ```
14
+
15
+ Follow the interactive prompts to choose a recipe and rendering mode, or pass flags directly to skip them:
16
+
17
+ ```bash
18
+ # Fullstack SSR app (default)
19
+ npm create litro@latest my-app --recipe fullstack --mode ssr
20
+
21
+ # 11ty-compatible blog (SSG or SSR)
22
+ npm create litro@latest my-app --recipe 11ty-blog --mode ssg
23
+
24
+ # List all available recipes
25
+ npm create litro@latest -- --list-recipes
26
+ ```
27
+
28
+ ## Recipes
29
+
30
+ ### `fullstack` (default)
31
+
32
+ A fullstack Lit + Nitro app with file-based routing and server-side rendering.
33
+
34
+ Generated app includes:
35
+ - `pages/index.ts` — home page with `definePageData()` server fetching
36
+ - `pages/blog/index.ts` — blog listing page
37
+ - `pages/blog/[slug].ts` — dynamic post page with `generateRoutes()` for SSG
38
+ - `server/api/hello.ts` — JSON API endpoint
39
+ - Config files: `nitro.config.ts`, `vite.config.ts`, `tsconfig.json`
40
+
41
+ ### `11ty-blog`
42
+
43
+ A Markdown blog using the `litro:content` content layer, compatible with the 11ty data cascade format (frontmatter, `.11tydata.json` directory data, `_data/metadata.js` global data). Supports both SSR (dev server) and SSG (prerender to static HTML).
44
+
45
+ Generated app includes:
46
+ - `content/blog/` — Markdown posts with YAML frontmatter
47
+ - `content/_data/metadata.js` — global site metadata
48
+ - `pages/index.ts` — home page showing recent posts
49
+ - `pages/blog/index.ts` — post listing with all posts
50
+ - `pages/blog/[slug].ts` — individual post page with `generateRoutes()`
51
+ - `pages/tags/[tag].ts` — tag-filtered post listing
52
+ - `server/api/posts.ts` — JSON API for posts (optional `?tag=` filter)
53
+ - `litro.recipe.json` — written to the project root so the content plugin knows where to find posts
54
+
55
+ ## After scaffolding
56
+
57
+ ```bash
58
+ cd my-app
59
+ pnpm install
60
+ pnpm dev # start dev server on http://localhost:3030
61
+ ```
62
+
63
+ For static site generation:
64
+
65
+ ```bash
66
+ LITRO_MODE=static pnpm build # prerenders all routes to HTML
67
+ ```
68
+
69
+ ## The `litro:content` virtual module
70
+
71
+ The `11ty-blog` recipe uses `litro:content`, a virtual module provided by the Litro framework:
72
+
73
+ ```typescript
74
+ import { getPosts, getPost, getTags, getGlobalData } from 'litro:content';
75
+
76
+ // In a page file:
77
+ const posts = await getPosts({ tag: 'tutorial', limit: 5 });
78
+ const post = await getPost('hello-world');
79
+ const tags = await getTags();
80
+ const meta = await getGlobalData(); // reads _data/metadata.js
81
+ ```
82
+
83
+ The content layer reads Markdown files from the directory specified in `litro.recipe.json` (`contentDir`). Posts are sorted by date descending. Draft posts (frontmatter `draft: true`) are excluded by default.
84
+
85
+ Add `/// <reference types="litro/content/env" />` (or the equivalent `tsconfig.json` entry) for TypeScript type support.
86
+
87
+ ## License
88
+
89
+ Apache License 2.0 — Copyright 2026 beatzball.
@@ -0,0 +1,4 @@
1
+ import type { LitroRecipe } from '../../src/types.js';
2
+ declare const recipe: LitroRecipe;
3
+ export default recipe;
4
+ //# sourceMappingURL=recipe.config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recipe.config.d.ts","sourceRoot":"","sources":["../../../recipes/11ty-blog/recipe.config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD,QAAA,MAAM,MAAM,EAAE,WAMb,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -0,0 +1,9 @@
1
+ const recipe = {
2
+ name: '11ty-blog',
3
+ displayName: 'Blog (11ty-compatible content)',
4
+ description: '11ty-compatible Markdown blog with frontmatter, tags, and directory data',
5
+ mode: 'both',
6
+ contentLayer: 'content/blog',
7
+ };
8
+ export default recipe;
9
+ //# sourceMappingURL=recipe.config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recipe.config.js","sourceRoot":"","sources":["../../../recipes/11ty-blog/recipe.config.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,GAAgB;IAC1B,IAAI,EAAE,WAAW;IACjB,WAAW,EAAE,gCAAgC;IAC7C,WAAW,EAAE,0EAA0E;IACvF,IAAI,EAAE,MAAM;IACZ,YAAY,EAAE,cAAc;CAC7B,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { LitroRecipe } from '../../src/types.js';
2
+
3
+ const recipe: LitroRecipe = {
4
+ name: '11ty-blog',
5
+ displayName: 'Blog (11ty-compatible content)',
6
+ description: '11ty-compatible Markdown blog with frontmatter, tags, and directory data',
7
+ mode: 'both',
8
+ contentLayer: 'content/blog',
9
+ };
10
+
11
+ export default recipe;
@@ -0,0 +1,18 @@
1
+ // CRITICAL: must be first — patches LitElement before any component is loaded.
2
+ import '@lit-labs/ssr-client/lit-element-hydrate-support.js';
3
+
4
+ // Client runtime: router outlet and link custom elements.
5
+ import 'litro/runtime/LitroOutlet.js';
6
+ import 'litro/runtime/LitroLink.js';
7
+
8
+ // Routes generated by the page scanner before each vite build.
9
+ import { routes } from './routes.generated.js';
10
+
11
+ document.addEventListener('DOMContentLoaded', () => {
12
+ const outlet = document.querySelector('litro-outlet') as (Element & { routes: unknown }) | null;
13
+ if (outlet) {
14
+ outlet.routes = routes;
15
+ } else {
16
+ console.warn('[litro] <litro-outlet> not found — router will not start.');
17
+ }
18
+ });
@@ -0,0 +1,10 @@
1
+ export default {
2
+ title: '{{projectName}}',
3
+ url: 'https://example.com',
4
+ language: 'en',
5
+ description: 'A blog built with Litro',
6
+ author: {
7
+ name: 'Your Name',
8
+ email: 'your@email.com',
9
+ },
10
+ };
@@ -0,0 +1 @@
1
+ { "tags": ["posts"] }
@@ -0,0 +1,66 @@
1
+ ---
2
+ title: Getting Started with Litro
3
+ date: 2026-01-20
4
+ description: A step-by-step guide to setting up your Litro blog, writing posts, and deploying to production.
5
+ tags:
6
+ - posts
7
+ - tutorial
8
+ ---
9
+
10
+ ## Prerequisites
11
+
12
+ Before you begin, make sure you have [Node.js](https://nodejs.org) 20 or later and [pnpm](https://pnpm.io) installed. Then install the Litro CLI globally:
13
+
14
+ ```bash
15
+ npm install -g litro
16
+ ```
17
+
18
+ Or run it directly with your package manager:
19
+
20
+ ```bash
21
+ pnpm dlx litro dev
22
+ ```
23
+
24
+ ## Setting Up {{projectName}}
25
+
26
+ If you're reading this inside a freshly scaffolded project, you're already set up. To install dependencies and start the dev server:
27
+
28
+ ```bash
29
+ pnpm install
30
+ pnpm dev
31
+ ```
32
+
33
+ The dev server starts on `http://localhost:3030` by default. Vite handles HMR for your Lit components; Nitro handles SSR and API routes — both on a single port.
34
+
35
+ ## Writing Posts
36
+
37
+ Posts live in `content/blog/`. Each `.md` file becomes a route under `/blog/<slug>`. Subdirectories using the `index.md` convention (like this post) work exactly the same way.
38
+
39
+ ### Available Frontmatter Fields
40
+
41
+ | Field | Type | Required | Description |
42
+ |---------------|------------|----------|--------------------------------------------------|
43
+ | `title` | `string` | Yes | Shown in the post header and listing pages |
44
+ | `date` | `string` | Yes | ISO 8601 date (e.g. `2026-01-20`); used for sort |
45
+ | `description` | `string` | No | Short summary shown in post cards |
46
+ | `tags` | `string[]` | No | Additional tags beyond the inherited `posts` tag |
47
+ | `draft` | `boolean` | No | Set `true` to hide from listings in production |
48
+
49
+ ### Tags
50
+
51
+ Every post in `content/blog/` inherits the `posts` tag automatically via `blog.11tydata.json`. Add extra tags in the post's own frontmatter — they appear at `/tags/<tag>`.
52
+
53
+ ## Building for Production
54
+
55
+ ```bash
56
+ pnpm build # SSR build (Node.js server)
57
+ pnpm preview # preview the production build locally
58
+ ```
59
+
60
+ For a fully static site (no server required), set the mode to `static` before building:
61
+
62
+ ```bash
63
+ LITRO_MODE=static pnpm build
64
+ ```
65
+
66
+ Static mode prerenders every route returned by `generateRoutes()` to plain HTML files, which can be served from any CDN or object storage bucket.
@@ -0,0 +1,39 @@
1
+ ---
2
+ title: Hello, World!
3
+ date: 2026-01-15
4
+ description: Welcome to your new Litro blog — here's what you need to know to start writing.
5
+ tags:
6
+ - posts
7
+ - welcome
8
+ ---
9
+
10
+ ## Welcome to Your Litro Blog
11
+
12
+ You've just scaffolded a brand-new blog powered by Litro — a fullstack web framework that combines Lit web components with Nitro's battle-tested server engine. This post is here to help you get your bearings and understand how everything fits together.
13
+
14
+ Content lives in the `content/blog/` directory as plain Markdown files. Each file becomes a post. The frontmatter at the top of every file (the `---` fenced block) controls the post's title, date, description, and tags. The rest of the file is your post body, written in standard Markdown — headings, paragraphs, lists, links, code blocks, all of it.
15
+
16
+ ## Writing Your First Post
17
+
18
+ Create a new `.md` file inside `content/blog/` and fill in the frontmatter:
19
+
20
+ ```markdown
21
+ ---
22
+ title: My Second Post
23
+ date: 2026-02-01
24
+ description: A short summary shown on the blog listing page.
25
+ tags:
26
+ - posts
27
+ - my-tag
28
+ ---
29
+
30
+ Your post content goes here.
31
+ ```
32
+
33
+ The `tags` field accepts a list. Every post in `content/blog/` automatically inherits the `posts` tag from `blog.11tydata.json`, so you only need to list additional tags in the post's own frontmatter. Tag pages are generated automatically at `/tags/<tag>` — no extra configuration required.
34
+
35
+ ## How Content Is Served
36
+
37
+ Litro reads your Markdown files at build time (or on-demand in dev mode) using its content layer. The `getPosts()` function returns all published posts sorted newest-first, with each post's Markdown rendered to HTML in the `body` field. The `getPost(slug)` function fetches a single post by its URL slug, derived from the filename. For example, this file — `hello-world.md` — is available at `/blog/hello-world`.
38
+
39
+ Run `litro dev` to start the development server and visit `http://localhost:3030` to see your blog live. Changes to content files are picked up immediately without restarting the server.
@@ -0,0 +1,7 @@
1
+ {
2
+ "recipe": "11ty-blog",
3
+ "version": "{{recipeVersion}}",
4
+ "mode": "{{mode}}",
5
+ "contentDir": "content/blog",
6
+ "options": {}
7
+ }
@@ -0,0 +1,60 @@
1
+ import { defineNitroConfig } from 'nitropack/config';
2
+ import type { Nitro } from 'nitropack';
3
+ import { resolve } from 'node:path';
4
+ import { ssrPreset, ssgPreset } from '@beatzball/litro/config';
5
+ import pagesPlugin from '@beatzball/litro/plugins';
6
+ import ssgPlugin from '@beatzball/litro/plugins/ssg';
7
+ import contentPlugin from '@beatzball/litro/content/plugin';
8
+
9
+ const mode = process.env.LITRO_MODE ?? 'server';
10
+
11
+ export default defineNitroConfig({
12
+ ...(mode === 'static' ? ssgPreset() : ssrPreset()),
13
+
14
+ srcDir: 'server',
15
+
16
+ publicAssets: [
17
+ { dir: '../dist/client', baseURL: '/_litro/', maxAge: 31536000 },
18
+ { dir: '../public', baseURL: '/', maxAge: 0 },
19
+ // Serve co-located content images at their natural paths
20
+ { dir: '../content', baseURL: '/content/', maxAge: 86400 },
21
+ ],
22
+
23
+ externals: { inline: ['@lit-labs/ssr', '@lit-labs/ssr-client'] },
24
+
25
+ esbuild: {
26
+ options: {
27
+ tsconfigRaw: {
28
+ compilerOptions: {
29
+ experimentalDecorators: true,
30
+ useDefineForClassFields: false,
31
+ },
32
+ },
33
+ },
34
+ },
35
+
36
+ ignore: ['**/middleware/vite-dev.ts'],
37
+ handlers: [
38
+ {
39
+ middleware: true,
40
+ handler: resolve('./server/middleware/vite-dev.ts'),
41
+ env: 'dev',
42
+ },
43
+ ],
44
+
45
+ hooks: {
46
+ 'build:before': async (nitro: Nitro) => {
47
+ await contentPlugin(nitro);
48
+ await pagesPlugin(nitro);
49
+ await ssgPlugin(nitro);
50
+ },
51
+ },
52
+
53
+ compatibilityDate: '2025-01-01',
54
+
55
+ routeRules: {
56
+ '/_litro/**': {
57
+ headers: { 'cache-control': 'public, max-age=31536000, immutable' },
58
+ },
59
+ },
60
+ });
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "{{projectName}}",
3
+ "private": true,
4
+ "type": "module",
5
+ "imports": {
6
+ "#litro/page-manifest": "./server/stubs/page-manifest.ts"
7
+ },
8
+ "scripts": {
9
+ "dev": "litro dev",
10
+ "build": "litro build",
11
+ "preview": "litro preview",
12
+ "generate": "litro generate"
13
+ },
14
+ "dependencies": {
15
+ "@beatzball/litro": "latest",
16
+ "lit": "^3.2.1",
17
+ "@lit-labs/ssr": "^3.3.0",
18
+ "@lit-labs/ssr-client": "^1.1.7",
19
+ "h3": "^1.13.0"
20
+ },
21
+ "devDependencies": {
22
+ "nitropack": "^2.10.4",
23
+ "vite": "^5.4.11",
24
+ "typescript": "^5.7.3"
25
+ }
26
+ }
@@ -0,0 +1,65 @@
1
+ import { html } from 'lit';
2
+ import { unsafeHTML } from 'lit/directives/unsafe-html.js';
3
+ import { customElement, state } from 'lit/decorators.js';
4
+ import { LitroPage } from '@beatzball/litro/runtime';
5
+ import { definePageData } from '@beatzball/litro';
6
+ import { createError } from 'h3';
7
+ import type { Post } from 'litro:content';
8
+ import { getPost, getPosts } from 'litro:content';
9
+
10
+ export interface PostData {
11
+ post: Post;
12
+ }
13
+
14
+ function toDate(d: Date | string): Date { return d instanceof Date ? d : new Date(d as string); }
15
+
16
+ export const pageData = definePageData(async (event) => {
17
+ const slug = event.context.params?.slug ?? '';
18
+ const post = await getPost(slug);
19
+ if (!post) {
20
+ throw createError({ statusCode: 404, message: `Post not found: ${slug}` });
21
+ }
22
+ return { post } satisfies PostData;
23
+ });
24
+
25
+ export async function generateRoutes(): Promise<string[]> {
26
+ const posts = await getPosts();
27
+ return posts.map(post => post.url);
28
+ }
29
+
30
+ @customElement('page-blog-slug')
31
+ export class BlogPostPage extends LitroPage {
32
+ @state() declare serverData: PostData | null;
33
+
34
+ render() {
35
+ const { post } = this.serverData ?? {};
36
+ if (!post) return html`<p>Loading…</p>`;
37
+ return html`
38
+ <article>
39
+ <header>
40
+ <h1>${post.title}</h1>
41
+ <time datetime="${toDate(post.date).toISOString()}">${toDate(post.date).toLocaleDateString()}</time>
42
+ ${post.tags.length > 0 ? html`
43
+ <ul class="tags">
44
+ ${post.tags.map(tag => html`
45
+ <li><a href="/tags/${tag}">#${tag}</a></li>
46
+ `)}
47
+ </ul>
48
+ ` : ''}
49
+ </header>
50
+ <div class="post-body">
51
+ <!-- unsafeHTML renders the Markdown-generated HTML directly.
52
+ The content directory is trusted-author-only; do not place
53
+ user-submitted or untrusted content here without first
54
+ sanitizing with a library such as rehype-sanitize. -->
55
+ ${unsafeHTML(post.body)}
56
+ </div>
57
+ <footer>
58
+ <a href="/blog">← Back to Blog</a>
59
+ </footer>
60
+ </article>
61
+ `;
62
+ }
63
+ }
64
+
65
+ export default BlogPostPage;