@kensio/colophon 2.1.0 → 2.3.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 (357) hide show
  1. package/README.md +608 -34
  2. package/dist/cli/args.d.ts +14 -0
  3. package/dist/cli/args.d.ts.map +1 -0
  4. package/dist/cli/args.js +67 -0
  5. package/dist/cli/args.js.map +1 -0
  6. package/dist/cli/config.d.ts +12 -0
  7. package/dist/cli/config.d.ts.map +1 -0
  8. package/dist/cli/config.js +43 -0
  9. package/dist/cli/config.js.map +1 -0
  10. package/dist/cli/index.d.ts +3 -0
  11. package/dist/cli/index.d.ts.map +1 -0
  12. package/dist/cli/index.js +35 -0
  13. package/dist/cli/index.js.map +1 -0
  14. package/dist/cli.js +34 -6
  15. package/dist/cli.js.map +1 -1
  16. package/dist/config/defaults.d.ts +64 -0
  17. package/dist/config/defaults.d.ts.map +1 -0
  18. package/dist/config/defaults.js +64 -0
  19. package/dist/config/defaults.js.map +1 -0
  20. package/dist/config/index.d.ts +22 -0
  21. package/dist/config/index.d.ts.map +1 -0
  22. package/dist/config/index.js +52 -0
  23. package/dist/config/index.js.map +1 -0
  24. package/dist/config/resolve.d.ts +24 -0
  25. package/dist/config/resolve.d.ts.map +1 -0
  26. package/dist/config/resolve.js +66 -0
  27. package/dist/config/resolve.js.map +1 -0
  28. package/dist/config/size.d.ts +20 -0
  29. package/dist/config/size.d.ts.map +1 -0
  30. package/dist/config/size.js +46 -0
  31. package/dist/config/size.js.map +1 -0
  32. package/dist/config.d.ts +33 -2
  33. package/dist/config.d.ts.map +1 -1
  34. package/dist/config.js +94 -4
  35. package/dist/config.js.map +1 -1
  36. package/dist/content/index.d.ts +5 -51
  37. package/dist/content/index.d.ts.map +1 -1
  38. package/dist/content/index.js +3 -115
  39. package/dist/content/index.js.map +1 -1
  40. package/dist/content/props.d.ts +15 -0
  41. package/dist/content/props.d.ts.map +1 -0
  42. package/dist/content/props.js +71 -0
  43. package/dist/content/props.js.map +1 -0
  44. package/dist/content/slug.d.ts +23 -0
  45. package/dist/content/slug.d.ts.map +1 -0
  46. package/dist/content/slug.js +52 -0
  47. package/dist/content/slug.js.map +1 -0
  48. package/dist/content/walk.d.ts +17 -0
  49. package/dist/content/walk.d.ts.map +1 -0
  50. package/dist/content/walk.js +57 -0
  51. package/dist/content/walk.js.map +1 -0
  52. package/dist/fonts/index.d.ts +10 -0
  53. package/dist/fonts/index.d.ts.map +1 -0
  54. package/dist/fonts/index.js +11 -0
  55. package/dist/fonts/index.js.map +1 -0
  56. package/dist/fonts/materialise.d.ts +7 -0
  57. package/dist/fonts/materialise.d.ts.map +1 -0
  58. package/dist/fonts/materialise.js +47 -0
  59. package/dist/fonts/materialise.js.map +1 -0
  60. package/dist/fonts/resolve.d.ts +7 -0
  61. package/dist/fonts/resolve.d.ts.map +1 -0
  62. package/dist/fonts/resolve.js +50 -0
  63. package/dist/fonts/resolve.js.map +1 -0
  64. package/dist/fonts.d.ts +18 -0
  65. package/dist/fonts.d.ts.map +1 -0
  66. package/dist/fonts.js +102 -0
  67. package/dist/fonts.js.map +1 -0
  68. package/dist/generate/extra.d.ts +16 -0
  69. package/dist/generate/extra.d.ts.map +1 -0
  70. package/dist/generate/extra.js +60 -0
  71. package/dist/generate/extra.js.map +1 -0
  72. package/dist/generate/index.d.ts +19 -0
  73. package/dist/generate/index.d.ts.map +1 -0
  74. package/dist/generate/index.js +46 -0
  75. package/dist/generate/index.js.map +1 -0
  76. package/dist/generate/job.d.ts +35 -0
  77. package/dist/generate/job.d.ts.map +1 -0
  78. package/dist/generate/job.js +2 -0
  79. package/dist/generate/job.js.map +1 -0
  80. package/dist/generate/options.d.ts +56 -0
  81. package/dist/generate/options.d.ts.map +1 -0
  82. package/dist/generate/options.js +17 -0
  83. package/dist/generate/options.js.map +1 -0
  84. package/dist/generate/output-path.d.ts +12 -0
  85. package/dist/generate/output-path.d.ts.map +1 -0
  86. package/dist/generate/output-path.js +18 -0
  87. package/dist/generate/output-path.js.map +1 -0
  88. package/dist/generate/outputs.d.ts +28 -0
  89. package/dist/generate/outputs.d.ts.map +1 -0
  90. package/dist/generate/outputs.js +71 -0
  91. package/dist/generate/outputs.js.map +1 -0
  92. package/dist/generate/plan.d.ts +21 -0
  93. package/dist/generate/plan.d.ts.map +1 -0
  94. package/dist/generate/plan.js +72 -0
  95. package/dist/generate/plan.js.map +1 -0
  96. package/dist/generate/render-image.d.ts +11 -0
  97. package/dist/generate/render-image.d.ts.map +1 -0
  98. package/dist/generate/render-image.js +27 -0
  99. package/dist/generate/render-image.js.map +1 -0
  100. package/dist/generate.d.ts +27 -6
  101. package/dist/generate.d.ts.map +1 -1
  102. package/dist/generate.js +77 -15
  103. package/dist/generate.js.map +1 -1
  104. package/dist/highlight/color.d.ts +9 -0
  105. package/dist/highlight/color.d.ts.map +1 -0
  106. package/dist/highlight/color.js +15 -0
  107. package/dist/highlight/color.js.map +1 -0
  108. package/dist/highlight/grid.d.ts +14 -0
  109. package/dist/highlight/grid.d.ts.map +1 -0
  110. package/dist/highlight/grid.js +36 -0
  111. package/dist/highlight/grid.js.map +1 -0
  112. package/dist/highlight/index.d.ts +12 -0
  113. package/dist/highlight/index.d.ts.map +1 -0
  114. package/dist/highlight/index.js +31 -0
  115. package/dist/highlight/index.js.map +1 -0
  116. package/dist/highlight/language.d.ts +14 -0
  117. package/dist/highlight/language.d.ts.map +1 -0
  118. package/dist/highlight/language.js +42 -0
  119. package/dist/highlight/language.js.map +1 -0
  120. package/dist/highlight/normalise.d.ts +17 -0
  121. package/dist/highlight/normalise.d.ts.map +1 -0
  122. package/dist/highlight/normalise.js +37 -0
  123. package/dist/highlight/normalise.js.map +1 -0
  124. package/dist/highlight/types.d.ts +40 -0
  125. package/dist/highlight/types.d.ts.map +1 -0
  126. package/dist/highlight/types.js +2 -0
  127. package/dist/highlight/types.js.map +1 -0
  128. package/dist/highlight.d.ts +10 -0
  129. package/dist/highlight.d.ts.map +1 -1
  130. package/dist/highlight.js +25 -2
  131. package/dist/highlight.js.map +1 -1
  132. package/dist/index.d.ts +15 -9
  133. package/dist/index.d.ts.map +1 -1
  134. package/dist/index.js +9 -5
  135. package/dist/index.js.map +1 -1
  136. package/dist/manifest/build.d.ts +14 -0
  137. package/dist/manifest/build.d.ts.map +1 -0
  138. package/dist/manifest/build.js +43 -0
  139. package/dist/manifest/build.js.map +1 -0
  140. package/dist/manifest/index.d.ts +27 -0
  141. package/dist/manifest/index.d.ts.map +1 -0
  142. package/dist/manifest/index.js +31 -0
  143. package/dist/manifest/index.js.map +1 -0
  144. package/dist/manifest/order.d.ts +12 -0
  145. package/dist/manifest/order.d.ts.map +1 -0
  146. package/dist/manifest/order.js +17 -0
  147. package/dist/manifest/order.js.map +1 -0
  148. package/dist/manifest/page.d.ts +24 -0
  149. package/dist/manifest/page.d.ts.map +1 -0
  150. package/dist/manifest/page.js +55 -0
  151. package/dist/manifest/page.js.map +1 -0
  152. package/dist/meta/html.d.ts +14 -0
  153. package/dist/meta/html.d.ts.map +1 -0
  154. package/dist/meta/html.js +24 -0
  155. package/dist/meta/html.js.map +1 -0
  156. package/dist/meta/index.d.ts +11 -0
  157. package/dist/meta/index.d.ts.map +1 -0
  158. package/dist/meta/index.js +11 -0
  159. package/dist/meta/index.js.map +1 -0
  160. package/dist/meta/tags.d.ts +21 -0
  161. package/dist/meta/tags.d.ts.map +1 -0
  162. package/dist/meta/tags.js +72 -0
  163. package/dist/meta/tags.js.map +1 -0
  164. package/dist/meta/url.d.ts +15 -0
  165. package/dist/meta/url.d.ts.map +1 -0
  166. package/dist/meta/url.js +34 -0
  167. package/dist/meta/url.js.map +1 -0
  168. package/dist/placement/check.d.ts +16 -0
  169. package/dist/placement/check.d.ts.map +1 -0
  170. package/dist/placement/check.js +40 -0
  171. package/dist/placement/check.js.map +1 -0
  172. package/dist/placement/index.d.ts +29 -0
  173. package/dist/placement/index.d.ts.map +1 -0
  174. package/dist/placement/index.js +61 -0
  175. package/dist/placement/index.js.map +1 -0
  176. package/dist/placement/relative.d.ts +31 -0
  177. package/dist/placement/relative.d.ts.map +1 -0
  178. package/dist/placement/relative.js +53 -0
  179. package/dist/placement/relative.js.map +1 -0
  180. package/dist/pool.d.ts +18 -0
  181. package/dist/pool.d.ts.map +1 -0
  182. package/dist/pool.js +56 -0
  183. package/dist/pool.js.map +1 -0
  184. package/dist/render/index.d.ts +10 -0
  185. package/dist/render/index.d.ts.map +1 -0
  186. package/dist/render/index.js +27 -0
  187. package/dist/render/index.js.map +1 -0
  188. package/dist/render/png.d.ts +10 -0
  189. package/dist/render/png.d.ts.map +1 -0
  190. package/dist/render/png.js +30 -0
  191. package/dist/render/png.js.map +1 -0
  192. package/dist/render/svg.d.ts +10 -0
  193. package/dist/render/svg.d.ts.map +1 -0
  194. package/dist/render/svg.js +20 -0
  195. package/dist/render/svg.js.map +1 -0
  196. package/dist/render/template.d.ts +9 -0
  197. package/dist/render/template.d.ts.map +1 -0
  198. package/dist/render/template.js +17 -0
  199. package/dist/render/template.js.map +1 -0
  200. package/dist/render.d.ts +6 -2
  201. package/dist/render.d.ts.map +1 -1
  202. package/dist/render.js +31 -10
  203. package/dist/render.js.map +1 -1
  204. package/dist/stamp/chunk.d.ts +16 -0
  205. package/dist/stamp/chunk.d.ts.map +1 -0
  206. package/dist/stamp/chunk.js +46 -0
  207. package/dist/stamp/chunk.js.map +1 -0
  208. package/dist/stamp/config-digest.d.ts +11 -0
  209. package/dist/stamp/config-digest.d.ts.map +1 -0
  210. package/dist/stamp/config-digest.js +43 -0
  211. package/dist/stamp/config-digest.js.map +1 -0
  212. package/dist/stamp/digest.d.ts +8 -0
  213. package/dist/stamp/digest.d.ts.map +1 -0
  214. package/dist/stamp/digest.js +20 -0
  215. package/dist/stamp/digest.js.map +1 -0
  216. package/dist/stamp/index.d.ts +20 -0
  217. package/dist/stamp/index.d.ts.map +1 -0
  218. package/dist/stamp/index.js +40 -0
  219. package/dist/stamp/index.js.map +1 -0
  220. package/dist/stamp/read.d.ts +7 -0
  221. package/dist/stamp/read.d.ts.map +1 -0
  222. package/dist/stamp/read.js +62 -0
  223. package/dist/stamp/read.js.map +1 -0
  224. package/dist/stamp.d.ts +29 -0
  225. package/dist/stamp.d.ts.map +1 -0
  226. package/dist/stamp.js +198 -0
  227. package/dist/stamp.js.map +1 -0
  228. package/dist/templates/banner/badge.d.ts +7 -0
  229. package/dist/templates/banner/badge.d.ts.map +1 -0
  230. package/dist/templates/banner/badge.js +24 -0
  231. package/dist/templates/banner/badge.js.map +1 -0
  232. package/dist/templates/banner/index.d.ts +9 -0
  233. package/dist/templates/banner/index.d.ts.map +1 -0
  234. package/dist/templates/banner/index.js +66 -0
  235. package/dist/templates/banner/index.js.map +1 -0
  236. package/dist/templates/banner/lines.d.ts +27 -0
  237. package/dist/templates/banner/lines.d.ts.map +1 -0
  238. package/dist/templates/banner/lines.js +46 -0
  239. package/dist/templates/banner/lines.js.map +1 -0
  240. package/dist/templates/card/index.d.ts +7 -0
  241. package/dist/templates/card/index.d.ts.map +1 -0
  242. package/dist/templates/card/index.js +43 -0
  243. package/dist/templates/card/index.js.map +1 -0
  244. package/dist/templates/card/lines.d.ts +17 -0
  245. package/dist/templates/card/lines.d.ts.map +1 -0
  246. package/dist/templates/card/lines.js +32 -0
  247. package/dist/templates/card/lines.js.map +1 -0
  248. package/dist/templates/code/chrome.d.ts +9 -0
  249. package/dist/templates/code/chrome.d.ts.map +1 -0
  250. package/dist/templates/code/chrome.js +32 -0
  251. package/dist/templates/code/chrome.js.map +1 -0
  252. package/dist/templates/code/clip.d.ts +18 -0
  253. package/dist/templates/code/clip.d.ts.map +1 -0
  254. package/dist/templates/code/clip.js +44 -0
  255. package/dist/templates/code/clip.js.map +1 -0
  256. package/dist/templates/code/ellipsis.d.ts +3 -0
  257. package/dist/templates/code/ellipsis.d.ts.map +1 -0
  258. package/dist/templates/code/ellipsis.js +3 -0
  259. package/dist/templates/code/ellipsis.js.map +1 -0
  260. package/dist/templates/code/fit.d.ts +27 -0
  261. package/dist/templates/code/fit.d.ts.map +1 -0
  262. package/dist/templates/code/fit.js +59 -0
  263. package/dist/templates/code/fit.js.map +1 -0
  264. package/dist/templates/code/index.d.ts +12 -0
  265. package/dist/templates/code/index.d.ts.map +1 -0
  266. package/dist/templates/code/index.js +64 -0
  267. package/dist/templates/code/index.js.map +1 -0
  268. package/dist/templates/code/layout.d.ts +21 -0
  269. package/dist/templates/code/layout.d.ts.map +1 -0
  270. package/dist/templates/code/layout.js +21 -0
  271. package/dist/templates/code/layout.js.map +1 -0
  272. package/dist/templates/code/panel.d.ts +17 -0
  273. package/dist/templates/code/panel.d.ts.map +1 -0
  274. package/dist/templates/code/panel.js +20 -0
  275. package/dist/templates/code/panel.js.map +1 -0
  276. package/dist/templates/code/plate.d.ts +15 -0
  277. package/dist/templates/code/plate.d.ts.map +1 -0
  278. package/dist/templates/code/plate.js +32 -0
  279. package/dist/templates/code/plate.js.map +1 -0
  280. package/dist/templates/code/spans.d.ts +19 -0
  281. package/dist/templates/code/spans.d.ts.map +1 -0
  282. package/dist/templates/code/spans.js +36 -0
  283. package/dist/templates/code/spans.js.map +1 -0
  284. package/dist/templates/code/warn.d.ts +11 -0
  285. package/dist/templates/code/warn.d.ts.map +1 -0
  286. package/dist/templates/code/warn.js +24 -0
  287. package/dist/templates/code/warn.js.map +1 -0
  288. package/dist/templates/code.d.ts.map +1 -1
  289. package/dist/templates/code.js +101 -29
  290. package/dist/templates/code.js.map +1 -1
  291. package/dist/templates/footer.d.ts +21 -0
  292. package/dist/templates/footer.d.ts.map +1 -0
  293. package/dist/templates/footer.js +25 -0
  294. package/dist/templates/footer.js.map +1 -0
  295. package/dist/templates/index.d.ts +3 -3
  296. package/dist/templates/index.d.ts.map +1 -1
  297. package/dist/templates/index.js +6 -6
  298. package/dist/templates/index.js.map +1 -1
  299. package/dist/text/element.d.ts +18 -0
  300. package/dist/text/element.d.ts.map +1 -0
  301. package/dist/text/element.js +19 -0
  302. package/dist/text/element.js.map +1 -0
  303. package/dist/text/escape.d.ts +5 -0
  304. package/dist/text/escape.d.ts.map +1 -0
  305. package/dist/text/escape.js +12 -0
  306. package/dist/text/escape.js.map +1 -0
  307. package/dist/text/index.d.ts +7 -0
  308. package/dist/text/index.d.ts.map +1 -0
  309. package/dist/text/index.js +5 -0
  310. package/dist/text/index.js.map +1 -0
  311. package/dist/text/stack.d.ts +24 -0
  312. package/dist/text/stack.d.ts.map +1 -0
  313. package/dist/text/stack.js +18 -0
  314. package/dist/text/stack.js.map +1 -0
  315. package/dist/text/wrap.d.ts +12 -0
  316. package/dist/text/wrap.d.ts.map +1 -0
  317. package/dist/text/wrap.js +33 -0
  318. package/dist/text/wrap.js.map +1 -0
  319. package/dist/types.d.ts +345 -6
  320. package/dist/types.d.ts.map +1 -1
  321. package/dist/validate/check.d.ts +13 -0
  322. package/dist/validate/check.d.ts.map +1 -0
  323. package/dist/validate/check.js +34 -0
  324. package/dist/validate/check.js.map +1 -0
  325. package/dist/validate/index.d.ts +15 -0
  326. package/dist/validate/index.d.ts.map +1 -0
  327. package/dist/validate/index.js +41 -0
  328. package/dist/validate/index.js.map +1 -0
  329. package/dist/validate/keys.d.ts +58 -0
  330. package/dist/validate/keys.d.ts.map +1 -0
  331. package/dist/validate/keys.js +166 -0
  332. package/dist/validate/keys.js.map +1 -0
  333. package/dist/validate/overrides.d.ts +5 -0
  334. package/dist/validate/overrides.d.ts.map +1 -0
  335. package/dist/validate/overrides.js +43 -0
  336. package/dist/validate/overrides.js.map +1 -0
  337. package/dist/validate/placement.d.ts +10 -0
  338. package/dist/validate/placement.d.ts.map +1 -0
  339. package/dist/validate/placement.js +38 -0
  340. package/dist/validate/placement.js.map +1 -0
  341. package/dist/validate/sizes.d.ts +9 -0
  342. package/dist/validate/sizes.d.ts.map +1 -0
  343. package/dist/validate/sizes.js +27 -0
  344. package/dist/validate/sizes.js.map +1 -0
  345. package/dist/validate/suggest.d.ts +10 -0
  346. package/dist/validate/suggest.d.ts.map +1 -0
  347. package/dist/validate/suggest.js +55 -0
  348. package/dist/validate/suggest.js.map +1 -0
  349. package/dist/validate/values.d.ts +21 -0
  350. package/dist/validate/values.d.ts.map +1 -0
  351. package/dist/validate/values.js +57 -0
  352. package/dist/validate/values.js.map +1 -0
  353. package/dist/validate.d.ts +15 -0
  354. package/dist/validate.d.ts.map +1 -0
  355. package/dist/validate.js +300 -0
  356. package/dist/validate.js.map +1 -0
  357. package/package.json +14 -7
