@zvndev/darkmown 0.19.0 → 0.20.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/src/dev.js CHANGED
@@ -8,7 +8,9 @@ export const devEventsPath = "/__wd/dev-events";
8
8
  */
9
9
  export function injectDevClient(html) {
10
10
  const script = `<script type="module" src="${devClientPath}"></script>`;
11
- return html.includes("</body>") ? html.replace("</body>", `${script}\n</body>`) : `${html}\n${script}`;
11
+ return html.includes("</body>")
12
+ ? html.replace("</body>", `${script}\n</body>`)
13
+ : `${html}\n${script}`;
12
14
  }
13
15
 
14
16
  /**
package/src/headers.js CHANGED
@@ -65,10 +65,9 @@ export const REACTIVE_CSP = [
65
65
  * keep `'unsafe-inline'` on script/style.
66
66
  * @type {string}
67
67
  */
68
- export const STATIC_CSP = [
69
- "script-src 'self' 'unsafe-inline'",
70
- ...COMMON_CSP_DIRECTIVES
71
- ].join("; ");
68
+ export const STATIC_CSP = ["script-src 'self' 'unsafe-inline'", ...COMMON_CSP_DIRECTIVES].join(
69
+ "; "
70
+ );
72
71
 
73
72
  /**
74
73
  * Baseline security headers applied to every HTML response, independent of the
package/src/index.js ADDED
@@ -0,0 +1,22 @@
1
+ // Public API barrel for @zvndev/darkmown.
2
+ // Mirrors the type surface declared in `types/index.d.ts`. Importing the
3
+ // package (`import { buildSite } from "@zvndev/darkmown"`) resolves here via the
4
+ // `exports` map; individual modules stay importable by their own path too.
5
+
6
+ export { buildSite } from "./builder.js";
7
+
8
+ export {
9
+ compileDocument,
10
+ compilePage,
11
+ escapeHtml,
12
+ loopKeyOf,
13
+ parseFrontmatter
14
+ } from "./compiler.js";
15
+
16
+ export { createPaths, isHiddenName, pageExtensions } from "./config.js";
17
+ export { devClientScript, injectDevClient } from "./dev.js";
18
+ export { discoverRoutes, outputPathForRoute, routeFromFile } from "./router.js";
19
+
20
+ export { initProject } from "./scaffold.js";
21
+ export { compileSkin } from "./skin.js";
22
+ export { contentType, resolvePublicFile, serve } from "./statics.js";
package/src/router.js CHANGED
@@ -43,7 +43,9 @@ export function discoverRoutes(routesRoot) {
43
43
  const seen = new Map();
44
44
  for (const route of routes) {
45
45
  if (seen.has(route.route)) {
46
- throw new Error(`Duplicate route "${route.route}" from ${seen.get(route.route)} and ${route.file}`);
46
+ throw new Error(
47
+ `Duplicate route "${route.route}" from ${seen.get(route.route)} and ${route.file}`
48
+ );
47
49
  }
48
50
  seen.set(route.route, route.file);
49
51
  }
package/src/scaffold.js CHANGED
@@ -12,136 +12,164 @@ const darkmownVersion = JSON.parse(
12
12
  */
