@zvndev/darkmown 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 (74) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +65 -0
  3. package/docs/cli.md +8 -0
  4. package/docs/spec-alignment.md +18 -0
  5. package/grammar/wd-directives.gbnf +58 -0
  6. package/package.json +17 -10
  7. package/site/pages/docs/index.wd +29 -0
  8. package/site/pages/playground/index.js +47 -46
  9. package/src/builder.js +5 -0
  10. package/src/catalog.js +601 -0
  11. package/src/cli.js +8 -0
  12. package/src/compiler/actions.js +87 -34
  13. package/src/compiler/body.js +36 -14
  14. package/src/compiler/collections.js +16 -10
  15. package/src/compiler/context.js +70 -1
  16. package/src/compiler/fetch.js +51 -19
  17. package/src/compiler/format.js +5 -2
  18. package/src/compiler/forms.js +169 -50
  19. package/src/compiler/frontmatter.js +11 -2
  20. package/src/compiler/fs-reader.js +2 -1
  21. package/src/compiler/image-size.js +340 -0
  22. package/src/compiler/includes.js +8 -4
  23. package/src/compiler/interpolation.js +15 -7
  24. package/src/compiler/loops.js +78 -39
  25. package/src/compiler/markdown.js +4 -3
  26. package/src/compiler/media.js +38 -10
  27. package/src/compiler/page.js +8 -6
  28. package/src/compiler/predicates.js +74 -30
  29. package/src/compiler/reader.js +12 -2
  30. package/src/compiler/state.js +83 -18
  31. package/src/compiler/structure.js +57 -24
  32. package/src/deploy.js +8 -4
  33. package/src/errors.js +1156 -0
  34. package/src/grammar.js +131 -0
  35. package/src/index.js +1 -0
  36. package/src/router.js +7 -4
  37. package/src/scaffold.js +4 -2
  38. package/src/skin.js +17 -6
  39. package/types/api-runner.d.ts +94 -0
  40. package/types/builder.d.ts +141 -10
  41. package/types/catalog.d.ts +97 -0
  42. package/types/compiler/actions.d.ts +41 -0
  43. package/types/compiler/body.d.ts +11 -0
  44. package/types/compiler/collections.d.ts +76 -0
  45. package/types/compiler/context.d.ts +661 -0
  46. package/types/compiler/directives.d.ts +6 -0
  47. package/types/compiler/expr-ast.d.ts +20 -0
  48. package/types/compiler/fetch.d.ts +29 -0
  49. package/types/compiler/format.d.ts +49 -0
  50. package/types/compiler/forms.d.ts +94 -0
  51. package/types/compiler/frontmatter.d.ts +33 -0
  52. package/types/compiler/fs-reader.d.ts +7 -0
  53. package/types/compiler/image-size.d.ts +14 -0
  54. package/types/compiler/includes.d.ts +100 -0
  55. package/types/compiler/index.d.ts +5 -0
  56. package/types/compiler/interpolation.d.ts +115 -0
  57. package/types/compiler/loops.d.ts +36 -0
  58. package/types/compiler/markdown.d.ts +34 -0
  59. package/types/compiler/media.d.ts +32 -0
  60. package/types/compiler/page.d.ts +109 -0
  61. package/types/compiler/predicates.d.ts +50 -0
  62. package/types/compiler/reader.d.ts +56 -0
  63. package/types/compiler/state.d.ts +68 -0
  64. package/types/compiler/structure.d.ts +56 -0
  65. package/types/compiler.d.ts +35 -223
  66. package/types/dev.d.ts +47 -2
  67. package/types/errors.d.ts +100 -0
  68. package/types/feeds.d.ts +150 -0
  69. package/types/headers.d.ts +44 -0
  70. package/types/highlight.d.ts +24 -0
  71. package/types/router.d.ts +42 -3
  72. package/types/scaffold.d.ts +15 -3
  73. package/types/skin.d.ts +28 -1
  74. package/types/statics.d.ts +2 -1
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Build the collection index from the router's discovered routes: one entry per
3
+ * `site/pages/<name>/…` route, grouped under the FIRST path segment (the
4
+ * collection name). The home route, top-level pages, and the synthetic `/404/`
5
+ * route are not entries. Reuses each route's already-parsed `meta` (no re-parse)
6
+ * and reads the `.md` body only for the excerpt fallback. When a collection has
7
+ * a `_schema.wd`, every entry is validated against it here (throwing on the
8
+ * first violation), so a malformed entry fails the build with a `file:line`.
9
+ *
10
+ * @param {Route[]} routes Post-draft-filter routes from `discoverRoutes`.
11
+ * @param {Paths} paths Resolved project paths (`routesRoot` for `_schema.wd`).
12
+ * @param {import("./reader.js").Reader} [reader] Source reader (fs-backed by
13
+ * default; pass an in-memory reader to build collections without a filesystem).
14
+ * @returns {Map<string, CollectionRow[]>} Collection name → entry rows.
15
+ */
16
+ export function buildCollections(routes: Route[], paths: Paths, reader?: import("./reader.js").Reader): Map<string, CollectionRow[]>;
17
+ /**
18
+ * A parsed `_schema.wd` field rule.
19
+ * @typedef {object} SchemaField
20
+ * @property {string} name Field name.
21
+ * @property {string} type One of {@link SCHEMA_TYPES}.
22
+ * @property {boolean} optional Whether the field may be absent (`?` modifier).
23
+ */
24
+ /**
25
+ * Read + parse a collection's `_schema.wd`, or null when the file is absent
26
+ * (validation is opt-in). The schema is frontmatter-shaped — one `field: type`
27
+ * line per rule inside the `---` block — so authors write it exactly like the
28
+ * frontmatter it validates. Each type must be in the closed {@link SCHEMA_TYPES}
29
+ * vocabulary (`?` suffix = optional); an unknown token is a compile error in the
30
+ * schema file itself, pointing at the offending line.
31
+ * @param {string} name Collection name.
32
+ * @param {Paths} paths
33
+ * @param {import("./reader.js").Reader} [reader] Source reader (fs-backed by default).
34
+ * @returns {SchemaField[] | null}
35
+ */
36
+ export function readSchema(name: string, paths: Paths, reader?: import("./reader.js").Reader): SchemaField[] | null;
37
+ /**
38
+ * Parse a `_schema.wd` source into field rules. The schema fields live in the
39
+ * frontmatter block; the body (if any) is ignored, so a schema file can carry a
40
+ * prose note after its `---` fence. Each field line is `name: type` where type
41
+ * is a closed token with an optional trailing `?`.
42
+ * @param {string} raw `_schema.wd` file contents.
43
+ * @param {string} file Absolute path, for `file:line` errors.
44
+ * @returns {SchemaField[]}
45
+ */
46
+ export function parseSchema(raw: string, file: string): SchemaField[];
47
+ /**
48
+ * A parsed `_schema.wd` field rule.
49
+ */
50
+ export type SchemaField = {
51
+ /**
52
+ * Field name.
53
+ */
54
+ name: string;
55
+ /**
56
+ * One of {@link SCHEMA_TYPES}.
57
+ */
58
+ type: string;
59
+ /**
60
+ * Whether the field may be absent (`?` modifier).
61
+ */
62
+ optional: boolean;
63
+ };
64
+ export type Paths = import("./context.js").Paths;
65
+ export type Meta = import("./context.js").Meta;
66
+ export type Route = import("../router.js").Route;
67
+ /**
68
+ * A collection entry row: every frontmatter field, plus derived `url`/`slug`/
69
+ * `excerpt`. Keyed loosely so authors' custom frontmatter keys pass through to
70
+ * `{ post.whatever }` and `where`/`sort` without a closed schema here.
71
+ */
72
+ export type CollectionRow = Record<string, unknown> & {
73
+ url: string;
74
+ slug: string;
75
+ excerpt: string;
76
+ };