vowel 0.7.1-beta.0 → 0.7.1

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 (38) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +41 -239
  3. package/bin.js +73 -31
  4. package/cli.js +32 -0
  5. package/config.js +12 -0
  6. package/extractDate.js +1 -1
  7. package/package.json +8 -33
  8. package/pathDate.js +69 -0
  9. package/plugins/assets/index.js +1 -1
  10. package/plugins/atproto/index.js +5 -45
  11. package/plugins/atproto/publish.js +34 -9
  12. package/plugins/atproto/record.js +47 -4
  13. package/plugins/deploy-cloudflare/index.js +4 -1
  14. package/plugins/export/index.js +131 -0
  15. package/plugins/html/bundle/index.js +57 -23
  16. package/plugins/html/editor/Editor.svelte +9 -5
  17. package/plugins/html/editor/create-session.js +3 -1
  18. package/plugins/html/editor/directives.js +12 -0
  19. package/plugins/html/editor/frontmatter.js +42 -11
  20. package/plugins/html/editor/ingest.js +19 -8
  21. package/plugins/html/editor/serialize.js +8 -4
  22. package/plugins/html/image.js +11 -5
  23. package/plugins/html/index.js +211 -100
  24. package/plugins/html/partials.js +14 -8
  25. package/plugins/html/socialLinks.js +5 -8
  26. package/plugins/html/writeRules.js +193 -35
  27. package/plugins/images/favicon.png +0 -0
  28. package/plugins/images/index.js +41 -3
  29. package/plugins/markdown/colorScheme.js +70 -14
  30. package/plugins/markdown/frontmatter.js +18 -8
  31. package/plugins/markdown/index.js +90 -23
  32. package/plugins/markdown/metadata.js +74 -22
  33. package/plugins/markdown/typography.js +11 -11
  34. package/plugins/styles/index.js +4 -4
  35. package/plugins/xml/index.js +17 -10
  36. package/stylesheets/DefaultStyles.css +158 -105
  37. package/stylesheets/TypographyStyles.css +143 -76
  38. package/utils.js +74 -1