13
13
  export function initProject(root) {
14
14
  fs.mkdirSync(root, { recursive: true });
15
- writeNew(root, "package.json", JSON.stringify({
16
- name: packageNameFromRoot(root),
17
- private: true,
18
- scripts: {
19
- dev: "darkmown dev",
20
- build: "darkmown build",
21
- preview: "darkmown serve"
22
- },
23
- devDependencies: {
24
- "@zvndev/darkmown": `^${darkmownVersion}`
25
- }
26
- }, null, 2));
27
- writeNew(root, "site/pages/index.wd", [
28
- "---",
29
- "title: My Darkmown site",
30
- "---",
31
- "",
32
- "@include /nav.wd",
33
- "",
34
- "<main>",
35
- "",
36
- "# My Darkmown site",
37
- "",
38
- "Plain Markdown works. Rename to `.wd` when you want directives.",
39
- "",
40
- ":state count = 0",
41
- "",
42
- "Count: { count }",
43
- "",
44
- ":button \"Increment\" -> count++",
45
- "",
46
- ":state todos = [\"Write a page\"]",
47
- "",
48
- "@loop todos into todo",
49
- "- { todo }",
50
- "@endloop",
51
- "",
52
- ":button \"Add\" -> todos += \"Add a loop\"",
53
- "",
54
- "</main>"
55
- ].join("\n"));
56
- writeNew(root, "site/pages/index.skin", [
57
- "tokens",
58
- " ink #172026",
59
- " paper #f7f2e8",
60
- " accent #0f8b8d",
61
- "",
62
- "page",
63
- " margin 0",
64
- " font ui-sans-serif, system-ui, sans-serif",
65
- " color $ink",
66
- " bg $paper",
67
- "",
68
- "main",
69
- " max-width 760px",
70
- " margin 0 auto",
71
- " padding 3rem 1.5rem",
72
- "",
73
- "nav",
74
- " display flex",
75
- " align-items center",
76
- " justify-content space-between",
77
- " gap 1rem",
78
- " max-width 760px",
79
- " margin 0 auto",
80
- " padding 1.25rem 1.5rem",
81
- "",
82
- "nav strong",
83
- " font-size 1.1rem",
84
- "",
85
- "nav .links",
86
- " display flex",
87
- " gap 1.25rem",
88
- "",
89
- "nav a",
90
- " color $ink",
91
- " text-decoration none",
92
- " opacity .8",
93
- "",
94
- "nav a:hover",
95
- " opacity 1",
96
- " color $accent",
97
- "",
98
- "button",
99
- " bg $accent",
100
- " color white",
101
- " border 0",
102
- " padding .75rem 1rem",
103
- " radius 8px"
104
- ].join("\n"));
105
- writeNew(root, "site/_/nav.wd", [
106
- "<nav>",
107
- " <strong>My site</strong>",
108
- " <span class=\"links\">",
109
- " <a href=\"/\">Home</a>",
110
- " <a href=\"/about/\">About</a>",
111
- " </span>",
112
- "</nav>"
113
- ].join("\n"));
114
- writeNew(root, "site/pages/about.md", [
115
- "---",
116
- "title: About",
117
- "---",
118
- "",
119
- "# About",
120
- "",
121
- "This page is plain Markdown (`.md`) — strict CommonMark, zero framework JavaScript.",
122
- "Rename it to `.wd` when you want directives like state, loops, or forms.",
123
- "",
124
- "[Back home](/)"
125
- ].join("\n"));
126
- writeNew(root, "README.md", [
127
- "# My Darkmown site",
128
- "",
129
- "Run `npm install` and `npm run dev` to start the live compiler.",
130
- "",
131
- "## Commands",
132
- "",
133
- "- `npm run dev` — live compiler on http://localhost:5173 with hot reload.",
134
- "- `npm run build` — compile the site to `dist/`.",
135
- "- `npm run preview` — serve the built `dist/` locally.",
136
- "",
137
- "## Layout",
138
- "",
139
- "- Pages live in `site/pages`.",
140
- "- Shared includes live in `site/_`.",
141
- "- Hidden route files start with `.` or `-`.",
142
- "- Colocated `index.skin` and `index.js` attach automatically.",
143
- "- Any other file under `site/pages` (images, fonts, …) copies to `dist/` at its own path."
144
- ].join("\n"));
15
+ writeNew(
16
+ root,
17
+ "package.json",
18
+ JSON.stringify(
19
+ {
20
+ name: packageNameFromRoot(root),
21
+ private: true,
22
+ scripts: {
23
+ dev: "darkmown dev",
24
+ build: "darkmown build",
25
+ preview: "darkmown serve"
26
+ },
27
+ devDependencies: {
28
+ "@zvndev/darkmown": `^${darkmownVersion}`
29
+ }
30
+ },
31
+ null,
32
+ 2
33
+ )
34
+ );
35
+ writeNew(
36
+ root,
37
+ "site/pages/index.wd",
38
+ [
39
+ "---",
40
+ "title: My Darkmown site",
41
+ "---",
42
+ "",
43
+ "@include /nav.wd",
44
+ "",
45
+ "<main>",
46
+ "",
47
+ "# My Darkmown site",
48
+ "",
49
+ "Plain Markdown works. Rename to `.wd` when you want directives.",
50
+ "",
51
+ ":state count = 0",
52
+ "",
53
+ "Count: { count }",
54
+ "",
55
+ ':button "Increment" -> count++',
56
+ "",
57
+ ':state todos = ["Write a page"]',
58
+ "",
59
+ "@loop todos into todo",
60
+ "- { todo }",
61
+ "@endloop",
62
+ "",
63
+ ':button "Add" -> todos += "Add a loop"',
64
+ "",
65
+ "</main>"
66
+ ].join("\n")
67
+ );
68
+ writeNew(
69
+ root,
70
+ "site/pages/index.skin",
71
+ [
72
+ "tokens",
73
+ " ink #172026",
74
+ " paper #f7f2e8",
75
+ " accent #0f8b8d",
76
+ "",
77
+ "page",
78
+ " margin 0",
79
+ " font ui-sans-serif, system-ui, sans-serif",
80
+ " color $ink",
81
+ " bg $paper",
82
+ "",
83
+ "main",
84
+ " max-width 760px",
85
+ " margin 0 auto",
86
+ " padding 3rem 1.5rem",
87
+ "",
88
+ "nav",
89
+ " display flex",
90
+ " align-items center",
91
+ " justify-content space-between",
92
+ " gap 1rem",
93
+ " max-width 760px",
94
+ " margin 0 auto",
95
+ " padding 1.25rem 1.5rem",
96
+ "",
97
+ "nav strong",
98
+ " font-size 1.1rem",
99
+ "",
100
+ "nav .links",
101
+ " display flex",
102
+ " gap 1.25rem",
103
+ "",
104
+ "nav a",
105
+ " color $ink",
106
+ " text-decoration none",
107
+ " opacity .8",
108
+ "",
109
+ "nav a:hover",
110
+ " opacity 1",
111
+ " color $accent",
112
+ "",
113
+ "button",
114
+ " bg $accent",
115
+ " color white",
116
+ " border 0",
117
+ " padding .75rem 1rem",
118
+ " radius 8px"
119
+ ].join("\n")
120
+ );
121
+ writeNew(
122
+ root,
123
+ "site/_/nav.wd",
124
+ [
125
+ "<nav>",
126
+ " <strong>My site</strong>",
127
+ ' <span class="links">',
128
+ ' <a href="/">Home</a>',
129
+ ' <a href="/about/">About</a>',
130
+ " </span>",
131
+ "</nav>"
132
+ ].join("\n")
133
+ );
134
+ writeNew(
135
+ root,
136
+ "site/pages/about.md",
137
+ [
138
+ "---",
139
+ "title: About",
140
+ "---",
141
+ "",
142
+ "# About",
143
+ "",
144
+ "This page is plain Markdown (`.md`) — strict CommonMark, zero framework JavaScript.",
145
+ "Rename it to `.wd` when you want directives like state, loops, or forms.",
146
+ "",
147
+ "[Back home](/)"
148
+ ].join("\n")
149
+ );
150
+ writeNew(
151
+ root,
152
+ "README.md",
153
+ [
154
+ "# My Darkmown site",
155
+ "",
156
+ "Run `npm install` and `npm run dev` to start the live compiler.",
157
+ "",
158
+ "## Commands",
159
+ "",
160
+ "- `npm run dev` — live compiler on http://localhost:5173 with hot reload.",
161
+ "- `npm run build` — compile the site to `dist/`.",
162
+ "- `npm run preview` — serve the built `dist/` locally.",
163
+ "",
164
+ "## Layout",
165
+ "",
166
+ "- Pages live in `site/pages`.",
167
+ "- Shared includes live in `site/_`.",
168
+ "- Hidden route files start with `.` or `-`.",
169
+ "- Colocated `index.skin` and `index.js` attach automatically.",
170
+ "- Any other file under `site/pages` (images, fonts, …) copies to `dist/` at its own path."
171
+ ].join("\n")
172
+ );
145
173
  return { root };
146
174
  }
147
175
 
@@ -159,7 +187,6 @@ function writeNew(root, file, content) {
159
187
  fs.writeFileSync(target, `${content}\n`);
160
188
  }
161
189
 
162
-
163
190
  /**
164
191
  * Derive a safe default npm package name from the scaffold target directory.
165
192
  * @param {string} root Absolute target directory.
package/src/skin.js CHANGED
@@ -14,7 +14,8 @@ const aliases = new Map([
14
14
  * @returns {string}
15
15
  */
16
16
  function resolveProp(prop, rest) {
17
- if (prop === "font" && (/^[\d.]/.test(rest[0] || "") || rest.join(" ").includes("/"))) return "font";
17
+ if (prop === "font" && (/^[\d.]/.test(rest[0] || "") || rest.join(" ").includes("/")))
18
+ return "font";
18
19
  return aliases.get(prop) || prop;
19
20
  }
20
21
 
package/site/_/og.png DELETED
Binary file