@zvndev/darkmown 2.0.0 → 2.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 (55) hide show
  1. package/AGENTS.md +1 -1
  2. package/CHANGELOG.md +21 -0
  3. package/README.md +31 -7
  4. package/SECURITY.md +4 -4
  5. package/docs/spec-alignment.md +19 -6
  6. package/package.json +5 -2
  7. package/site/_/footer.wd +1 -1
  8. package/site/_/nav.wd +1 -0
  9. package/site/pages/app.wd +1 -1
  10. package/site/pages/blog/zero-js-by-default.md +1 -1
  11. package/site/pages/docs/index.wd +18 -2
  12. package/site/pages/index.js +19 -0
  13. package/site/pages/index.skin +46 -1
  14. package/site/pages/index.wd +7 -3
  15. package/site/pages/playground/index.js +158 -0
  16. package/site/pages/playground/index.skin +128 -0
  17. package/site/pages/playground/index.wd +51 -0
  18. package/site/pages/showcase/index.wd +1 -1
  19. package/src/builder.js +10 -8
  20. package/src/compiler/collections.js +16 -11
  21. package/src/compiler/context.js +22 -4
  22. package/src/compiler/expr-ast.js +296 -0
  23. package/src/compiler/fs-reader.js +25 -0
  24. package/src/compiler/includes.js +25 -14
  25. package/src/compiler/index.js +1 -1
  26. package/src/compiler/loops.js +44 -7
  27. package/src/compiler/page.js +97 -17
  28. package/src/compiler/predicates.js +4 -12
  29. package/src/compiler/reader.js +60 -0
  30. package/src/compiler/state.js +16 -18
  31. package/src/compiler/structure.js +40 -10
  32. package/src/compiler.js +57 -6
  33. package/src/headers.js +15 -13
  34. package/src/index.js +1 -0
  35. package/src/runtime.js +77 -45
  36. package/src/statics.js +6 -7
  37. package/src/templates/blog/site/_/nav.wd +6 -9
  38. package/src/templates/blog/site/pages/index.skin +7 -4
  39. package/src/templates/blog/site/pages/index.wd +2 -3
  40. package/src/templates/dashboard/site/_/nav.wd +6 -9
  41. package/src/templates/dashboard/site/pages/index.skin +7 -4
  42. package/src/templates/dashboard/site/pages/index.wd +2 -3
  43. package/src/templates/landing/site/_/nav.wd +6 -9
  44. package/src/templates/landing/site/pages/index.skin +13 -4
  45. package/src/templates/landing/site/pages/index.wd +22 -9
  46. package/src/templates/starter/site/_/nav.wd +7 -10
  47. package/src/templates/starter/site/pages/about.md +7 -18
  48. package/src/templates/starter/site/pages/about.skin +0 -25
  49. package/src/templates/starter/site/pages/index.skin +10 -6
  50. package/src/templates/starter/site/pages/index.wd +2 -3
  51. package/src/templates/store/site/_/nav.wd +6 -9
  52. package/src/templates/store/site/pages/index.skin +7 -4
  53. package/src/templates/store/site/pages/index.wd +2 -3
  54. package/types/compiler.d.ts +13 -0
  55. package/types/index.d.ts +1 -0
@@ -27,12 +27,12 @@ page
27
27
  line-height 1.6
28
28
  -webkit-font-smoothing antialiased
29
29
 
30
- main
30
+ .main
31
31
  max-width 900px
32
32
  margin 0 auto
33
33
  padding 1rem 1.5rem 4rem
34
34
 
35
- nav
35
+ .nav
36
36
  display flex
37
37
  align-items center
38
38
  justify-content space-between
@@ -40,10 +40,13 @@ nav
40
40
  margin 0 auto
41
41
  padding 1.25rem 1.5rem
42
42
 
43
- nav strong
43
+ .nav p
44
+ margin 0
45
+
46
+ .nav strong
44
47
  font-size 1.15rem
45
48
 
46
- nav a
49
+ .nav a
47
50
  color $accent
48
51
  text-decoration none
49
52
 
@@ -60,6 +63,9 @@ nav a
60
63
  color $muted
61
64
  margin 0 0 1.5rem
62
65
 
66
+ .lede p
67
+ margin 0
68
+
63
69
  .cta
64
70
  display inline-flex
65
71
  align-items center
@@ -186,6 +192,9 @@ input:focus-visible, textarea:focus-visible, select:focus-visible
186
192
  color $muted
187
193
  font-size .95rem
188
194
 
195
+ .quote .who p
196
+ margin 0
197
+
189
198
  .wd-carousel-prev
190
199
  position absolute
191
200
  left -.5rem
@@ -1,5 +1,4 @@
1
1
  ---
2
- html: true
3
2
  title: Acme — ship faster