@@ -9,17 +9,17 @@
9
9
  :root {
10
10
  /*
11
11
  these variables declare a stack with system fallbacks
12
- declare brand fonts with `--font-x-brand` to keep stack intact
12
+ declare brand fonts with `--fontfamily-x-brand` to keep stack intact
13
13
  */
14
- --font-stack-serif: var(--font-serif-brand), var(--font-serif-system);
15
- --font-stack-sans: var(--font-sans-brand), var(--font-sans-system);
16
- --font-stack-monospace: var(--font-monospace-brand), var(--font-monospace-system);
14
+ --fontfamily-serif: var(--fontfamily-serif-brand), var(--fontfamily-serif-system);
15
+ --fontfamily-sans: var(--fontfamily-sans-brand), var(--fontfamily-sans-system);
16
+ --fontfamily-monospace: var(--fontfamily-monospace-brand), var(--fontfamily-monospace-system);
17
17
 
18
- --font-serif-brand: "Declare a brand serif font with this variable";
19
- --font-sans-brand: "Declare a brand sans-serif font with this variable";
20
- --font-monospace-brand: "Declare a brand monospace font with this variable";
18
+ --fontfamily-serif-brand: "Declare a brand serif font with this variable";
19
+ --fontfamily-sans-brand: "Declare a brand sans-serif font with this variable";
20
+ --fontfamily-monospace-brand: "Declare a brand monospace font with this variable";
21
21
 
22
- --font-sans-system:
22
+ --fontfamily-sans-system:
23
23
  -apple-system,
24
24
  BlinkMacSystemFont,
25
25
  avenir next,
@@ -34,7 +34,7 @@
34
34
  arial,
35
35
  sans-serif;
36
36
 
37
- --font-monospace-system:
37
+ --fontfamily-monospace-system:
38
38
  Menlo,
39
39
  Consolas,
40
40
  Monaco,
@@ -42,7 +42,7 @@
42
42
  Lucida Console,
43
43
  monospace;
44
44
 
45
- --font-serif-system:
45
+ --fontfamily-serif-system:
46
46
  Iowan Old Style,
47
47
  Apple Garamond,
48
48
  Baskerville,
@@ -60,68 +60,96 @@
60
60
  the recommended root font size on small screens (16px) and
61
61
  large screens (18px)
62
62
  */
63
- --font-size-root: clamp(1rem, 0.875rem + 0.333vw, 1.125rem);
63
+ --fontsize-root: clamp(1rem, 0.875rem + 0.333vw, 1.125rem);
64
64
 
65
65
  /*
66
66
  the difference in size of h1 relative to the root
67
67
  font size; increase or decrease this number for larger or
68
68
  smaller headings
69
69
  */
70
- --font-size-delta: calc(1.5 * var(--font-size-root));
70
+ --fontsize-delta: calc(1.5 * var(--fontsize-root));
71
71
 
72
72
  /*
73
73
  the rate of decay from h1 to h6 font size, where h6 is
74
74
  almost as small as the root font size; a higher number
75
75
  makes subheadings smaller
76
76
  */
77
- --font-size-decay: 3;
77
+ --fontsize-decay: 3;
78
78
 
79
79
  /*
80
80
  letter spacing of h1 and h6, with h2-h6 imputed
81
81
  according to the decay variable
82
82
  */
83
- --letter-spacing-h1: -0.01ch;
84
- --letter-spacing-h6: 0ch;
85
- --letter-spacing-decay: 2;
83
+ --letterspacing-h1: -0.01ch;
84
+ --letterspacing-h6: 0ch;
85
+ --letterspacing-decay: 2;
86
86
 
87
87
  /*
88
88
  weight of h1 and h6, with h2-h6 imputed according
89
89
  to the decay variable
90
90
  */
91
- --font-weight-h1: 800;
92
- --font-weight-h6: 600;
93
- --font-weight-decay: 2;
91
+ --fontweight-h1: 800;
92
+ --fontweight-h6: 600;
93
+ --fontweight-decay: 2;
94
94
 
95
95
  /*
96
96
  *do not edit or overwrite*: calculations to impute
97
97
  font sizes, weights, and spacing between h1 and h6
98
98
  */
99
- --font-size-h1: calc(var(--font-size-root) + var(--font-size-delta));
100
- --font-size-h2: calc(var(--font-size-root) + calc(var(--font-size-delta) * pow(5 / 6, var(--font-size-decay))));
101
- --font-size-h3: calc(var(--font-size-root) + calc(var(--font-size-delta) * pow(4 / 6, var(--font-size-decay))));
102
- --font-size-h4: calc(var(--font-size-root) + calc(var(--font-size-delta) * pow(3 / 6, var(--font-size-decay))));
103
- --font-size-h5: calc(var(--font-size-root) + calc(var(--font-size-delta) * pow(2 / 6, var(--font-size-decay))));
104
- --font-size-h6: calc(var(--font-size-root) + calc(var(--font-size-delta) * pow(1 / 6, var(--font-size-decay))));
105
- --letter-spacing-delta: calc(var(--letter-spacing-h1) - var(--letter-spacing-h6));
106
- --letter-spacing-h2: calc(var(--letter-spacing-h6) + calc(var(--letter-spacing-delta) * pow(5 / 6, var(--letter-spacing-decay))));
107
- --letter-spacing-h3: calc(var(--letter-spacing-h6) + calc(var(--letter-spacing-delta) * pow(4 / 6, var(--letter-spacing-decay))));
108
- --letter-spacing-h4: calc(var(--letter-spacing-h6) + calc(var(--letter-spacing-delta) * pow(3 / 6, var(--letter-spacing-decay))));
109
- --letter-spacing-h5: calc(var(--letter-spacing-h6) + calc(var(--letter-spacing-delta) * pow(2 / 6, var(--letter-spacing-decay))));
110
- --font-weight-delta: calc(var(--font-weight-h1) - var(--font-weight-h6));
111
- --font-weight-h2: calc(var(--font-weight-h6) + calc(var(--font-weight-delta) * pow(5 / 6, var(--font-weight-decay))));
112
- --font-weight-h3: calc(var(--font-weight-h6) + calc(var(--font-weight-delta) * pow(4 / 6, var(--font-weight-decay))));
113
- --font-weight-h4: calc(var(--font-weight-h6) + calc(var(--font-weight-delta) * pow(3 / 6, var(--font-weight-decay))));
114
- --font-weight-h5: calc(var(--font-weight-h6) + calc(var(--font-weight-delta) * pow(2 / 6, var(--font-weight-decay))));
99
+ --fontsize-h1: calc(var(--fontsize-root) + var(--fontsize-delta));
100
+ --fontsize-h2: calc(var(--fontsize-root) + calc(var(--fontsize-delta) * pow(5 / 6, var(--fontsize-decay))));
101
+ --fontsize-h3: calc(var(--fontsize-root) + calc(var(--fontsize-delta) * pow(4 / 6, var(--fontsize-decay))));
102
+ --fontsize-h4: calc(var(--fontsize-root) + calc(var(--fontsize-delta) * pow(3 / 6, var(--fontsize-decay))));
103
+ --fontsize-h5: calc(var(--fontsize-root) + calc(var(--fontsize-delta) * pow(2 / 6, var(--fontsize-decay))));
104
+ --fontsize-h6: calc(var(--fontsize-root) + calc(var(--fontsize-delta) * pow(1 / 6, var(--fontsize-decay))));
105
+ --_letterspacing-delta: calc(var(--letterspacing-h1) - var(--letterspacing-h6));
106
+ --letterspacing-h2: calc(var(--letterspacing-h6) + calc(var(--_letterspacing-delta) * pow(5 / 6, var(--letterspacing-decay))));
107
+ --letterspacing-h3: calc(var(--letterspacing-h6) + calc(var(--_letterspacing-delta) * pow(4 / 6, var(--letterspacing-decay))));
108
+ --letterspacing-h4: calc(var(--letterspacing-h6) + calc(var(--_letterspacing-delta) * pow(3 / 6, var(--letterspacing-decay))));
109
+ --letterspacing-h5: calc(var(--letterspacing-h6) + calc(var(--_letterspacing-delta) * pow(2 / 6, var(--letterspacing-decay))));
110
+ --_fontweight-delta: calc(var(--fontweight-h1) - var(--fontweight-h6));
111
+ --fontweight-h2: calc(var(--fontweight-h6) + calc(var(--_fontweight-delta) * pow(5 / 6, var(--fontweight-decay))));
112
+ --fontweight-h3: calc(var(--fontweight-h6) + calc(var(--_fontweight-delta) * pow(4 / 6, var(--fontweight-decay))));
113
+ --fontweight-h4: calc(var(--fontweight-h6) + calc(var(--_fontweight-delta) * pow(3 / 6, var(--fontweight-decay))));
114
+ --fontweight-h5: calc(var(--fontweight-h6) + calc(var(--_fontweight-delta) * pow(2 / 6, var(--fontweight-decay))));
115
+
116
+ /*
117
+ heading sizes by context, for the contexts that differ: in
118
+ main, a heading inside a listing card (article), an aside or a
119
+ blockquote is set a step or two down the ramp. Set one of
120
+ these to change that context alone. No context is the
121
+ default, everywhere else.
122
+ */
123
+ --fontsize-h1-article: var(--fontsize-h3);
124
+ --fontsize-h2-article: var(--fontsize-h3);
125
+ --fontsize-h3-article: var(--fontsize-h4);
126
+ --fontsize-h4-article: var(--fontsize-h5);
127
+ --fontsize-h5-article: var(--fontsize-h6);
128
+ --fontsize-h1-aside: var(--fontsize-h3);
129
+ --fontsize-h2-aside: var(--fontsize-h3);
130
+ --fontsize-h3-aside: var(--fontsize-h4);
131
+ --fontsize-h4-aside: var(--fontsize-h5);
132
+ --fontsize-h5-aside: var(--fontsize-h6);
133
+ --fontsize-h1-blockquote: var(--fontsize-h3);
134
+ --fontsize-h2-blockquote: var(--fontsize-h3);
135
+ --fontsize-h3-blockquote: var(--fontsize-h4);
136
+ --fontsize-h4-blockquote: var(--fontsize-h5);
137
+ --fontsize-h5-blockquote: var(--fontsize-h6);
138
+
139
+ /* the site's name, in the header */
140
+ --fontsize-name-header: var(--fontsize-h3);
141
+ --fontweight-name-header: var(--fontweight-h1);
142
+ --letterspacing-name-header: var(--letterspacing-h1);
115
143
  }