package/dist/types.d.ts CHANGED
@@ -9,8 +9,10 @@ export interface Dimensions {
9
9
  * A named output size. The `name` identifies the size in output filenames
10
10
  * (e.g. `og`, `square`) and must be unique within a config, so every
11
11
  * generated image gets a distinct, descriptive filename.
12
+ *
13
+ * A size may also carry {@link SizeOverrides}, applied only when rendering it.
12
14
  */
13
- export interface OutputSize {
15
+ export interface OutputSize extends SizeOverrides {
14
16
  readonly name: string;
15
17
  readonly width: number;
16
18
  readonly height: number;
@@ -75,7 +77,10 @@ export interface Badge {
75
77
  export interface CodeStyle {
76
78
  /** Shiki theme name, e.g. `github-dark`, `monokai`, `catppuccin-mocha`. */
77
79
  readonly theme?: string;
78
- /** Monospace font stack. Must resolve to a font available to `sharp`. */
80
+ /**
81
+ * Monospace font stack. Must resolve to a configured font, or to an
82
+ * installed one when `systemFonts` is on.
83
+ */
79
84
  readonly fontFamily?: string;
80
85
  /**
81
86
  * Glyph advance width as a fraction of the font size. `0.6` matches most
@@ -89,15 +94,42 @@ export interface CodeStyle {
89
94
  readonly tabSize?: number;
90
95
  /** Corner radius of the code panel, as a fraction of the smaller side. */
91
96
  readonly cornerScale?: number;
92
- /** Upper bound on the auto-fitted font size, as a fraction of image height. */
97
+ /** Upper bound on the auto-fitted font size, as a fraction of image width. */
93
98
  readonly maxFontScale?: number;
94
99
  /**
95
- * Lower bound on the auto-fitted font size, as a fraction of image height.
96
- * Code too long to fit at this size is truncated with an ellipsis rather
97
- * than shrunk into illegibility.
100
+ * Lower bound on the auto-fitted font size, as a fraction of image width —
101
+ * width, because that is what a feed scales a share image to. Code too long
102
+ * to fit at this size is truncated with an ellipsis rather than shrunk into
103
+ * illegibility, so raising this trades lines of code for readability and
104
+ * lowering it does the reverse.
98
105
  */
99
106
  readonly minFontScale?: number;
100
107
  }
108
+ /**
109
+ * A font to load into the rasteriser, given either as a file path or as the
110
+ * font's bytes. Supply one entry per font file: weight and style are read from
111
+ * the file itself, so a bold and a regular face are two entries, and the SVG's
112
+ * `font-weight` picks between them.
113
+ *
114
+ * `family` is optional and does not affect matching — the family name in the
115
+ * font file does that. When given on the first font it seeds `fontFamily`,
116
+ * which saves repeating the name for the common single-font case.
117
+ */
118
+ export type FontSource = {
119
+ readonly family?: string;
120
+ /**
121
+ * Path to a `.ttf`, `.otf`, `.ttc` or `.otc` file, resolved from the
122
+ * current working directory when relative.
123
+ */
124
+ readonly path: string;
125
+ } | {
126
+ readonly family?: string;
127
+ /**
128
+ * The font file's bytes, for fonts loaded from a bundle or fetched at
129
+ * build time rather than read from disk.
130
+ */
131
+ readonly data: Uint8Array;
132
+ };
101
133
  /**
102
134
  * Image properties, typically read from a post's frontmatter. The schema is
103
135
  * intentionally open: templates read whatever fields they understand, so a
@@ -111,6 +143,199 @@ export interface MetaImageProps {
111
143
  readonly version?: string | number;
112
144
  readonly [key: string]: unknown;
113
145
  }
146
+ /**
147
+ * Build image props from a post's whole frontmatter, so a project can use the
148
+ * fields it already has rather than adding a props block to every file.
149
+ *
150
+ * Return `undefined` to leave a post without images. That is the filter for
151
+ * drafts, section indexes and anything else in the tree that is not a page
152
+ * worth sharing — without it, mapping frontmatter would mean an image for every
153
+ * markdown file there is. It only settles posts that say nothing for
154
+ * themselves, though: one declaring a props block is rendered either way, since
155
+ * asking for an image outright beats a blanket rule.
156
+ *
157
+ * The returned fields need not be complete: they are merged under whatever the
158
+ * post declares explicitly, and a missing template falls back to
159
+ * {@link ContentOptions.defaultTemplate}.
160
+ */
161
+ export type PropsFromFrontmatter = (frontmatter: Record<string, unknown>) => Record<string, unknown> | undefined;
162
+ /**
163
+ * How a post's slug — the base name for its images — is derived from its path
164
+ * when the frontmatter does not declare one.
165
+ *
166
+ * - `basename`: the filename without extension, or the parent directory for
167
+ * `index.*`. Suits page bundles, where the image sits beside the content.
168
+ * - `route`: the whole path without extension, with `index.*` standing for its
169
+ * directory, so `services/iam/index.md` becomes `services/iam` and a root
170
+ * `index.md` becomes `index`. Suits a site addressed by route.
171
+ */
172
+ export type SlugStrategy = "basename" | "route";
173
+ /**
174
+ * How to read image props out of a content tree. Every field is optional.
175
+ *
176
+ * This is the host-project half of the job — finding posts and understanding
177
+ * their frontmatter — and is deliberately absent from {@link ResolvedConfig}:
178
+ * a template is handed the resolved config, and where the props came from is
179
+ * none of its business.
180
+ */
181
+ export interface ContentOptions {
182
+ /** Frontmatter key holding the image props object. Default `meta_img_props`. */
183
+ readonly propsKey?: string;
184
+ /** Field within the props object naming the template. Default `template`. */
185
+ readonly templateField?: string;
186
+ /** Template to use when the template field is absent. */
187
+ readonly defaultTemplate?: string;
188
+ /**
189
+ * Derive props from a post's existing frontmatter, for a site whose posts
190
+ * already carry the fields an image needs under different names. An explicit
191
+ * props object still wins field by field, so per-post overrides keep working.
192
+ */
193
+ readonly props?: PropsFromFrontmatter;
194
+ /**
195
+ * Top-level frontmatter field to read the post slug from (used as the base
196
+ * filename). Default `slug`; falls back to the file/directory name.
197
+ */
198
+ readonly slugField?: string;
199
+ /**
200
+ * How to derive a slug from a post's path when its frontmatter declares
201
+ * none. Default `basename`.
202
+ */
203
+ readonly slugStrategy?: SlugStrategy;
204
+ /** File extensions to include. Default `.md` and `.markdown`. */
205
+ readonly extensions?: readonly string[];
206
+ }
207
+ /**
208
+ * A discovered content file with the image props read from its frontmatter.
209
+ *
210
+ * It lives here rather than with the walker so that {@link Placement} can name
211
+ * it without the config module depending on the content module, for the reason
212
+ * {@link ContentOptions} does.
213
+ */
214
+ export interface ContentFile {
215
+ /** Path relative to the walk `dir`. */
216
+ readonly contentPath: string;
217
+ /** Absolute path on disk. */
218
+ readonly absolutePath: string;
219
+ /** Base filename for this post's images (frontmatter slug, or path-derived). */
220
+ readonly slug: string;
221
+ readonly props: MetaImageProps;
222
+ }
223
+ /**
224
+ * Where an image is written, and the URL it is served at once it is.
225
+ *
226
+ * `outputPath` alone says where the bytes go and nothing about how anyone
227
+ * reaches them, so every site ends up rebuilding that mapping in its own
228
+ * templates — from information Colophon had at generate time and threw away.
229
+ *
230
+ * - `beside-content`: next to the post, which is the page-bundle convention
231
+ * and what Colophon has always done. Still the default.
232
+ * - `public-dir`: gathered into one directory, as Astro, Eleventy and Vite
233
+ * expect. A slug carrying directories keeps them underneath it.
234
+ * - `custom`: for a site whose mapping is its own — images under a dated
235
+ * directory, say.
236
+ *
237
+ * `urlBase` is what makes a URL: it is prefixed to the image's path under the
238
+ * root that placed it, and without one there is no URL, because no directory
239
+ * on disk says by itself how it is served. It can be a site-relative path
240
+ * (`/og`) or an absolute one, for images served from a CDN.
241
+ *
242
+ * `hash` puts a digest of the image's inputs in its filename, so that changing
243
+ * a post gives its image a URL nobody has cached yet. It is opt-in because it
244
+ * also means the filename moves whenever the image does, which not every setup
245
+ * wants. `custom` has no say in it: a placement naming its own paths is the
246
+ * one that can hash them itself.
247
+ */
248
+ export type Placement = {
249
+ readonly strategy: "beside-content";
250
+ readonly urlBase?: string;
251
+ readonly hash?: boolean;
252
+ } | {
253
+ readonly strategy: "public-dir";
254
+ /** Directory to gather images into, relative to the working directory. */
255
+ readonly dir: string;
256
+ readonly urlBase?: string;
257
+ readonly hash?: boolean;
258
+ } | {
259
+ readonly strategy: "custom";
260
+ readonly path: (file: ContentFile, size: OutputSize) => string;
261
+ /** Omit for images that are written but not served. */
262
+ readonly url?: (file: ContentFile, size: OutputSize) => string | undefined;
263
+ };
264
+ /**
265
+ * One image in the manifest.
266
+ *
267
+ * The dimensions are the ones it was actually rendered at, which is the point:
268
+ * sites hardcode 1200 and 630 into their meta tags because nothing told them
269
+ * otherwise, and a size they later change leaves the tags behind.
270
+ */
271
+ export interface ManifestImage {
272
+ /** Absent where the placement knows no URL — see {@link Placement}. */
273
+ readonly url?: string;
274
+ readonly width: number;
275
+ readonly height: number;
276
+ }
277
+ /** One page's images, keyed by output size name. */
278
+ export interface ManifestPage {
279
+ readonly images: Readonly<Record<string, ManifestImage>>;
280
+ /**
281
+ * The name of the most landscape image, by aspect ratio, with ties going to
282
+ * the first size configured. It is what a `summary_large_image` card wants,
283
+ * and picking it is a check every site currently writes for itself.
284
+ */
285
+ readonly widest: string;
286
+ /** Alt text, from the props' title. Absent for a page that has no title. */
287
+ readonly alt?: string;
288
+ }
289
+ /**
290
+ * What a build generated, for the site to read back: a JSON file listing every
291
+ * page's images, their URLs and the dimensions they were rendered at.
292
+ *
293
+ * Without it a site reconstructs all of that in template code — globbing for
294
+ * `*-og.png` to find the landscape variant, or writing image paths back into
295
+ * each post's frontmatter. All of it is known while generating.
296
+ *
297
+ * Pages are keyed by slug, which is what a site addresses a page by: with
298
+ * `slugStrategy: "route"` that is the route itself.
299
+ */
300
+ export interface Manifest {
301
+ /** Schema version, so a reader can tell what it is holding. */
302
+ readonly version: 1;
303
+ readonly pages: Readonly<Record<string, ManifestPage>>;
304
+ }
305
+ /**
306
+ * One `<meta>` tag, as the attributes it carries.
307
+ *
308
+ * Open Graph names its tags with `property` and Twitter with `name`, which is
309
+ * a distinction sites get wrong routinely. Keeping them apart in the type
310
+ * means a component can spread a tag — `<meta {...tag} />` — and be right
311
+ * either way.
312
+ */
313
+ export type MetaTag = {
314
+ readonly property: string;
315
+ readonly content: string;
316
+ } | {
317
+ readonly name: string;
318
+ readonly content: string;
319
+ };
320
+ /** Options for {@link MetaTag} generation. */
321
+ export interface MetaTagOptions {
322
+ /**
323
+ * Absolute base for a site-relative image URL, e.g. `https://example.com`.
324
+ *
325
+ * Open Graph wants an absolute URL — a crawler has no page to resolve a
326
+ * relative one against — and a manifest records whatever the placement's
327
+ * `urlBase` said, which is usually site-relative. A URL that is already
328
+ * absolute is left alone, so a CDN base needs nothing here.
329
+ */
330
+ readonly baseUrl?: string;
331
+ }
332
+ /**
333
+ * Reports something a template had to compromise on — code truncated to stay
334
+ * legible, so far. Rendering carries on regardless: a share image is worth
335
+ * having even when the input did not quite fit, but the author should hear
336
+ * about it rather than discover it in someone else's timeline.
337
+ */
338
+ export type WarningHandler = (message: string) => void;
114
339
  /**
115
340
  * Everything a template needs to produce its SVG foreground content.
116
341
  */
@@ -140,6 +365,24 @@ export interface ColophonConfig {
140
365
  readonly colors?: BrandColors;
141
366
  /** Explicit background, overriding the gradient derived from `colors`. */
142
367
  readonly background?: Background;
368
+ /**
369
+ * Fonts to load into the rasteriser, so the output does not depend on what
370
+ * the build machine happens to have installed. Supplying any font turns
371
+ * {@link ColophonConfig.systemFonts} off by default, which is the point:
372
+ * a laptop, CI and a Docker image then render the same image.
373
+ */
374
+ readonly fonts?: readonly FontSource[];
375
+ /**
376
+ * Whether to also load the machine's installed fonts. Defaults to `true`
377
+ * when no `fonts` are configured (nothing else would render) and `false`
378
+ * when they are. Turn it on alongside `fonts` to fall back to system fonts
379
+ * for families you have not supplied — at the cost of determinism.
380
+ */
381
+ readonly systemFonts?: boolean;
382
+ /**
383
+ * Font stack for template text. Defaults to the `family` of the first
384
+ * configured font, or to `DEFAULT_FONT_FAMILY` when there is none.
385
+ */
143
386
  readonly fontFamily?: string;
144
387
  /** Footer text drawn along the bottom edge. Omit (the default) for none. */
145
388
  readonly footer?: string;
@@ -147,6 +390,11 @@ export interface ColophonConfig {
147
390
  readonly badge?: Badge;
148
391
  /** Styling for the `code` template. */
149
392
  readonly code?: CodeStyle;
393
+ /**
394
+ * Where non-fatal rendering complaints go. Defaults to `console.warn`; pass
395
+ * a no-op to silence them, or your build's logger to route them.
396
+ */
397
+ readonly onWarning?: WarningHandler;
150
398
  /**
151
399
  * Output sizes, each with a unique `name` used in the filename. Defaults to
152
400
  * a 1.91:1 Open Graph landscape plus a 1:1 square (see `DEFAULT_SIZES`).
@@ -154,6 +402,93 @@ export interface ColophonConfig {
154
402
  readonly sizes?: readonly OutputSize[];
155
403
  /** Extra templates, merged over (and able to override) the built-ins. */
156
404
  readonly templates?: Readonly<Record<string, Template>>;
405
+ /**
406
+ * How to read props out of the content tree. Used by `generate` and the CLI;
407
+ * the render core never sees it.
408
+ */
409
+ readonly content?: ContentOptions;
410
+ /**
411
+ * Where images are written and what URL they end up at. Defaults to
412
+ * `beside-content`, which is what Colophon did before there was a choice.
413
+ */
414
+ readonly placement?: Placement;
415
+ /**
416
+ * Where to write a {@link Manifest} of everything the build generated,
417
+ * relative to the working directory. Omit (the default) to write none.
418
+ *
419
+ * Somewhere the site reads data from: `data/colophon.json` for Hugo,
420
+ * `src/data/` for Astro, `_data/` for Eleventy and Jekyll.
421
+ */
422
+ readonly manifest?: string;
423
+ /**
424
+ * One-off images that belong to the project rather than to any post — a
425
+ * package card, a repository social preview. Rendered by the same build, and
426
+ * skipped or re-rendered on the same stamps.
427
+ */
428
+ readonly extra?: readonly ExtraImage[];
429
+ }
430
+ /**
431
+ * A function a config module may export instead of a config object, so that a
432
+ * config which has to compute something — brand colours read out of the site's
433
+ * own stylesheet, say — can still be a config module rather than a script.
434
+ *
435
+ * It takes no arguments. Anything it might be handed is either already on the
436
+ * command line or a decision the config itself is making.
437
+ */
438
+ export type ColophonConfigFactory = () => ColophonConfig | Promise<ColophonConfig>;
439
+ /** What a config module's default export may be. */
440
+ export type ColophonConfigInput = ColophonConfig | ColophonConfigFactory;
441
+ /**
442
+ * Config an {@link OutputSize} may override for itself.
443
+ *
444
+ * Some settings only make sense per size: `code.minFontScale` is the clearest
445
+ * case, because a 1:1 square and a 1.91:1 landscape have very different amounts
446
+ * of vertical room for the same snippet. Without this the only way to vary one
447
+ * is a `generate` pass per size, which walks and parses the whole content tree
448
+ * again for each.
449
+ *
450
+ * Only what a template reads while drawing is overridable. `fonts`,
451
+ * `systemFonts` and `templates` are shared build inputs rather than part of the
452
+ * picture; `onWarning` is where messages go, not what they say; and `sizes`
453
+ * inside a size would be nonsense.
454
+ */
455
+ export interface SizeOverrides {
456
+ /**
457
+ * Merged over the config's `colors`, so a size can change one shade on its
458
+ * own — `brand` is optional here precisely because the rest are kept.
459
+ */
460
+ readonly colors?: Partial<BrandColors>;
461
+ /** Replaces the config's background outright — see the note on merging. */
462
+ readonly background?: Background;
463
+ readonly fontFamily?: string;
464
+ readonly footer?: string;
465
+ readonly badge?: Badge;
466
+ /** Merged over the config's `code`, so a size can change one setting. */
467
+ readonly code?: CodeStyle;
468
+ }
469
+ /**
470
+ * A single image that is not tied to a content file: props, somewhere to write
471
+ * it, and the size to draw it at.
472
+ *
473
+ * The alternative is a script that calls `renderMetaImages` and writes the
474
+ * bytes itself, which is a lot of machinery for one card — and one that keeps
475
+ * neither the rebuild stamps nor the build log a content image gets.
476
+ */
477
+ export interface ExtraImage {
478
+ readonly props: MetaImageProps;
479
+ /**
480
+ * Where to write the PNG, resolved from the current working directory when
481
+ * relative. This image has no post to sit beside, so there is nothing to
482
+ * derive a path from and `generate`'s `outputPath` is not consulted.
483
+ */
484
+ readonly output: string;
485
+ /**
486
+ * The size to render at, {@link SizeOverrides} and all — an inline size is
487
+ * how a one-off image gets its own footer or palette without a whole entry
488
+ * in `sizes`. Defaults to the first configured size, since a one-off card
489
+ * usually wants to match the site's primary share format.
490
+ */
491
+ readonly size?: OutputSize;
157
492
  }
158
493
  /**
159
494
  * Fully-resolved configuration with all defaults applied.
@@ -161,10 +496,14 @@ export interface ColophonConfig {
161
496
  export interface ResolvedConfig {
162
497
  readonly colors: Required<BrandColors>;
163
498
  readonly background: Background;
499
+ /** Configured fonts, with every `path` made absolute. */
500
+ readonly fonts: readonly FontSource[];
501
+ readonly systemFonts: boolean;
164
502
  readonly fontFamily: string;
165
503
  readonly footer: string | undefined;
166
504
  readonly badge: Badge | undefined;
167
505
  readonly code: Required<CodeStyle>;
506
+ readonly onWarning: WarningHandler;
168
507
  readonly sizes: readonly OutputSize[];
169
508
  readonly templates: Readonly<Record<string, Template>>;
170
509
  }
@@ -1 +1 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KAAK,EAAE,KAAK,GAAG,SAAS,CAAC;IAClC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC;IACnC,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAC;IACnC,QAAQ,CAAC,KAAK,EAAE,SAAS,UAAU,EAAE,CAAC;IACtC,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;CACxD;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,+DAA+D;IAC/D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB"}
@@ -0,0 +1,13 @@
1
+ /** Whether a value is a plain object, and so has keys worth checking. */
2
+ export declare function isRecord(value: unknown): value is Record<string, unknown>;
3
+ /** Whether a value is a list, and so has entries worth checking. */
4
+ export declare function isList(value: unknown): value is readonly unknown[];
5
+ /**
6
+ * Report every key of one config object that is not a known option. Anything
7
+ * that is not an object is left alone: the shape of a value is the type
8
+ * checker's business, and there are no keys to judge either way.
9
+ */
10
+ export declare function checkKeys(value: unknown, path: string, known: readonly string[], problems: string[]): void;
11
+ /** Check every entry of a list, naming each by its index. */
12
+ export declare function checkEach(values: unknown, path: string, known: readonly string[], problems: string[]): void;
13
+ //# sourceMappingURL=check.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../src/validate/check.ts"],"names":[],"mappings":"AAEA,yEAAyE;AACzE,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzE;AAED,oEAAoE;AACpE,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,SAAS,OAAO,EAAE,CAElE;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CACvB,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,QAAQ,EAAE,MAAM,EAAE,GACjB,IAAI,CAYN;AAED,6DAA6D;AAC7D,wBAAgB,SAAS,CACvB,MAAM,EAAE,OAAO,EACf,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,QAAQ,EAAE,MAAM,EAAE,GACjB,IAAI,CAQN"}
@@ -0,0 +1,34 @@
1
+ import { describeUnknownOption } from "./suggest.js";
2
+ /** Whether a value is a plain object, and so has keys worth checking. */
3
+ export function isRecord(value) {
4
+ return typeof value === "object" && value !== null && !Array.isArray(value);
5
+ }
6
+ /** Whether a value is a list, and so has entries worth checking. */
7
+ export function isList(value) {
8
+ return Array.isArray(value);
9
+ }
10
+ /**
11
+ * Report every key of one config object that is not a known option. Anything
12
+ * that is not an object is left alone: the shape of a value is the type
13
+ * checker's business, and there are no keys to judge either way.
14
+ */
15
+ export function checkKeys(value, path, known, problems) {
16
+ if (!isRecord(value)) {
17
+ return;
18
+ }
19
+ for (const key of Object.keys(value)) {
20
+ if (!known.includes(key)) {
21
+ problems.push(describeUnknownOption(path === "" ? key : `${path}.${key}`, key, known));
22
+ }
23
+ }
24
+ }
25
+ /** Check every entry of a list, naming each by its index. */
26
+ export function checkEach(values, path, known, problems) {
27
+ if (!isList(values)) {
28
+ return;
29
+ }
30
+ for (const [index, value] of values.entries()) {
31
+ checkKeys(value, `${path}[${String(index)}]`, known, problems);
32
+ }
33
+ }
34
+ //# sourceMappingURL=check.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check.js","sourceRoot":"","sources":["../../src/validate/check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAErD,yEAAyE;AACzE,MAAM,UAAU,QAAQ,CAA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reject a config carrying options Colophon does not know.
4
+ *
5
+ * An unrecognised key is otherwise ignored in silence: the build succeeds, the
6
+ * option does nothing, and the images come out with the defaults in its place.
7
+ * That is at its worst across an upgrade, where a config that still reads
8
+ * correctly is describing images nobody is rendering.
9
+ *
10
+ * Only the closed parts of the config are checked. The names in `templates`
11
+ * are the project's own, and a post's props are open by design — a template
12
+ * reads whatever fields it understands.
13
+ */
14
+ export declare function validateConfig(config: ColophonConfig): void;
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/validate/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAclD;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CAsC3D"}
@@ -0,0 +1,41 @@
1
+ import { checkEach, checkKeys } from "./check.js";
2
+ import { badgeKeys, codeKeys, colorKeys, configKeys, contentKeys, fontKeys, } from "./keys.js";
3
+ import { checkExtras, checkSizes } from "./overrides.js";
4
+ import { checkPlacement } from "./placement.js";
5
+ import { checkBackground, checkSlugStrategy } from "./values.js";
6
+ /**
7
+ * Reject a config carrying options Colophon does not know.
8
+ *
9
+ * An unrecognised key is otherwise ignored in silence: the build succeeds, the
10
+ * option does nothing, and the images come out with the defaults in its place.
11
+ * That is at its worst across an upgrade, where a config that still reads
12
+ * correctly is describing images nobody is rendering.
13
+ *
14
+ * Only the closed parts of the config are checked. The names in `templates`
15
+ * are the project's own, and a post's props are open by design — a template
16
+ * reads whatever fields it understands.
17
+ */
18
+ export function validateConfig(config) {
19
+ // The types say what should be here; validation exists for when it is not.
20
+ const raw = config;
21
+ const problems = [];
22
+ checkKeys(config, "", configKeys, problems);
23
+ checkKeys(raw.colors, "colors", colorKeys, problems);
24
+ checkKeys(raw.badge, "badge", badgeKeys, problems);
25
+ checkKeys(raw.code, "code", codeKeys, problems);
26
+ checkKeys(raw.content, "content", contentKeys, problems);
27
+ checkSlugStrategy(raw.content, problems);
28
+ checkSizes(raw.sizes, problems);
29
+ checkExtras(raw.extra, problems);
30
+ checkEach(raw.fonts, "fonts", fontKeys, problems);
31
+ checkBackground(raw.background, "background", problems);
32
+ checkPlacement(raw.placement, problems);
33
+ const [first, ...rest] = problems;
34
+ if (first === undefined) {
35
+ return;
36
+ }
37
+ throw new Error(rest.length === 0
38
+ ? first
39
+ : `Invalid config:\n${problems.map((problem) => ` - ${problem}`).join("\n")}`);
40
+ }
41
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/validate/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EACL,SAAS,EACT,QAAQ,EACR,SAAS,EACT,UAAU,EACV,WAAW,EACX,QAAQ,GACT,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEjE;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,cAAc,CAAC,MAAsB;IACnD,2EAA2E;IAC3E,MAAM,GAAG,GAAG,MAUX,CAAC;IACF,MAAM,QAAQ,GAAa,EAAE,CAAC;IAE9B,SAAS,CAAC,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;IAC5C,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;IACrD,SAAS,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;IACnD,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAChD,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC;IACzD,iBAAiB,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACzC,UAAU,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAChC,WAAW,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACjC,SAAS,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAClD,eAAe,CAAC,GAAG,CAAC,UAAU,EAAE,YAAY,EAAE,QAAQ,CAAC,CAAC;IACxD,cAAc,CAAC,GAAG,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAExC,MAAM,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,GAAG,QAAQ,CAAC;IAElC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO;IACT,CAAC;IAED,MAAM,IAAI,KAAK,CACb,IAAI,CAAC,MAAM,KAAK,CAAC;QACf,CAAC,CAAC,KAAK;QACP,CAAC,CAAC,oBAAoB,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACjF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,58 @@
1
+ /** Top-level config options. */
2
+ export declare const configKeys: readonly string[];
3
+ /** Keys of a placement that writes each image beside its post. */
4
+ export declare const besideContentKeys: readonly string[];
5
+ /** Keys of a placement that gathers images into one directory. */
6
+ export declare const publicDirKeys: readonly string[];
7
+ /** Keys of a placement that works both halves out for itself. */
8
+ export declare const customPlacementKeys: readonly string[];
9
+ /**
10
+ * The placement strategies, for the same reason as {@link backgroundTypes}: a
11
+ * mistyped one would otherwise be reported as an unknown key on whichever
12
+ * variant it was guessed to be.
13
+ *
14
+ * Two of the names are hyphenated because they are values a user writes in a
15
+ * config, not identifiers — the casing rule is about the latter. Keeping them
16
+ * as keys is what keeps the list exhaustive, which is the whole point of it.
17
+ */
18
+ export declare const placementStrategies: readonly string[];
19
+ /** One ad hoc image declared in config. */
20
+ export declare const extraKeys: readonly string[];
21
+ /** Options for reading a project's own frontmatter. */
22
+ export declare const contentKeys: readonly string[];
23
+ /** Brand palette shades. */
24
+ export declare const colorKeys: readonly string[];
25
+ /** Corner-badge options. */
26
+ export declare const badgeKeys: readonly string[];
27
+ /** `code` template styling options. */
28
+ export declare const codeKeys: readonly string[];
29
+ /** One output size, including the overrides it may carry. */
30
+ export declare const sizeKeys: readonly string[];
31
+ /**
32
+ * Both font variants at once. Which of `path` and `data` a font may carry is
33
+ * `fonts/resolve.ts`'s ruling to make, and it has a better message for it than
34
+ * a list of keys could.
35
+ */
36
+ export declare const fontKeys: string[];
37
+ /** Keys of a solid background. */
38
+ export declare const solidBackgroundKeys: readonly string[];
39
+ /** Keys of a gradient background. */
40
+ export declare const gradientBackgroundKeys: readonly string[];
41
+ /** Keys of one gradient stop. */
42
+ export declare const gradientStopKeys: readonly string[];
43
+ /** Keys of a gradient's `from` and `to` points. */
44
+ export declare const gradientPointKeys: readonly string[];
45
+ /**
46
+ * The background variants, as values to check a declared `type` against. Typed
47
+ * against the union for the same reason the key lists are: a variant added to
48
+ * `Background` and not listed here would otherwise be reported as an unknown
49
+ * type, rejecting a config that is perfectly valid.
50
+ */
51
+ export declare const backgroundTypes: readonly string[];
52
+ /**
53
+ * The slug strategies, for the same reason as {@link backgroundTypes}:
54
+ * `slugFromPath` treats anything that is not `basename` as a route, so a
55
+ * mistyped `rout` would quietly re-slug a whole site rather than complain.
56
+ */
57
+ export declare const slugStrategies: readonly string[];
58
+ //# sourceMappingURL=keys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../../src/validate/keys.ts"],"names":[],"mappings":"AA0CA,gCAAgC;AAChC,eAAO,MAAM,UAAU,mBAgBrB,CAAC;AAEH,kEAAkE;AAClE,eAAO,MAAM,iBAAiB,mBAI5B,CAAC;AAEH,kEAAkE;AAClE,eAAO,MAAM,aAAa,mBAKxB,CAAC;AAEH,iEAAiE;AACjE,eAAO,MAAM,mBAAmB,mBAI9B,CAAC;AAEH;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,mBAQ9B,CAAC;AAEH,2CAA2C;AAC3C,eAAO,MAAM,SAAS,mBAIpB,CAAC;AAEH,uDAAuD;AACvD,eAAO,MAAM,WAAW,mBAQtB,CAAC;AAEH,4BAA4B;AAC5B,eAAO,MAAM,SAAS,mBAKpB,CAAC;AAEH,4BAA4B;AAC5B,eAAO,MAAM,SAAS,mBAIpB,CAAC;AAEH,uCAAuC;AACvC,eAAO,MAAM,QAAQ,mBASnB,CAAC;AAEH,6DAA6D;AAC7D,eAAO,MAAM,QAAQ,mBAUnB,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,QAAQ,UAKpB,CAAC;AAEF,kCAAkC;AAClC,eAAO,MAAM,mBAAmB,mBAG9B,CAAC;AAEH,qCAAqC;AACrC,eAAO,MAAM,sBAAsB,mBAKjC,CAAC;AAEH,iCAAiC;AACjC,eAAO,MAAM,gBAAgB,mBAG3B,CAAC;AAEH,mDAAmD;AACnD,eAAO,MAAM,iBAAiB,mBAAiD,CAAC;AAEhF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,mBAG1B,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,cAAc,mBAGzB,CAAC"}