vowel 0.6.4 → 0.7.0-beta.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 (166) hide show
  1. package/README.md +1 -1
  2. package/bin.js +47 -27
  3. package/cli.js +15 -0
  4. package/config.js +93 -26
  5. package/extractDate.js +70 -6
  6. package/index.js +14 -5
  7. package/package.json +39 -8
  8. package/plugins/assets/index.js +65 -0
  9. package/plugins/atproto/index.js +132 -0
  10. package/plugins/atproto/password.js +71 -0
  11. package/plugins/atproto/publish.js +406 -0
  12. package/plugins/atproto/record.js +144 -0
  13. package/plugins/atproto/rkey.js +54 -0
  14. package/plugins/deploy-cloudflare/index.js +30 -16
  15. package/plugins/fonts/index.js +18 -21
  16. package/plugins/html/assets/bundle-BeK1Hptv.css +21 -0
  17. package/plugins/html/bundle/assets/index-BeK1Hptv.css +21 -0
  18. package/plugins/html/bundle/index.js +21145 -0
  19. package/plugins/html/editor/EditButton.svelte +152 -0
  20. package/plugins/html/editor/Editor.svelte +51 -0
  21. package/plugins/html/editor/Overlays.svelte +6 -0
  22. package/plugins/html/editor/SettingsPanel.svelte +397 -0
  23. package/plugins/html/editor/Toolbar.svelte +644 -0
  24. package/plugins/html/editor/create-session.js +250 -0
  25. package/plugins/html/editor/directives.js +128 -0
  26. package/plugins/html/editor/frontmatter.js +97 -0
  27. package/plugins/html/editor/ingest.js +339 -0
  28. package/plugins/html/editor/main.js +94 -0
  29. package/plugins/html/editor/nodes/Alert.svelte +21 -0
  30. package/plugins/html/editor/nodes/Blockquote.svelte +9 -0
  31. package/plugins/html/editor/nodes/CodeBlock.svelte +19 -0
  32. package/plugins/html/editor/nodes/Embed.svelte +19 -0
  33. package/plugins/html/editor/nodes/Emphasis.svelte +11 -0
  34. package/plugins/html/editor/nodes/Heading.svelte +15 -0
  35. package/plugins/html/editor/nodes/Highlight.svelte +11 -0
  36. package/plugins/html/editor/nodes/Image.svelte +18 -0
  37. package/plugins/html/editor/nodes/InlineCode.svelte +11 -0
  38. package/plugins/html/editor/nodes/Link.svelte +17 -0
  39. package/plugins/html/editor/nodes/List.svelte +15 -0
  40. package/plugins/html/editor/nodes/ListItem.svelte +9 -0
  41. package/plugins/html/editor/nodes/Page.svelte +21 -0
  42. package/plugins/html/editor/nodes/Paragraph.svelte +9 -0
  43. package/plugins/html/editor/nodes/Strikethrough.svelte +11 -0
  44. package/plugins/html/editor/nodes/Strong.svelte +11 -0
  45. package/plugins/html/editor/nodes/ThematicBreak.svelte +9 -0
  46. package/plugins/html/editor/nodes/index.js +18 -0
  47. package/plugins/html/editor/rollup.config.js +35 -0
  48. package/plugins/html/editor/serialize.js +157 -0
  49. package/plugins/html/editor/settings-file.js +83 -0
  50. package/plugins/html/editor/socket.js +202 -0
  51. package/plugins/html/editor/source.js +43 -0
  52. package/plugins/html/image.js +31 -5
  53. package/plugins/html/index.js +430 -458
  54. package/plugins/html/partials.js +299 -0
  55. package/plugins/html/socialLinks.js +67 -0
  56. package/plugins/html/writeRules.js +377 -0
  57. package/plugins/icons/index.js +2 -6
  58. package/plugins/images/index.js +78 -55
  59. package/plugins/markdown/brandColors.js +10 -0
  60. package/plugins/markdown/colorScheme.js +64 -0
  61. package/plugins/markdown/emoji.js +30 -0
  62. package/plugins/markdown/frontmatter.js +253 -0
  63. package/plugins/markdown/index.js +276 -334
  64. package/plugins/markdown/links.js +97 -0
  65. package/plugins/markdown/metadata.js +229 -68
  66. package/plugins/markdown/readRules.js +143 -0
  67. package/plugins/markdown/typography.js +109 -0
  68. package/plugins/markdown/visitor.js +143 -0
  69. package/plugins/publish/index.js +34 -0
  70. package/plugins/robots/agents.js +79 -0
  71. package/plugins/robots/index.js +30 -10
  72. package/plugins/robots/robots.js +48 -0
  73. package/plugins/styles/index.js +111 -18
  74. package/plugins/styles/theme.js +116 -0
  75. package/plugins/urls/index.js +49 -62
  76. package/plugins/urls/urlMetadata.js +246 -0
  77. package/plugins/vectors/index.js +5 -9
  78. package/plugins/xml/entryContent.js +103 -0
  79. package/plugins/xml/index.js +105 -43
  80. package/secretPaths.js +170 -0
  81. package/stylesheets/DefaultStyles.css +367 -437
  82. package/stylesheets/ResetStyles.css +2 -38
  83. package/stylesheets/SyntaxHighlightingStyles.css +36 -4
  84. package/stylesheets/TypographyStyles.css +386 -128
  85. package/systemPaths.js +48 -0
  86. package/utils.js +56 -5
  87. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -73
  88. package/.github/ISSUE_TEMPLATE/config.yml +0 -7
  89. package/docs-source/.cache.json +0 -9
  90. package/docs-source/.obsidian/app.json +0 -3
  91. package/docs-source/.obsidian/appearance.json +0 -3
  92. package/docs-source/.obsidian/core-plugins-migration.json +0 -30
  93. package/docs-source/.obsidian/core-plugins.json +0 -20
  94. package/docs-source/.obsidian/workspace.json +0 -168
  95. package/docs-source/.stackblitzrc +0 -3
  96. package/docs-source/.votive.db +0 -0
  97. package/docs-source/about.md +0 -3
  98. package/docs-source/blog/home.md +0 -5
  99. package/docs-source/blog/url-ui.md +0 -21
  100. package/docs-source/blog.md +0 -5
  101. package/docs-source/docs/.votive.db +0 -0
  102. package/docs-source/docs/deploy.md +0 -67
  103. package/docs-source/docs/file-structure.md +0 -31
  104. package/docs-source/docs/folder-settings.md +0 -23
  105. package/docs-source/docs/home.md +0 -55
  106. package/docs-source/docs/images.md +0 -10
  107. package/docs-source/docs/items.md +0 -13
  108. package/docs-source/docs/pages.md +0 -141
  109. package/docs-source/docs/settings.md +0 -4
  110. package/docs-source/docs/styling.md +0 -34
  111. package/docs-source/docs/taxonomies.md +0 -37
  112. package/docs-source/features/cards.md +0 -7
  113. package/docs-source/features/editing.md +0 -7
  114. package/docs-source/features/emoji.md +0 -7
  115. package/docs-source/features/frontmatter.md +0 -7
  116. package/docs-source/features/lists.md +0 -7
  117. package/docs-source/features/navigation.md +0 -7
  118. package/docs-source/features/rich-previews.md +0 -7
  119. package/docs-source/features/robots.md +0 -7
  120. package/docs-source/features/rss.md +0 -7
  121. package/docs-source/features/sitemap.md +0 -7
  122. package/docs-source/features/speed.md +0 -7
  123. package/docs-source/features/static.md +0 -7
  124. package/docs-source/features/taxonomies.md +0 -7
  125. package/docs-source/home.md +0 -42
  126. package/docs-source/output/about.html +0 -1
  127. package/docs-source/output/blog/url-ui.html +0 -8
  128. package/docs-source/output/blog.html +0 -1
  129. package/docs-source/output/default.css +0 -1
  130. package/docs-source/output/docs/deploy.html +0 -34
  131. package/docs-source/output/docs/file-structure.html +0 -24
  132. package/docs-source/output/docs/folder-settings.html +0 -20
  133. package/docs-source/output/docs/images.html +0 -2
  134. package/docs-source/output/docs/items.html +0 -6
  135. package/docs-source/output/docs/pages.html +0 -101
  136. package/docs-source/output/docs/styling.html +0 -18
  137. package/docs-source/output/docs/taxonomies.html +0 -20
  138. package/docs-source/output/docs.html +0 -28
  139. package/docs-source/output/features/cards.html +0 -1
  140. package/docs-source/output/features/editing.html +0 -1
  141. package/docs-source/output/features/emoji.html +0 -1
  142. package/docs-source/output/features/frontmatter.html +0 -1
  143. package/docs-source/output/features/lists.html +0 -1
  144. package/docs-source/output/features/navigation.html +0 -1
  145. package/docs-source/output/features/rich-previews.html +0 -1
  146. package/docs-source/output/features/robots.html +0 -1
  147. package/docs-source/output/features/rss.html +0 -1
  148. package/docs-source/output/features/sitemap.html +0 -1
  149. package/docs-source/output/features/speed.html +0 -1
  150. package/docs-source/output/features/static.html +0 -1
  151. package/docs-source/output/features/taxonomies.html +0 -1
  152. package/docs-source/output/features.html +0 -1
  153. package/docs-source/output/feed.xml +0 -1
  154. package/docs-source/output/index.html +0 -21
  155. package/docs-source/output/reset.css +0 -1
  156. package/docs-source/output/roadmap.html +0 -87
  157. package/docs-source/output/robots.txt +0 -14
  158. package/docs-source/output/sitemap.xml +0 -16
  159. package/docs-source/output/typography.css +0 -1
  160. package/docs-source/roadmap.md +0 -98
  161. package/docs-source/settings.md +0 -13
  162. package/getMetadata.js +0 -41
  163. package/jsconfig.json +0 -10
  164. package/plugins/markdown/robots.js +0 -18
  165. package/regex.js +0 -36
  166. package/stylesheets/brand-colors.css +0 -119