4
3
  description: A marketing one-pager built with Darkmown. Zero framework JS on the static parts, with a testimonials carousel.
5
4
  transitions: true
@@ -7,12 +6,16 @@ transitions: true
7
6
 
8
7
  @include /nav.wd
9
8
 
10
- <main>
9
+ ::: main
11
10
 
12
11
  ::: hero
13
12
  # Ship faster with *Acme*
14
- <p class="lede">The all-in-one toolkit your team actually enjoys using.</p>
15
- <a class="cta" href="#start">Get started</a>
13
+
14
+ ::: lede
15
+ The all-in-one toolkit your team actually enjoys using.
16
+ :::
17
+
18
+ [Get started](#start){.cta}
16
19
  :::
17
20
 
18
21
  ::: features
@@ -35,21 +38,31 @@ One command to Vercel or Cloudflare — your API comes along for free.
35
38
  :carousel
36
39
  ::: quote
37
40
  > "Acme cut our launch time in half."
38
- <p class="who">— Riley, Head of Product</p>
41
+
42
+ ::: who
43
+ — Riley, Head of Product
44
+ :::
39
45
  :::
40
46
  ::: quote
41
47
  > "The simplest stack we've ever shipped on."
42
- <p class="who">— Sam, CTO</p>
48
+
49
+ ::: who
50
+ — Sam, CTO
51
+ :::
43
52
  :::
44
53
  ::: quote
45
54
  > "Our marketing pages load instantly now."
46
- <p class="who">— Jordan, Growth</p>
55
+
56
+ ::: who
57
+ — Jordan, Growth
58
+ :::
47
59
  :::
48
60
  :endcarousel
49
61
 
50
62
  ::: cta-band #start
51
63
  ## Ready to build?
52
- <a class="cta" href="/">Start now</a>
64
+
65
+ [Start now](/){.cta}
53
66
  :::
54
67
 
55
- </main>
68
+ :::
@@ -1,11 +1,8 @@
1
- ---
2
- html: true
3
- ---
1
+ ::: nav
2
+ **My site**
4
3
 
5
- <nav>
6
- <strong>My site</strong>
7
- <span class="links">
8
- <a href="/">Home</a>
9
- <a href="/about/">About</a>
10
- </span>
11
- </nav>
4
+ ::: links
5
+ [Home](/)
6
+ [About](/about/)
7
+ :::
8
+ :::
@@ -1,27 +1,16 @@
1
1
  ---
2
2
  title: About
3
- html: true
4
3
  ---
5
4
 
6
- <nav>
7
- <strong>My site</strong>
8
- <span class="links">
9
- <a href="/">Home</a>
10
- <a href="/about/">About</a>
11
- </span>
12
- </nav>
13
-
14
- <main>
15
-
16
5
  # About
17
6
 
18
- This page is plain Markdown (`.md`) — strict CommonMark, zero framework JavaScript.
19
- Rename it to `.wd` when you want directives like state, loops, or forms — a `.wd`
20
- page can `@include /nav.wd` instead of repeating the markup above.
7
+ This page is plain Markdown (`.md`) — strict CommonMark, zero framework
8
+ JavaScript, and no raw HTML (Darkmown escapes it by default, so untrusted
9
+ content can't inject markup). That's why there's no shared nav bar here: a
10
+ `.md` page can't `@include` or use directives.
21
11
 
22
- The colocated `about.skin` styles this page; it attaches automatically by
23
- basename, `.md` or `.wd` alike.
12
+ Rename it to `.wd` when you want that — state, loops, forms, and an
13
+ `@include /nav.wd` for the shared nav. The colocated `about.skin` styles this
14
+ page either way; it attaches automatically by basename, `.md` or `.wd` alike.
24
15
 
25
16
  [Back home](/)
26
-
27
- </main>
@@ -32,31 +32,6 @@ main
32
32
  margin 0 auto
33
33
  padding 3rem 1.5rem
34
34
 
35
- nav
36
- display flex
37
- align-items center
38
- justify-content space-between
39
- gap 1rem
40
- max-width 760px
41
- margin 0 auto
42
- padding 1.25rem 1.5rem
43
-
44
- nav strong
45
- font-size 1.1rem
46
-
47
- nav .links
48
- display flex
49
- gap 1.25rem
50
-
51
- nav a
52
- color $ink
53
- text-decoration none
54
- opacity .8
55
-
56
- nav a:hover
57
- opacity 1
58
- color $accent
59
-
60
35
  a
61
36
  color $accent
62
37
 
@@ -27,12 +27,12 @@ page
27
27
  line-height 1.6
28
28
  -webkit-font-smoothing antialiased
29
29
 
30
- main
30
+ .main
31
31
  max-width 760px
32
32
  margin 0 auto
33
33
  padding 3rem 1.5rem
34
34
 
35
- nav
35
+ .nav
36
36
  display flex
37
37
  align-items center
38
38
  justify-content space-between
@@ -41,19 +41,23 @@ nav
41
41
  margin 0 auto
42
42
  padding 1.25rem 1.5rem
43
43
 
44
- nav strong
44
+ .nav p
45
+ margin 0
46
+
47
+ .nav strong
45
48
  font-size 1.1rem
46
49
 
47
- nav .links
50
+ .nav .links p
48
51
  display flex
49
52
  gap 1.25rem
53
+ margin 0
50
54
 
51
- nav a
55
+ .nav a
52
56
  color $ink
53
57
  text-decoration none
54
58
  opacity .8
55
59
 
56
- nav a:hover
60
+ .nav a:hover
57
61
  opacity 1
58
62
  color $accent
59
63
 
@@ -1,11 +1,10 @@
1
1
  ---
2
- html: true
3
2
  title: My Darkmown site
4
3
  ---
5
4
 
6
5
  @include /nav.wd
7
6
 
8
- <main>
7
+ ::: main
9
8
 
10
9
  # My Darkmown site
11
10
 
@@ -25,4 +24,4 @@ Count: { count }
25
24
 
26
25
  :button "Add" -> todos += "Add a loop"
27
26
 
28
- </main>
27
+ :::
@@ -1,10 +1,7 @@
1
- ---
2
- html: true
3
- ---
1
+ ::: nav
2
+ **Shop**
4
3
 
5
- <nav>
6
- <strong>Shop</strong>
7
- <span class="links">
8
- <a href="/">Catalog</a>
9
- </span>
10
- </nav>
4
+ ::: links
5
+ [Catalog](/)
6
+ :::
7
+ :::
@@ -27,12 +27,12 @@ page
27
27
  line-height 1.55
28
28
  -webkit-font-smoothing antialiased
29
29
 
30
- main
30
+ .main
31
31
  max-width 860px
32
32
  margin 0 auto
33
33
  padding 2rem 1.5rem
34
34
 
35
- nav
35
+ .nav
36
36
  display flex
37
37
  align-items center
38
38
  justify-content space-between
@@ -40,10 +40,13 @@ nav
40
40
  margin 0 auto
41
41
  padding 1.25rem 1.5rem
42
42
 
43
- nav strong
43
+ .nav p
44
+ margin 0
45
+
46
+ .nav strong
44
47
  font-size 1.1rem
45
48
 
46
- nav a
49
+ .nav a
47
50
  color $accent
48
51
  text-decoration none
49
52
 
@@ -1,5 +1,4 @@
1
1
  ---
2
- html: true
3
2
  title: Shop — built with Darkmown
4
3
  description: A storefront in Markdown — live search, a shared cart, and a checkout that posts to a serverless function.
5
4
  transitions: true
@@ -7,7 +6,7 @@ transitions: true
7
6
 
8
7
  @include /nav.wd
9
8
 
10
- <main>
9
+ ::: main
11
10
 
12
11
  ::: section #shop
13
12
 
@@ -81,4 +80,4 @@ to { receipt.received.email }. Order { receipt.orderId }.
81
80
 
82
81
  :::
83
82
 
84
- </main>
83
+ :::
@@ -14,6 +14,19 @@ export function compilePage(file: string, context: Paths): CompiledPage;
14
14
  * @returns {CompiledDocument}
15
15
  */
16
16
  export function compileDocument(file: string, context: Paths, stack?: string[], vars?: Record<string, unknown>): CompiledDocument;
17
+ /**
18
+ * Compile a page from an in-memory map of project-relative path → source, with
19
+ * no filesystem access. `entryPath` is the project-relative path of the page to
20
+ * compile; includes and `@loop` data resolve against the same map.
21
+ * @param {Record<string, string> | Map<string, string>} files
22
+ * @param {string} entryPath
23
+ * @param {{ vars?: Record<string, unknown>, cwd?: string }} [options]
24
+ * @returns {CompiledPage}
25
+ */
26
+ export function compileFromMemory(files: Record<string, string> | Map<string, string>, entryPath: string, options?: {
27
+ vars?: Record<string, unknown>;
28
+ cwd?: string;
29
+ }): CompiledPage;
17
30
  /**
18
31
  * Split a raw file into its frontmatter `meta` and `body`.
19
32
  * @param {string} raw Full file contents.
package/types/index.d.ts CHANGED
@@ -8,6 +8,7 @@ export type { RouteManifestEntry, Paths, Assets } from "./builder.js";
8
8
  export {
9
9
  compilePage,
10
10
  compileDocument,
11
+ compileFromMemory,
11
12
  parseFrontmatter,
12
13
  escapeHtml,
13
14
  loopKeyOf