@nicodoggie/mdx-language-server 0.6.3 → 0.6.5
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/lib/frontmatter-schemas.js +28 -1
- package/package.json +2 -2
|
@@ -33,6 +33,31 @@ function isRecord(value) {
|
|
|
33
33
|
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
/**
|
|
37
|
+
* Some clients return the requested `mdx.frontmatter` section directly, while
|
|
38
|
+
* others return the full workspace settings object.
|
|
39
|
+
*
|
|
40
|
+
* @param {unknown} value
|
|
41
|
+
* @returns {Record<string, unknown>}
|
|
42
|
+
*/
|
|
43
|
+
export function normalizeFrontmatterConfig(value) {
|
|
44
|
+
if (!isRecord(value)) {
|
|
45
|
+
return {}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if ('schemas' in value) {
|
|
49
|
+
return value
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const mdx = value.mdx
|
|
53
|
+
if (!isRecord(mdx)) {
|
|
54
|
+
return value
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const frontmatter = mdx.frontmatter
|
|
58
|
+
return isRecord(frontmatter) ? frontmatter : value
|
|
59
|
+
}
|
|
60
|
+
|
|
36
61
|
/**
|
|
37
62
|
* @param {unknown} value
|
|
38
63
|
* @returns {string[]}
|
|
@@ -170,7 +195,9 @@ export async function getFrontmatterYamlSettings(
|
|
|
170
195
|
fallbackWorkspaceFolder
|
|
171
196
|
) {
|
|
172
197
|
const frontmatterConfig =
|
|
173
|
-
(
|
|
198
|
+
normalizeFrontmatterConfig(
|
|
199
|
+
await context.env.getConfiguration?.('mdx.frontmatter')
|
|
200
|
+
)
|
|
174
201
|
const workspaceFolder =
|
|
175
202
|
fallbackWorkspaceFolder ?? context.env.workspaceFolders?.[0]
|
|
176
203
|
const workspaceUri =
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nicodoggie/mdx-language-server",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A language server for MDX",
|
|
6
6
|
"repository": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"test": "npm run test-api"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@mdx-js/language-service": "0.7.3",
|
|
34
|
+
"@mdx-js/language-service": "npm:@nicodoggie/mdx-language-service@0.7.3",
|
|
35
35
|
"@volar/language-server": "~2.4.0",
|
|
36
36
|
"remark-frontmatter": "^5.0.0",
|
|
37
37
|
"remark-gfm": "^4.0.0",
|