@@ -0,0 +1,253 @@
1
+ import yaml from "yaml"
2
+ import path from "node:path"
3
+ import { fromMarkdown } from "mdast-util-from-markdown"
4
+ import extractDate from "../../extractDate.js"
5
+
6
+ /**
7
+ * How vowel handles a frontmatter block. Stated once, here, per Sam
8
+ * (Sept 19); votive's side of the same policy is `votive/lib/attempt.js`.
9
+ *
10
+ * 1. **YAML that does not parse is not frontmatter.** The block goes
11
+ * back into the content as the markdown it would have been without
12
+ * the frontmatter extension - the `---` lines are thematic breaks,
13
+ * the lines between them prose - and an error names the file and the
14
+ * parser's complaint. Nothing is inferred from it. (`readFrontmatter`)
15
+ *
16
+ * 2. **A value that is not what vowel expects is logged and coerced.**
17
+ * `EXPECTED` below is the contract, one entry per key vowel reads:
18
+ * the shape it wants and how a wrong one is coerced. A coercion that
19
+ * can recover a value does (`title: [a, b]` → "a, b"; `tags: x` →
20
+ * ["x"]; `image: {src: x}` → "x"; `date: 03/04/2026` → ISO); one that
21
+ * cannot drops the key (`date: Thursday`), so downstream code never
22
+ * sees a shape it did not ask for. Either way one error line names
23
+ * the file, the key and what was found. Keys not in the table are the
24
+ * author's own and are stored as written. (`coerce`)
25
+ *
26
+ * 3. **A path is a URL path from the root.** `logo: x.svg` and
27
+ * `logo: /x.svg` both mean `/x.svg`; `./x.svg` is resolved against
28
+ * the file's own folder. Lowercased, because every url vowel routes
29
+ * is. (`resolvePath`)
30
+ *
31
+ * A filename vowel cannot route (a malformed `##` marker) is the
32
+ * router's to refuse; votive logs the refusal and ignores the file.
33
+ */
34
+
35
+ /**
36
+ * @typedef {"string" | "date" | "path" | "boolean" | "number" | "strings" | "theme" | "links" | "publication" | "object"} Shape
37
+ */
38
+
39
+ /**
40
+ * The keys vowel reads and the shape each one has. Everything else in a
41
+ * frontmatter block is the author's own data.
42
+ * @type {Record<string, Shape>}
43
+ */
44
+ const EXPECTED = {
45
+ title: "string",
46
+ breadcrumb: "string",
47
+ description: "string",
48
+ tagline: "string",
49
+ name: "string",
50
+ author: "string",
51
+ domain: "string",
52
+ date: "date",
53
+ image: "path",
54
+ logo: "path",
55
+ wordmark: "path",
56
+ icon: "path",
57
+ tags: "strings",
58
+ aliases: "strings",
59
+ published: "boolean",
60
+ html_file: "boolean",
61
+ rss_item: "boolean",
62
+ sitemap_item: "boolean",
63
+ global_menu_item: "boolean",
64
+ local_menu_item: "boolean",
65
+ feed_limit: "number",
66
+ theme: "theme",
67
+ social_links: "links",
68
+ robots: "object",
69
+ atproto_did: "string",
70
+ atproto_lexicon: "string",
71
+ atproto_publication: "publication",
72
+ cloudflare_project: "string",
73
+ atproto_pds: "string"
74
+ }
75
+
76
+ /** @param {unknown} value */
77
+ const isScalar = (value) => ["string", "number", "boolean"].includes(typeof value)
78
+
79
+ /** @param {unknown} value */
80
+ const isPlainObject = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value) && !(value instanceof Date)
81
+
82
+ /**
83
+ * A date in whatever shape it was written - a Date the parser made,
84
+ * "2026-03-04", "January 5, 1000" - as ISO, or undefined when it is not
85
+ * one. ISO sorts lexically (orderBy relies on it) and toISOString pads
86
+ * the year, so 0999 sorts before 1000.
87
+ * @param {unknown} value
88
+ */
89
+ function toISODate(value) {
90
+ const parsed = value instanceof Date ? value : isScalar(value) ? extractDate(String(value)) : null
91
+ if (!parsed || isNaN(Number(parsed))) return undefined
92
+ return parsed.toISOString()
93
+ }
94
+
95
+ /**
96
+ * A URL path from the root. `./x` is the file's own folder; anything
97
+ * else is root-relative whether or not it starts with `/`.
98
+ * @param {string} value
99
+ * @param {string} folder - the file's folder, project-relative ("" at the root)
100
+ */
101
+ function resolvePath(value, folder) {
102
+ const trimmed = value.trim()
103
+ if (/^[a-z]+:/i.test(trimmed)) return trimmed
104
+ const relative = trimmed.startsWith("./") || trimmed.startsWith("../")
105
+ const joined = relative ? path.posix.join("/", folder.split(path.sep).join("/"), trimmed) : path.posix.join("/", trimmed)
106
+ return joined.toLowerCase()
107
+ }
108
+
109
+ /**
110
+ * One value against one shape. Returns the value to store, or undefined
111
+ * to drop the key; `problem` says what was wrong when it was.
112
+ * @param {Shape} shape
113
+ * @param {unknown} value
114
+ * @param {string} folder
115
+ * @returns {{ value: unknown, problem?: string }}
116
+ */
117
+ function coerceOne(shape, value, folder) {
118
+ if (shape === "string") {
119
+ if (typeof value === "string") return { value }
120
+ if (isScalar(value) || value instanceof Date) return { value: String(value), problem: `expected text, got ${typeof value}` }
121
+ if (Array.isArray(value) && value.every(isScalar)) return { value: value.map(String).join(", "), problem: "expected text, got a list" }
122
+ return { value: undefined, problem: `expected text, got ${Array.isArray(value) ? "a list" : "an object"}` }
123
+ }
124
+ if (shape === "date") {
125
+ const iso = toISODate(value)
126
+ if (iso !== undefined) return { value: iso }
127
+ return { value: undefined, problem: `expected a date, got ${JSON.stringify(value)}` }
128
+ }
129
+ if (shape === "path") {
130
+ if (typeof value === "string" && value.trim()) return { value: resolvePath(value, folder) }
131
+ const inner = isPlainObject(value) ? [value.src, value.url, value.path].find(candidate => typeof candidate === "string") : Array.isArray(value) ? value.find(candidate => typeof candidate === "string") : undefined
132
+ if (inner) return { value: resolvePath(inner, folder), problem: `expected a path, got ${Array.isArray(value) ? "a list" : "an object"}; using "${inner}"` }
133
+ return { value: undefined, problem: `expected a path, got ${JSON.stringify(value)}` }
134
+ }
135
+ if (shape === "boolean") {
136
+ if (typeof value === "boolean") return { value }
137
+ const word = String(value).trim().toLowerCase()
138
+ if (["true", "yes", "1", "on"].includes(word)) return { value: true, problem: `expected true or false, got ${JSON.stringify(value)}` }
139
+ if (["false", "no", "0", "off"].includes(word)) return { value: false, problem: `expected true or false, got ${JSON.stringify(value)}` }
140
+ return { value: undefined, problem: `expected true or false, got ${JSON.stringify(value)}` }
141
+ }
142
+ if (shape === "number") {
143
+ if (typeof value === "number" && Number.isFinite(value)) return { value }
144
+ const parsed = Number(value)
145
+ if (typeof value === "string" && value.trim() && Number.isFinite(parsed)) return { value: parsed, problem: `expected a number, got text` }
146
+ return { value: undefined, problem: `expected a number, got ${JSON.stringify(value)}` }
147
+ }
148
+ if (shape === "strings") {
149
+ if (Array.isArray(value)) {
150
+ const kept = value.filter(isScalar).map(String)
151
+ return kept.length === value.length ? { value: kept } : { value: kept, problem: "expected a list of text; dropped what was not" }
152
+ }
153
+ if (isScalar(value)) return { value: [String(value)], problem: "expected a list, got one value" }
154
+ return { value: undefined, problem: `expected a list, got ${JSON.stringify(value)}` }
155
+ }
156
+ if (shape === "theme") {
157
+ if (typeof value === "string") return { value }
158
+ if (isPlainObject(value)) return { value }
159
+ return { value: undefined, problem: `expected a theme name or an object, got ${JSON.stringify(value)}` }
160
+ }
161
+ if (shape === "links") {
162
+ if (!Array.isArray(value)) return { value: undefined, problem: "expected a list of links" }
163
+ const kept = value
164
+ .filter(link => isPlainObject(link) && typeof link.url === "string")
165
+ .map(link => typeof link.icon === "string" ? { ...link, icon: resolvePath(link.icon, folder) } : link)
166
+ return kept.length === value.length ? { value: kept } : { value: kept, problem: "expected every link to have a url; dropped those without" }
167
+ }
168
+ if (shape === "publication") {
169
+ if (!isPlainObject(value)) return { value: undefined, problem: `expected an object with description and icon, got ${JSON.stringify(value)}` }
170
+ const { description, icon, ...rest } = value
171
+ const kept = {
172
+ ...rest,
173
+ ...(typeof description === "string" ? { description } : {}),
174
+ ...(typeof icon === "string" && icon.trim() ? { icon: resolvePath(icon, folder) } : {})
175
+ }
176
+ const wrong = [
177
+ ...(description === undefined || typeof description === "string" ? [] : ["description is not text"]),
178
+ ...(icon === undefined || (typeof icon === "string" && icon.trim()) ? [] : ["icon is not a path"])
179
+ ]
180
+ return wrong.length ? { value: kept, problem: `${wrong.join(", ")}; dropped` } : { value: kept }
181
+ }
182
+ if (shape === "object") {
183
+ if (isPlainObject(value)) return { value }
184
+ return { value: undefined, problem: `expected an object, got ${JSON.stringify(value)}` }
185
+ }
186
+ return { value }
187
+ }
188
+
189
+ /**
190
+ * The block's values, each known key checked against EXPECTED. Returns
191
+ * a new object; keys coerced away are absent from it.
192
+ * @param {Record<string, unknown>} frontmatter
193
+ * @param {string} filePath - project-relative, for the error line
194
+ * @param {string} folder - the folder paths resolve against
195
+ * @param {(message: string) => void} report
196
+ */
197
+ function coerce(frontmatter, filePath, folder, report) {
198
+ const result = {}
199
+ for (const key in frontmatter) {
200
+ const shape = EXPECTED[key]
201
+ if (!shape) {
202
+ result[key] = frontmatter[key]
203
+ continue
204
+ }
205
+ const { value, problem } = coerceOne(shape, frontmatter[key], folder)
206
+ if (problem) report(`${filePath}: \`${key}:\` ${problem}${value === undefined ? "; ignoring it" : ""}`)
207
+ if (value !== undefined) result[key] = value
208
+ }
209
+ return result
210
+ }
211
+
212
+ /**
213
+ * Parses a frontmatter node. On a parse error the node is replaced in
214
+ * the tree by the markdown it would have been - rule 1 above - and
215
+ * nothing is returned.
216
+ * @param {object} tree - the mdast root
217
+ * @param {object} node - its `yaml` child
218
+ * @param {string} filePath
219
+ * @param {(message: string) => void} report
220
+ * @returns {Record<string, unknown> | undefined}
221
+ */
222
+ function parseFrontmatter(tree, node, filePath, report) {
223
+ try {
224
+ // logLevel "error": yaml otherwise prints its own warnings through
225
+ // process.emitWarning, naming no file - `date: {{ date }}` printed
226
+ // "Keys with collection values will be stringified". A value vowel
227
+ // reads is checked by coerce(), which reports it with the path.
228
+ const parsed = yaml.parse(node.value, { logLevel: "error" })
229
+ if (parsed === null || parsed === undefined) return {}
230
+ if (!isPlainObject(parsed)) {
231
+ report(`${filePath}: frontmatter is ${Array.isArray(parsed) ? "a list" : "a single value"}, not a mapping; rendering it as content`)
232
+ return asContent(tree, node)
233
+ }
234
+ return parsed
235
+ } catch (error) {
236
+ report(`${filePath}: frontmatter could not be parsed (${String(error.message).split("\n")[0]}); rendering it as content`)
237
+ return asContent(tree, node)
238
+ }
239
+ }
240
+
241
+ /**
242
+ * Puts a block back as content: `---`, its lines, `---`, parsed as
243
+ * ordinary markdown, in the node's place.
244
+ * @param {object} tree
245
+ * @param {object} node
246
+ */
247
+ function asContent(tree, node) {
248
+ const replacement = fromMarkdown(`---\n${node.value}\n---\n`).children
249
+ tree.children.splice(tree.children.indexOf(node), 1, ...replacement)
250
+ return undefined
251
+ }
252
+
253
+ export { EXPECTED, coerce, parseFrontmatter, resolvePath, toISODate }