@jxsuite/parser 0.27.0 → 0.28.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/content.js +53 -1
- package/dist/csv.js +189 -0
- package/dist/markdown.js +44815 -0
- package/dist/serialize.js +30786 -0
- package/package.json +14 -7
- package/src/Csv.class.json +171 -0
- package/src/Markdown.class.json +272 -0
- package/src/content.ts +17 -4
- package/src/csv.ts +209 -0
- package/src/markdown.ts +112 -0
- package/src/md.ts +6 -49
- package/src/serialize.ts +1482 -0
- package/src/MarkdownFile.class.json +0 -94
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jxsuite/parser",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.2",
|
|
4
4
|
"description": "Jx markdown parser and external class integration",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -16,10 +16,14 @@
|
|
|
16
16
|
"exports": {
|
|
17
17
|
".": "./src/md.ts",
|
|
18
18
|
"./content": "./src/content.ts",
|
|
19
|
+
"./markdown": "./src/markdown.ts",
|
|
20
|
+
"./csv": "./src/csv.ts",
|
|
21
|
+
"./serialize": "./src/serialize.ts",
|
|
19
22
|
"./ContentCollection.class.json": "./src/ContentCollection.class.json",
|
|
20
23
|
"./ContentEntry.class.json": "./src/ContentEntry.class.json",
|
|
21
24
|
"./MarkdownCollection.class.json": "./src/MarkdownCollection.class.json",
|
|
22
|
-
"./
|
|
25
|
+
"./Markdown.class.json": "./src/Markdown.class.json",
|
|
26
|
+
"./Csv.class.json": "./src/Csv.class.json",
|
|
23
27
|
"./transpile": "./src/transpile.ts",
|
|
24
28
|
"./html-to-jx": "./src/html-to-jx.ts",
|
|
25
29
|
"./types": "./src/types.ts"
|
|
@@ -28,14 +32,14 @@
|
|
|
28
32
|
"provenance": true
|
|
29
33
|
},
|
|
30
34
|
"scripts": {
|
|
31
|
-
"prepare": "bun build src/content.ts --outdir=dist --format=esm --target=node",
|
|
35
|
+
"prepare": "bun build src/content.ts src/markdown.ts src/csv.ts src/serialize.ts --outdir=dist --format=esm --target=node",
|
|
32
36
|
"build": "bun run prepare",
|
|
33
37
|
"test": "bun test --isolate",
|
|
34
38
|
"test:coverage": "bun test --isolate --coverage",
|
|
35
39
|
"upgrade": "bunx npm-check-updates -u && bun install"
|
|
36
40
|
},
|
|
37
41
|
"dependencies": {
|
|
38
|
-
"@jxsuite/schema": "^0.
|
|
42
|
+
"@jxsuite/schema": "^0.28.2",
|
|
39
43
|
"glob": "^13.0.6",
|
|
40
44
|
"hast-util-from-html": "^2.0.3",
|
|
41
45
|
"hast-util-whitespace": "^3.0.0",
|
|
@@ -48,12 +52,15 @@
|
|
|
48
52
|
"remark-parse": "^11.0.0",
|
|
49
53
|
"remark-parse-frontmatter": "^1.0.3",
|
|
50
54
|
"remark-rehype": "^11.1.2",
|
|
55
|
+
"remark-stringify": "^11.0.0",
|
|
51
56
|
"unified": "^11.0.5",
|
|
52
|
-
"unist-util-visit": "^5.1.0"
|
|
57
|
+
"unist-util-visit": "^5.1.0",
|
|
58
|
+
"yaml": "^2.9.0"
|
|
53
59
|
},
|
|
54
60
|
"devDependencies": {
|
|
55
61
|
"@happy-dom/global-registrator": "^20.10.2",
|
|
56
|
-
"@jxsuite/runtime": "^0.
|
|
57
|
-
"@types/hast": "^3.0.4"
|
|
62
|
+
"@jxsuite/runtime": "^0.28.2",
|
|
63
|
+
"@types/hast": "^3.0.4",
|
|
64
|
+
"@types/mdast": "^4.0.4"
|
|
58
65
|
}
|
|
59
66
|
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://jxsuite.com/schemas/Csv.class.json",
|
|
4
|
+
"title": "Csv",
|
|
5
|
+
"description": "CSV content format for Jx: parse CSV files or remote CSV URLs into typed content entries",
|
|
6
|
+
"$prototype": "Class",
|
|
7
|
+
"extends": "Object",
|
|
8
|
+
"$implementation": "./csv.js",
|
|
9
|
+
|
|
10
|
+
"format": {
|
|
11
|
+
"extensions": [".csv"],
|
|
12
|
+
"mediaType": "text/csv",
|
|
13
|
+
"documentKinds": ["content"],
|
|
14
|
+
"exportTarget": false,
|
|
15
|
+
"remote": true
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
"$studio": {
|
|
19
|
+
"icon": "table",
|
|
20
|
+
"modes": ["source"]
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
"$defs": {
|
|
24
|
+
"parameters": {
|
|
25
|
+
"src": {
|
|
26
|
+
"identifier": "src",
|
|
27
|
+
"type": { "type": "string" },
|
|
28
|
+
"description": "Path or http(s) URL to a CSV file",
|
|
29
|
+
"examples": ["./content/products.csv", "https://example.com/sheet.csv"]
|
|
30
|
+
},
|
|
31
|
+
"schema": {
|
|
32
|
+
"identifier": "schema",
|
|
33
|
+
"type": { "type": "object" },
|
|
34
|
+
"format": "json-schema",
|
|
35
|
+
"description": "Per-column type schema for coercion (number, boolean, array)"
|
|
36
|
+
},
|
|
37
|
+
"idField": {
|
|
38
|
+
"identifier": "idField",
|
|
39
|
+
"type": { "type": "string" },
|
|
40
|
+
"description": "Column used as entry id (default chain: id, sku, slug, Slug, row index)"
|
|
41
|
+
},
|
|
42
|
+
"basePath": {
|
|
43
|
+
"identifier": "basePath",
|
|
44
|
+
"type": { "type": "string" },
|
|
45
|
+
"description": "Base path for resolving src"
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
"returnTypes": {
|
|
50
|
+
"ContentLoaderEntries": {
|
|
51
|
+
"type": "array",
|
|
52
|
+
"description": "Content entries: { id, data, body }"
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
"fields": {
|
|
57
|
+
"config": {
|
|
58
|
+
"role": "field",
|
|
59
|
+
"access": "private",
|
|
60
|
+
"scope": "instance",
|
|
61
|
+
"identifier": "config",
|
|
62
|
+
"type": { "type": "object" },
|
|
63
|
+
"description": "Raw configuration object passed to the constructor"
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
"constructor": {
|
|
68
|
+
"role": "constructor",
|
|
69
|
+
"$prototype": "Function",
|
|
70
|
+
"parameters": [
|
|
71
|
+
{ "$ref": "#/$defs/parameters/src" },
|
|
72
|
+
{ "$ref": "#/$defs/parameters/schema" },
|
|
73
|
+
{ "$ref": "#/$defs/parameters/idField" },
|
|
74
|
+
{ "$ref": "#/$defs/parameters/basePath" }
|
|
75
|
+
],
|
|
76
|
+
"body": ["this.config = config;"],
|
|
77
|
+
"description": "Stores the configuration for deferred resolution"
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
"methods": {
|
|
81
|
+
"resolve": {
|
|
82
|
+
"role": "method",
|
|
83
|
+
"$prototype": "Function",
|
|
84
|
+
"access": "public",
|
|
85
|
+
"scope": "instance",
|
|
86
|
+
"identifier": "resolve",
|
|
87
|
+
"parameters": [],
|
|
88
|
+
"returnType": { "$ref": "#/$defs/returnTypes/ContentLoaderEntries" },
|
|
89
|
+
"description": "Load and coerce the configured CSV source (runtime on-demand access)"
|
|
90
|
+
},
|
|
91
|
+
"parse": {
|
|
92
|
+
"role": "parse",
|
|
93
|
+
"$prototype": "Function",
|
|
94
|
+
"access": "public",
|
|
95
|
+
"scope": "static",
|
|
96
|
+
"identifier": "parse",
|
|
97
|
+
"timing": ["compiler", "server", "client"],
|
|
98
|
+
"parameters": [
|
|
99
|
+
{
|
|
100
|
+
"identifier": "source",
|
|
101
|
+
"type": { "type": "string" },
|
|
102
|
+
"description": "Raw CSV text"
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"identifier": "options",
|
|
106
|
+
"type": {
|
|
107
|
+
"type": "object",
|
|
108
|
+
"properties": {
|
|
109
|
+
"schema": { "type": "object" },
|
|
110
|
+
"idField": { "type": "string" }
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
],
|
|
115
|
+
"returnType": { "$ref": "#/$defs/returnTypes/ContentLoaderEntries" },
|
|
116
|
+
"description": "Parse CSV text into typed content entries (pure, browser-safe)"
|
|
117
|
+
},
|
|
118
|
+
"discover": {
|
|
119
|
+
"role": "discover",
|
|
120
|
+
"$prototype": "Function",
|
|
121
|
+
"access": "public",
|
|
122
|
+
"scope": "static",
|
|
123
|
+
"identifier": "discover",
|
|
124
|
+
"timing": ["compiler", "server"],
|
|
125
|
+
"parameters": [
|
|
126
|
+
{
|
|
127
|
+
"identifier": "source",
|
|
128
|
+
"type": { "type": "string" },
|
|
129
|
+
"description": "Content-type source: file path or directory"
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"identifier": "options",
|
|
133
|
+
"type": {
|
|
134
|
+
"type": "object",
|
|
135
|
+
"properties": { "baseDir": { "type": "string" } }
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
],
|
|
139
|
+
"returnType": { "type": "array", "items": { "type": "string" } },
|
|
140
|
+
"description": "List CSV entry files for a content-type source"
|
|
141
|
+
},
|
|
142
|
+
"load": {
|
|
143
|
+
"role": "load",
|
|
144
|
+
"$prototype": "Function",
|
|
145
|
+
"access": "public",
|
|
146
|
+
"scope": "static",
|
|
147
|
+
"identifier": "load",
|
|
148
|
+
"timing": ["compiler", "server"],
|
|
149
|
+
"parameters": [
|
|
150
|
+
{
|
|
151
|
+
"identifier": "path",
|
|
152
|
+
"type": { "type": "string" },
|
|
153
|
+
"description": "File path or http(s) URL"
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"identifier": "options",
|
|
157
|
+
"type": {
|
|
158
|
+
"type": "object",
|
|
159
|
+
"properties": {
|
|
160
|
+
"schema": { "type": "object" },
|
|
161
|
+
"idField": { "type": "string" }
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
],
|
|
166
|
+
"returnType": { "$ref": "#/$defs/returnTypes/ContentLoaderEntries" },
|
|
167
|
+
"description": "Read or fetch one CSV source and parse it into content entries"
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://jxsuite.com/schemas/Markdown.class.json",
|
|
4
|
+
"title": "Markdown",
|
|
5
|
+
"description": "Markdown format for Jx: parse/serialize Jx Markdown documents, load markdown content entries, and resolve markdown files at runtime",
|
|
6
|
+
"$prototype": "Class",
|
|
7
|
+
"extends": "Object",
|
|
8
|
+
"$implementation": "./markdown.js",
|
|
9
|
+
|
|
10
|
+
"format": {
|
|
11
|
+
"extensions": [".md"],
|
|
12
|
+
"mediaType": "text/markdown",
|
|
13
|
+
"documentKinds": ["page", "component", "content"],
|
|
14
|
+
"exportTarget": true,
|
|
15
|
+
"remote": false
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
"$studio": {
|
|
19
|
+
"icon": "markdown",
|
|
20
|
+
"modes": ["design", "preview", "source"],
|
|
21
|
+
"documentMode": {
|
|
22
|
+
"default": "content",
|
|
23
|
+
"componentWhen": { "frontmatterKey": "tagName", "matches": ".+-.+" }
|
|
24
|
+
},
|
|
25
|
+
"newFileTemplate": "---\ntitle: Untitled\n---\n\n",
|
|
26
|
+
"elements": {
|
|
27
|
+
"block": [
|
|
28
|
+
"h1",
|
|
29
|
+
"h2",
|
|
30
|
+
"h3",
|
|
31
|
+
"h4",
|
|
32
|
+
"h5",
|
|
33
|
+
"h6",
|
|
34
|
+
"p",
|
|
35
|
+
"blockquote",
|
|
36
|
+
"ul",
|
|
37
|
+
"ol",
|
|
38
|
+
"li",
|
|
39
|
+
"pre",
|
|
40
|
+
"hr",
|
|
41
|
+
"table",
|
|
42
|
+
"thead",
|
|
43
|
+
"tbody",
|
|
44
|
+
"tr",
|
|
45
|
+
"th",
|
|
46
|
+
"td"
|
|
47
|
+
],
|
|
48
|
+
"inline": ["em", "strong", "del", "code", "a", "img", "br"],
|
|
49
|
+
"void": ["hr", "br", "img"],
|
|
50
|
+
"textOnly": ["code"],
|
|
51
|
+
"nesting": {
|
|
52
|
+
"_root": { "block": true, "inline": false, "directive": true },
|
|
53
|
+
"h1": { "block": false, "inline": true, "directive": false },
|
|
54
|
+
"h2": { "block": false, "inline": true, "directive": false },
|
|
55
|
+
"h3": { "block": false, "inline": true, "directive": false },
|
|
56
|
+
"h4": { "block": false, "inline": true, "directive": false },
|
|
57
|
+
"h5": { "block": false, "inline": true, "directive": false },
|
|
58
|
+
"h6": { "block": false, "inline": true, "directive": false },
|
|
59
|
+
"p": { "block": false, "inline": true, "directive": true },
|
|
60
|
+
"blockquote": { "block": true, "inline": false, "directive": true },
|
|
61
|
+
"ul": { "only": ["li"] },
|
|
62
|
+
"ol": { "only": ["li"] },
|
|
63
|
+
"li": { "block": true, "inline": true, "directive": true },
|
|
64
|
+
"pre": { "only": ["code"] },
|
|
65
|
+
"table": { "only": ["thead", "tbody"] },
|
|
66
|
+
"thead": { "only": ["tr"] },
|
|
67
|
+
"tbody": { "only": ["tr"] },
|
|
68
|
+
"tr": { "only": ["th", "td"] },
|
|
69
|
+
"th": { "block": false, "inline": true, "directive": false },
|
|
70
|
+
"td": { "block": false, "inline": true, "directive": false },
|
|
71
|
+
"em": { "block": false, "inline": true, "directive": false },
|
|
72
|
+
"strong": { "block": false, "inline": true, "directive": false },
|
|
73
|
+
"del": { "block": false, "inline": true, "directive": false },
|
|
74
|
+
"a": { "block": false, "inline": true, "directive": false }
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
"$defs": {
|
|
80
|
+
"parameters": {
|
|
81
|
+
"src": {
|
|
82
|
+
"identifier": "src",
|
|
83
|
+
"type": { "type": "string" },
|
|
84
|
+
"description": "Path to markdown file",
|
|
85
|
+
"examples": ["./content/about.md"]
|
|
86
|
+
},
|
|
87
|
+
"directives": {
|
|
88
|
+
"identifier": "directives",
|
|
89
|
+
"type": { "type": "boolean", "default": false },
|
|
90
|
+
"description": "Enable remark-directive plugin"
|
|
91
|
+
},
|
|
92
|
+
"basePath": {
|
|
93
|
+
"identifier": "basePath",
|
|
94
|
+
"type": { "type": "string" },
|
|
95
|
+
"description": "Base path for resolving src"
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
"returnTypes": {
|
|
100
|
+
"JxDocument": {
|
|
101
|
+
"type": "object",
|
|
102
|
+
"description": "Jx JSON document: frontmatter keys at top level, body as children"
|
|
103
|
+
},
|
|
104
|
+
"MarkdownFileResult": {
|
|
105
|
+
"type": "object",
|
|
106
|
+
"description": "Parsed markdown file result",
|
|
107
|
+
"properties": {
|
|
108
|
+
"slug": { "type": "string", "description": "Filename without extension" },
|
|
109
|
+
"path": { "type": "string", "description": "Absolute file path" },
|
|
110
|
+
"frontmatter": { "type": "object", "description": "YAML frontmatter key-value pairs" },
|
|
111
|
+
"$children": { "type": "array", "description": "JX node tree" },
|
|
112
|
+
"$excerpt": { "type": "string", "description": "First paragraph as plain text" },
|
|
113
|
+
"$toc": {
|
|
114
|
+
"type": "array",
|
|
115
|
+
"description": "Table of contents entries",
|
|
116
|
+
"items": {
|
|
117
|
+
"type": "object",
|
|
118
|
+
"properties": {
|
|
119
|
+
"depth": { "type": "integer" },
|
|
120
|
+
"text": { "type": "string" },
|
|
121
|
+
"id": { "type": "string" }
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
"$readingTime": { "type": "integer", "description": "Estimated reading time in minutes" },
|
|
126
|
+
"$wordCount": { "type": "integer", "description": "Total word count" }
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
"ContentLoaderEntries": {
|
|
130
|
+
"type": "array",
|
|
131
|
+
"description": "Content entries: { id, data, body, $children, _meta }"
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
|
|
135
|
+
"fields": {
|
|
136
|
+
"config": {
|
|
137
|
+
"role": "field",
|
|
138
|
+
"access": "private",
|
|
139
|
+
"scope": "instance",
|
|
140
|
+
"identifier": "config",
|
|
141
|
+
"type": { "type": "object" },
|
|
142
|
+
"description": "Raw configuration object passed to the constructor"
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
|
|
146
|
+
"constructor": {
|
|
147
|
+
"role": "constructor",
|
|
148
|
+
"$prototype": "Function",
|
|
149
|
+
"parameters": [
|
|
150
|
+
{ "$ref": "#/$defs/parameters/src" },
|
|
151
|
+
{ "$ref": "#/$defs/parameters/directives" },
|
|
152
|
+
{ "$ref": "#/$defs/parameters/basePath" }
|
|
153
|
+
],
|
|
154
|
+
"body": ["this.config = config;"],
|
|
155
|
+
"description": "Stores the configuration for deferred resolution"
|
|
156
|
+
},
|
|
157
|
+
|
|
158
|
+
"methods": {
|
|
159
|
+
"resolve": {
|
|
160
|
+
"role": "method",
|
|
161
|
+
"$prototype": "Function",
|
|
162
|
+
"access": "public",
|
|
163
|
+
"scope": "instance",
|
|
164
|
+
"identifier": "resolve",
|
|
165
|
+
"parameters": [],
|
|
166
|
+
"returnType": { "$ref": "#/$defs/returnTypes/MarkdownFileResult" },
|
|
167
|
+
"description": "Parse and resolve the configured markdown file (runtime on-demand access)"
|
|
168
|
+
},
|
|
169
|
+
"parse": {
|
|
170
|
+
"role": "parse",
|
|
171
|
+
"$prototype": "Function",
|
|
172
|
+
"access": "public",
|
|
173
|
+
"scope": "static",
|
|
174
|
+
"identifier": "parse",
|
|
175
|
+
"timing": ["compiler", "server", "client"],
|
|
176
|
+
"parameters": [
|
|
177
|
+
{
|
|
178
|
+
"identifier": "source",
|
|
179
|
+
"type": { "type": "string" },
|
|
180
|
+
"description": "Raw markdown source"
|
|
181
|
+
}
|
|
182
|
+
],
|
|
183
|
+
"returnType": { "$ref": "#/$defs/returnTypes/JxDocument" },
|
|
184
|
+
"description": "Transpile Jx Markdown source into a Jx JSON document"
|
|
185
|
+
},
|
|
186
|
+
"serialize": {
|
|
187
|
+
"role": "serialize",
|
|
188
|
+
"$prototype": "Function",
|
|
189
|
+
"access": "public",
|
|
190
|
+
"scope": "static",
|
|
191
|
+
"identifier": "serialize",
|
|
192
|
+
"timing": ["compiler", "server", "client"],
|
|
193
|
+
"parameters": [
|
|
194
|
+
{
|
|
195
|
+
"identifier": "doc",
|
|
196
|
+
"type": { "type": "object" },
|
|
197
|
+
"description": "Jx JSON document"
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
"identifier": "options",
|
|
201
|
+
"type": {
|
|
202
|
+
"type": "object",
|
|
203
|
+
"properties": {
|
|
204
|
+
"mode": {
|
|
205
|
+
"type": "string",
|
|
206
|
+
"enum": ["roundtrip", "export"],
|
|
207
|
+
"default": "roundtrip",
|
|
208
|
+
"description": "roundtrip: lossless with frontmatter and directives; export: clean GFM"
|
|
209
|
+
},
|
|
210
|
+
"frontmatter": { "type": "boolean", "default": true }
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
"description": "Serialization options"
|
|
214
|
+
}
|
|
215
|
+
],
|
|
216
|
+
"returnType": { "type": "string" },
|
|
217
|
+
"description": "Serialize a Jx document to markdown source"
|
|
218
|
+
},
|
|
219
|
+
"discover": {
|
|
220
|
+
"role": "discover",
|
|
221
|
+
"$prototype": "Function",
|
|
222
|
+
"access": "public",
|
|
223
|
+
"scope": "static",
|
|
224
|
+
"identifier": "discover",
|
|
225
|
+
"timing": ["compiler", "server"],
|
|
226
|
+
"parameters": [
|
|
227
|
+
{
|
|
228
|
+
"identifier": "source",
|
|
229
|
+
"type": { "type": "string" },
|
|
230
|
+
"description": "Content-type source: file path or directory"
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
"identifier": "options",
|
|
234
|
+
"type": {
|
|
235
|
+
"type": "object",
|
|
236
|
+
"properties": { "baseDir": { "type": "string" } }
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
],
|
|
240
|
+
"returnType": { "type": "array", "items": { "type": "string" } },
|
|
241
|
+
"description": "List markdown entry files for a content-type source"
|
|
242
|
+
},
|
|
243
|
+
"load": {
|
|
244
|
+
"role": "load",
|
|
245
|
+
"$prototype": "Function",
|
|
246
|
+
"access": "public",
|
|
247
|
+
"scope": "static",
|
|
248
|
+
"identifier": "load",
|
|
249
|
+
"timing": ["compiler", "server"],
|
|
250
|
+
"parameters": [
|
|
251
|
+
{
|
|
252
|
+
"identifier": "path",
|
|
253
|
+
"type": { "type": "string" },
|
|
254
|
+
"description": "Absolute path to a markdown file"
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
"identifier": "options",
|
|
258
|
+
"type": {
|
|
259
|
+
"type": "object",
|
|
260
|
+
"properties": {
|
|
261
|
+
"directiveOptions": { "type": "object" },
|
|
262
|
+
"directives": { "type": "boolean" }
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
],
|
|
267
|
+
"returnType": { "$ref": "#/$defs/returnTypes/ContentLoaderEntries" },
|
|
268
|
+
"description": "Load one markdown file into content entries (frontmatter as data, body preserved)"
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
package/src/content.ts
CHANGED
|
@@ -13,7 +13,10 @@ interface CollectionConfig {
|
|
|
13
13
|
filter?: unknown;
|
|
14
14
|
sort?: unknown;
|
|
15
15
|
limit?: number;
|
|
16
|
-
_project?: {
|
|
16
|
+
_project?: {
|
|
17
|
+
contentTypes?: Map<string, ContentLoaderEntry[]>;
|
|
18
|
+
[k: string]: unknown;
|
|
19
|
+
};
|
|
17
20
|
[k: string]: unknown;
|
|
18
21
|
}
|
|
19
22
|
|
|
@@ -21,8 +24,14 @@ interface EntryConfig {
|
|
|
21
24
|
contentType?: string;
|
|
22
25
|
id?: unknown;
|
|
23
26
|
field?: string;
|
|
24
|
-
_project?: {
|
|
25
|
-
|
|
27
|
+
_project?: {
|
|
28
|
+
contentTypes?: Map<string, ContentLoaderEntry[]>;
|
|
29
|
+
[k: string]: unknown;
|
|
30
|
+
};
|
|
31
|
+
_document?: {
|
|
32
|
+
route?: { _pathParams?: Record<string, string> };
|
|
33
|
+
[k: string]: unknown;
|
|
34
|
+
};
|
|
26
35
|
[k: string]: unknown;
|
|
27
36
|
}
|
|
28
37
|
|
|
@@ -93,7 +102,11 @@ export function queryContentType(
|
|
|
93
102
|
if (Array.isArray(query.filter)) {
|
|
94
103
|
rules = query.filter;
|
|
95
104
|
} else if (typeof query.filter === "object") {
|
|
96
|
-
rules = Object.entries(query.filter).map(([field, value]) => ({
|
|
105
|
+
rules = Object.entries(query.filter).map(([field, value]) => ({
|
|
106
|
+
field,
|
|
107
|
+
op: "==",
|
|
108
|
+
value,
|
|
109
|
+
}));
|
|
97
110
|
} else {
|
|
98
111
|
rules = [];
|
|
99
112
|
}
|