116
144
 
117
145
  html {
118
- font-family: var(--font-stack-sans);
146
+ font-family: var(--fontfamily-sans);
119
147
  }
120
148
 
121
149
  pre,
122
150
  code,
123
151
  kbd {
124
- font-family: var(--font-stack-monospace);
152
+ font-family: var(--fontfamily-monospace);
125
153
  }
126
154
 
127
155
  /*
@@ -189,8 +217,11 @@
189
217
 
190
218
  table {
191
219
  border-collapse: collapse;
192
- display: block;
193
- overflow: auto;
220
+ }
221
+
222
+ /* a table too wide for the page scrolls sideways inside its figure */
223
+ figure:has(>table) {
224
+ overflow-x: auto;
194
225
  }
195
226
 
196
227
  time {
@@ -339,6 +370,12 @@
339
370
  overflow-x: auto;
340
371
  }
341
372
 
373
+ /* markdown is prose: its long lines wrap rather than scroll */
374
+ pre:has(>code:is(.language-markdown, .language-md)) {
375
+ white-space: pre-wrap;
376
+ overflow-wrap: anywhere;
377
+ }
378
+
342
379
  /* table spacing */
343
380
  td,
344
381
  th {
@@ -379,79 +416,109 @@
379
416
  */
380
417
 
381
418
  body {
382
- font-size: var(--font-size-root);
419
+ font-size: var(--fontsize-root);
383
420
  }
384
421
 
385
422
  h1 {
386
- font-size: var(--font-size-h1);
387
- letter-spacing: var(--letter-spacing-h1);
388
- font-weight: var(--font-weight-h1);
423
+ font-size: var(--fontsize-h1);
424
+ letter-spacing: var(--letterspacing-h1);
425
+ font-weight: var(--fontweight-h1);
426
+
427
+ main article & {
428
+ font-size: var(--fontsize-h1-article);
429
+ }
430
+
431
+ main aside & {
432
+ font-size: var(--fontsize-h1-aside);
433
+ }
389
434
 
390
- main article &,
391
- main aside &,
392
435
  main blockquote & {
393
- font-size: var(--font-size-h3);
436
+ font-size: var(--fontsize-h1-blockquote);
394
437
  }
395
438
  }
396
439
 
397
440
  h2 {
398
- font-size: var(--font-size-h2);
399
- letter-spacing: var(--letter-spacing-h2);
400
- font-weight: var(--font-weight-h2);
441
+ font-size: var(--fontsize-h2);
442
+ letter-spacing: var(--letterspacing-h2);
443
+ font-weight: var(--fontweight-h2);
444
+
445
+ main article & {
446
+ font-size: var(--fontsize-h2-article);
447
+ }
448
+
449
+ main aside & {
450
+ font-size: var(--fontsize-h2-aside);
451
+ }
401
452
 
402
- main article &,
403
- main aside &,
404
453
  main blockquote & {
405
- font-size: var(--font-size-h3);
454
+ font-size: var(--fontsize-h2-blockquote);
406
455
  }
407
456
  }
408
457
 
409
458
  h3 {
410
- font-size: var(--font-size-h3);
411
- letter-spacing: var(--letter-spacing-h3);
412
- font-weight: var(--font-weight-h3);
459
+ font-size: var(--fontsize-h3);
460
+ letter-spacing: var(--letterspacing-h3);
461
+ font-weight: var(--fontweight-h3);
462
+
463
+ main article & {
464
+ font-size: var(--fontsize-h3-article);
465
+ }
466
+
467
+ main aside & {
468
+ font-size: var(--fontsize-h3-aside);
469
+ }
413
470
 
414
- main article &,
415
- main aside &,
416
471
  main blockquote & {
417
- font-size: var(--font-size-h4);
472
+ font-size: var(--fontsize-h3-blockquote);
418
473
  }
419
474
  }
420
475
 
421
476
  h4 {
422
- font-size: var(--font-size-h4);
423
- letter-spacing: var(--letter-spacing-h4);
424
- font-weight: var(--font-weight-h4);
477
+ font-size: var(--fontsize-h4);
478
+ letter-spacing: var(--letterspacing-h4);
479
+ font-weight: var(--fontweight-h4);
480
+
481
+ main article & {
482
+ font-size: var(--fontsize-h4-article);
483
+ }
484
+
485
+ main aside & {
486
+ font-size: var(--fontsize-h4-aside);
487
+ }
425
488
 
426
- main article &,
427
- main aside &,
428
489
  main blockquote & {
429
- font-size: var(--font-size-h5);
490
+ font-size: var(--fontsize-h4-blockquote);
430
491
  }
431
492
  }
432
493
 
433
494
  h5 {
434
- font-size: var(--font-size-h5);
435
- letter-spacing: var(--letter-spacing-h5);
436
- font-weight: var(--font-weight-h5);
495
+ font-size: var(--fontsize-h5);
496
+ letter-spacing: var(--letterspacing-h5);
497
+ font-weight: var(--fontweight-h5);
498
+
499
+ main article & {
500
+ font-size: var(--fontsize-h5-article);
501
+ }
502
+
503
+ main aside & {
504
+ font-size: var(--fontsize-h5-aside);
505
+ }
437
506
 
438
- main article &,
439
- main aside &,
440
507
  main blockquote & {
441
- font-size: var(--font-size-h6);
508
+ font-size: var(--fontsize-h5-blockquote);
442
509
  }
443
510
  }
444
511
 
445
512
  h6 {
446
- font-size: var(--font-size-h6);
447
- letter-spacing: var(--letter-spacing-h6);
448
- font-weight: var(--font-weight-h6);
513
+ font-size: var(--fontsize-h6);
514
+ letter-spacing: var(--letterspacing-h6);
515
+ font-weight: var(--fontweight-h6);
449
516
  }
450
517
 
451
518
  [rel=home] {
452
- font-size: var(--font-size-h3);
453
- font-weight: var(--font-weight-h1);
454
- letter-spacing: var(--letter-spacing-h1);
519
+ font-size: var(--fontsize-name-header);
520
+ font-weight: var(--fontweight-name-header);
521
+ letter-spacing: var(--letterspacing-name-header);
455
522
  }
456
523
 
457
524
 
package/utils.js CHANGED
@@ -2,6 +2,7 @@ import {fromMarkdown} from 'mdast-util-from-markdown'
2
2
  import {toHast} from 'mdast-util-to-hast'
3
3
  import path from "node:path"
4
4
  import { randomUUID } from "node:crypto"
5
+ import { isSecretPath, displayPath } from "./secretPaths.js"
5
6
 
6
7
  export const imageSizes = [414, 768, 1440, 1920]
7
8
  export const imageExts = ["avif", "webp"]
@@ -62,6 +63,53 @@ export function testHashtags(text) {
62
63
  }
63
64
 
64
65
 
66
+ /**
67
+ * The classes that place a page in the site, for `<body>` and for the
68
+ * page's card in a listing: one per folder it's in, from the top, and
69
+ * one for the page. `/` is `page_home`; `/blog/travel/hello-world` is
70
+ * `folder_blog folder_blog_travel page_blog_travel_hello-world`.
71
+ *
72
+ * From the published url, except where a segment is secret: there the
73
+ * author's name for it, without the salt, as the breadcrumb shows it
74
+ * (per Sam) - `blog/secret##purple-moon/hello-world.md` is
75
+ * `folder_blog folder_blog_secret page_blog_secret_hello-world`, never
76
+ * the hash and never the salt. Routing keeps a source's depth, so its
77
+ * segments line up with the url's. `_` joins segments, so one inside a
78
+ * segment becomes `-`, and a space becomes `-` too.
79
+ * @param {string | undefined} prettyURL
80
+ * @param {string} [source] - the page's source path, project-relative
81
+ * @returns {string[]}
82
+ */
83
+ export function pageClasses(prettyURL, source) {
84
+ const urlSegments = String(prettyURL ?? "").split("/").filter(Boolean)
85
+ const sourceSegments = typeof source === "string" ? source.split(/[\\/]/) : []
86
+ const named = typeof source === "string" ? displayPath(source).split(/[\\/]/) : []
87
+ const segments = urlSegments
88
+ .map((segment, index) => isSecretPath(sourceSegments[index] ?? "") ? path.parse(named[index]).name.toLowerCase() : segment)
89
+ .map(segment => segment.replace(/[_\s]+/g, "-"))
90
+ if (!segments.length) return ["page_home"]
91
+ const folders = segments.slice(0, -1).map((_, index) => `folder_${segments.slice(0, index + 1).join("_")}`)
92
+ return [...folders, `page_${segments.join("_")}`]
93
+ }
94
+
95
+ /**
96
+ * A title or breadcrumb inferred from a name - a file's, a folder's, a
97
+ * tag's. A name the author cased themselves (any capital letter) is
98
+ * theirs, kept as written: `Hello World`, `iPhone notes`, `README`. An
99
+ * all-lowercase one is sentence-cased, its hyphens and underscores read
100
+ * as spaces: `hello-world` → "Hello world", `#machine-learning` →
101
+ * "Machine learning". Some names read awkwardly (`api-design` → "Api
102
+ * design"); per Sam, that's accepted - no rule handles every case.
103
+ * @param {string | undefined} name
104
+ * @returns {string | undefined}
105
+ */
106
+ export function labelFromName(name) {
107
+ if (!name) return name
108
+ if (/\p{Lu}/u.test(name)) return name
109
+ const spaced = name.replace(/[-_]+/g, " ").replace(/\s+/g, " ").trim()
110
+ return spaced.charAt(0).toUpperCase() + spaced.slice(1)
111
+ }
112
+
65
113
  export function toTitleCase(string) {
66
114
  if (!string) return
67
115
  return string.split(" ").map(word => {
@@ -82,7 +130,7 @@ export function toTitleCase(string) {
82
130
  * title, a routed prettyURL and a tracked listing without special cases.
83
131
  */
84
132
  export function createHashtagPage(tag) {
85
- return `# ${toTitleCase(tag)}\n\n/**?tag=${tag}`
133
+ return `# ${labelFromName(tag)}\n\n/**?tag=${tag}`
86
134
  }
87
135
 
88
136
  /**
@@ -129,3 +177,28 @@ export function isListedPage(target) {
129
177
  && target.extension === ".html"
130
178
  && !target.metadata?.hidden
131
179
  }
180
+
181
+ /**
182
+ * A page its author gave no file, on purpose (`html_file: false`). It has
183
+ * no url, but it is a page: shown wherever one can be without a link to
184
+ * it - a listing's card, a table row, a feed entry - which is what
185
+ * makes card-only and feed-only pages possible. Not in a nav, the
186
+ * sitemap, backlinks or a wikilink: those are links. Another target
187
+ * with no file (a deleted page) isn't this.
188
+ * @param {any} target
189
+ */
190
+ export function isPageWithoutFile(target) {
191
+ return target.write === false && target.metadata?.html_file === false
192
+ }
193
+
194
+ /**
195
+ * listPages, plus pages without a file: for listings, cards and the
196
+ * feed, which can show a page without linking to it.
197
+ * @param {{targets: (query: object) => any[]}} api
198
+ * @param {object} query
199
+ */
200
+ export function showPages(api, query) {
201
+ return api.targets(query).filter(target => isListedPage(target) || (
202
+ isPageWithoutFile(target) && target.extension === ".html" && !target.metadata?.hidden
203
+ ))
204
+ }