@refrakt-md/content 0.35.0 → 0.36.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.
- package/dist/format.d.ts +22 -0
- package/dist/format.d.ts.map +1 -1
- package/dist/format.js +7 -20
- package/dist/format.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/loader.d.ts +15 -0
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.js +23 -1
- package/dist/loader.js.map +1 -1
- package/dist/refract-loader.d.ts +23 -0
- package/dist/refract-loader.d.ts.map +1 -1
- package/dist/refract-loader.js +81 -5
- package/dist/refract-loader.js.map +1 -1
- package/dist/site.d.ts +169 -1
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +250 -133
- package/dist/site.js.map +1 -1
- package/dist/validate-content.d.ts +83 -0
- package/dist/validate-content.d.ts.map +1 -0
- package/dist/validate-content.js +143 -0
- package/dist/validate-content.js.map +1 -0
- package/dist/validate.d.ts +32 -0
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +31 -10
- package/dist/validate.js.map +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The fast validation tier — SPEC-135 D3 / D14 / WORK-577.
|
|
3
|
+
*
|
|
4
|
+
* `loadContent` validates as a side effect of building a `Site`: it resolves
|
|
5
|
+
* routes and layouts, shells out to git for timestamps, runs the identity
|
|
6
|
+
* transform, and then runs three more cross-page phases over every page. A CLI
|
|
7
|
+
* that called it would be no faster than a build, which defeats the reason for
|
|
8
|
+
* having a CLI (D3).
|
|
9
|
+
*
|
|
10
|
+
* This runs the two steps validation actually needs — parse and validate —
|
|
11
|
+
* against a config built by the *same* function the build uses, so the two
|
|
12
|
+
* cannot disagree about which tags and attributes exist (D14).
|
|
13
|
+
*/
|
|
14
|
+
import { resolve } from 'node:path';
|
|
15
|
+
import Markdoc from '@markdoc/markdoc';
|
|
16
|
+
import { fsProjectFiles } from '@refrakt-md/types/project-files';
|
|
17
|
+
import { escapeFenceTags } from '@refrakt-md/runes';
|
|
18
|
+
import { ContentTree } from './content-tree.js';
|
|
19
|
+
import { parseFrontmatter } from './frontmatter.js';
|
|
20
|
+
import { Router } from './router.js';
|
|
21
|
+
import { buildPageContentVariables, buildPageTransformConfig, buildPreprocessHookSets, parsePagePartials, } from './site.js';
|
|
22
|
+
import { validatePageDetailed } from './validate.js';
|
|
23
|
+
/**
|
|
24
|
+
* Validate every page in a content tree, returning findings.
|
|
25
|
+
*
|
|
26
|
+
* Accepts a directory path or a pre-built {@link ContentTree}. Runs parse,
|
|
27
|
+
* preprocess and `Markdoc.validate`, and **nothing else**: no `resolveLayouts`,
|
|
28
|
+
* no `resolveTimestamps` (no git), no `Markdoc.transform`, no `runPipeline`.
|
|
29
|
+
*
|
|
30
|
+
* Two departures from WORK-577's acceptance criteria, both in service of the
|
|
31
|
+
* agreement the same item calls its real deliverable:
|
|
32
|
+
*
|
|
33
|
+
* - **It resolves routes.** The criteria say not to call `router.resolve`, to
|
|
34
|
+
* keep the tier fast. `Router.resolve` is pure string manipulation with no
|
|
35
|
+
* I/O (`router.ts:46`), so it costs nothing measurable — and without it every
|
|
36
|
+
* finding's `url` would differ from the build's, making the agreement
|
|
37
|
+
* approximate where it could be exact.
|
|
38
|
+
* - **It runs preprocess hooks.** The criteria do not mention them. They are
|
|
39
|
+
* not optional: `{% snippet %}` resolves itself into a fence node during
|
|
40
|
+
* preprocess and `{% include %}` pastes partial content in, so skipping them
|
|
41
|
+
* validates a different tree than the build does — precisely the divergence
|
|
42
|
+
* D5a exists to forbid.
|
|
43
|
+
*
|
|
44
|
+
* What stays skipped is where the cost actually is: git, layouts, the identity
|
|
45
|
+
* transform, and the three cross-page phases. Those are the `--deep` tier.
|
|
46
|
+
*/
|
|
47
|
+
export async function validateContent(source, options = {}) {
|
|
48
|
+
const tree = typeof source === 'string' ? await ContentTree.fromDirectory(source) : source;
|
|
49
|
+
const router = new Router(options.basePath ?? '/');
|
|
50
|
+
// Mirror `loadContent`'s defaults for the directory form. It derives a
|
|
51
|
+
// project root from the content directory's parent and roots a
|
|
52
|
+
// `fsProjectFiles` provider there; without the same defaults, snippet's
|
|
53
|
+
// preprocess cannot read files here while it can in a build, and the two
|
|
54
|
+
// paths report different findings for the same corpus.
|
|
55
|
+
//
|
|
56
|
+
// Found by running this function against refrakt's own 235-page site and
|
|
57
|
+
// diffing: 13 findings the build had and this did not, plus one it had and
|
|
58
|
+
// the build did not — all of them snippet tags that resolved in one path and
|
|
59
|
+
// not the other. Exactly the divergence D5a forbids, and invisible without
|
|
60
|
+
// the comparison.
|
|
61
|
+
const env = { ...options };
|
|
62
|
+
if (typeof source === 'string') {
|
|
63
|
+
const projectRoot = options.projectRoot ?? resolve(source, '..');
|
|
64
|
+
env.projectRoot = projectRoot;
|
|
65
|
+
env.sandbox = options.sandbox ?? fsProjectFiles(projectRoot);
|
|
66
|
+
}
|
|
67
|
+
const parsedPartials = await parsePagePartials(tree, env);
|
|
68
|
+
const hookSets = buildPreprocessHookSets(env, parsedPartials);
|
|
69
|
+
// D5a — settings come off the site config exactly as `loadContent` reads
|
|
70
|
+
// them (`site.ts`), and are handed to `validatePageDetailed`, which resolves
|
|
71
|
+
// them through `resolveValidationIds`. Not reimplemented here: the three-way
|
|
72
|
+
// refinement (demote / drop / always-report) has one implementation, and
|
|
73
|
+
// this path calls it.
|
|
74
|
+
const settings = options.validation ??
|
|
75
|
+
options.siteConfig?.validation;
|
|
76
|
+
const out = [];
|
|
77
|
+
for (const page of tree.pages()) {
|
|
78
|
+
const { frontmatter, content } = parseFrontmatter(page.raw);
|
|
79
|
+
const route = router.resolve(page.relativePath, frontmatter);
|
|
80
|
+
let ast = Markdoc.parse(escapeFenceTags(content));
|
|
81
|
+
// Computed before preprocess, exactly as the build does, so snippet can
|
|
82
|
+
// resolve `path=$file.path`-style references. `timestamps` is omitted —
|
|
83
|
+
// that is the git call the fast tier exists to skip, and nothing in
|
|
84
|
+
// preprocess reads `$file.created` / `$file.modified`.
|
|
85
|
+
const contentVariables = buildPageContentVariables({
|
|
86
|
+
ast,
|
|
87
|
+
frontmatter,
|
|
88
|
+
relativePath: page.relativePath,
|
|
89
|
+
filePath: page.filePath,
|
|
90
|
+
url: route.url,
|
|
91
|
+
draft: route.draft,
|
|
92
|
+
variables: options.variables,
|
|
93
|
+
projectRoot: env.projectRoot,
|
|
94
|
+
sandbox: env.sandbox,
|
|
95
|
+
sandboxExamplesDir: options.sandboxExamplesDir,
|
|
96
|
+
securityPolicy: options.securityPolicy,
|
|
97
|
+
siteConfig: options.siteConfig,
|
|
98
|
+
});
|
|
99
|
+
// Preprocess needs somewhere to put its own diagnostics. They are
|
|
100
|
+
// collected and discarded here: a preprocess warning is a pipeline
|
|
101
|
+
// finding, not a content-validation finding, and reporting it from this
|
|
102
|
+
// entry point would make the fast tier return findings a `validatePage`
|
|
103
|
+
// comparison could never match. The build still reports them.
|
|
104
|
+
const ppCtx = {
|
|
105
|
+
info() { },
|
|
106
|
+
warn() { },
|
|
107
|
+
error() { },
|
|
108
|
+
projectRoot: env.projectRoot,
|
|
109
|
+
sandbox: env.sandbox,
|
|
110
|
+
variables: contentVariables,
|
|
111
|
+
partials: parsedPartials ?? {},
|
|
112
|
+
};
|
|
113
|
+
for (const { hooks } of hookSets) {
|
|
114
|
+
if (!hooks.preprocess)
|
|
115
|
+
continue;
|
|
116
|
+
const next = await hooks.preprocess(ast, { url: route.url, relativePath: page.relativePath, filePath: page.filePath }, ppCtx);
|
|
117
|
+
if (next)
|
|
118
|
+
ast = next;
|
|
119
|
+
}
|
|
120
|
+
const { config } = buildPageTransformConfig({
|
|
121
|
+
ast,
|
|
122
|
+
content,
|
|
123
|
+
path: route.url,
|
|
124
|
+
sourcePath: page.relativePath,
|
|
125
|
+
icons: options.icons,
|
|
126
|
+
additionalTags: options.additionalTags,
|
|
127
|
+
contentVariables,
|
|
128
|
+
partials: parsedPartials,
|
|
129
|
+
});
|
|
130
|
+
for (const finding of validatePageDetailed(ast, config, { url: route.url, settings })) {
|
|
131
|
+
out.push({
|
|
132
|
+
file: page.relativePath,
|
|
133
|
+
url: route.url,
|
|
134
|
+
line: finding.line,
|
|
135
|
+
severity: finding.warning.severity,
|
|
136
|
+
id: finding.id,
|
|
137
|
+
message: finding.warning.message,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return out;
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=validate-content.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-content.js","sourceRoot":"","sources":["../src/validate-content.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,OAAO,MAAM,kBAAkB,CAAC;AAGvC,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EACN,yBAAyB,EACzB,wBAAwB,EACxB,uBAAuB,EACvB,iBAAiB,GAEjB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,oBAAoB,EAA2B,MAAM,eAAe,CAAC;AA4C9E;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACpC,MAA4B,EAC5B,UAAkC,EAAE;IAEpC,MAAM,IAAI,GAAG,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,WAAW,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;I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;QAED,MAAM,EAAE,MAAM,EAAE,GAAG,wBAAwB,CAAC;YAC3C,GAAG;YACH,OAAO;YACP,IAAI,EAAE,KAAK,CAAC,GAAG;YACf,UAAU,EAAE,IAAI,CAAC,YAAY;YAC7B,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,cAAc,EAAE,OAAO,CAAC,cAAc;YACtC,gBAAgB;YAChB,QAAQ,EAAE,cAAc;SACxB,CAAC,CAAC;QAEH,KAAK,MAAM,OAAO,IAAI,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;YACvF,GAAG,CAAC,IAAI,CAAC;gBACR,IAAI,EAAE,IAAI,CAAC,YAAY;gBACvB,GAAG,EAAE,KAAK,CAAC,GAAG;gBACd,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,QAAQ;gBAClC,EAAE,EAAE,OAAO,CAAC,EAAE;gBACd,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,OAAO;aAChC,CAAC,CAAC;QACJ,CAAC;IACF,CAAC;IAED,OAAO,GAAG,CAAC;AACZ,CAAC"}
|
package/dist/validate.d.ts
CHANGED
|
@@ -99,5 +99,37 @@ export interface ValidatePageOptions {
|
|
|
99
99
|
* value in an `info` stream of every check the project has decided against.
|
|
100
100
|
*/
|
|
101
101
|
export declare function validatePage(ast: Node, config: unknown, opts: ValidatePageOptions): PipelineWarning[];
|
|
102
|
+
/**
|
|
103
|
+
* A finding, plus the structured fields `PipelineWarning` has nowhere to put.
|
|
104
|
+
*
|
|
105
|
+
* `PipelineWarning` is the build's diagnostic shape: severity, phase, plugin,
|
|
106
|
+
* url, message. The Markdoc error id and source line are *formatted into* the
|
|
107
|
+
* message there, which is fine for a build summary a human reads and useless to
|
|
108
|
+
* a caller that wants to filter by id or open a file at a line — the CLI's
|
|
109
|
+
* `--format json` (WORK-578) and the MCP tool (WORK-581, SPEC-135 D6).
|
|
110
|
+
*
|
|
111
|
+
* Carried alongside rather than added to `PipelineWarning` so the build's
|
|
112
|
+
* diagnostic shape is unchanged and the two cannot drift: the warning here is
|
|
113
|
+
* the identical object `validatePage` returns.
|
|
114
|
+
*/
|
|
115
|
+
export interface DetailedFinding {
|
|
116
|
+
/** Exactly what `validatePage` reports for this finding. */
|
|
117
|
+
warning: PipelineWarning;
|
|
118
|
+
/** Markdoc error id, e.g. `tag-undefined`. Absent only when validation
|
|
119
|
+
* itself crashed and the finding is the fallback. */
|
|
120
|
+
id?: string;
|
|
121
|
+
/** 1-based source line, matching what the message renders. */
|
|
122
|
+
line?: number;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* {@link validatePage}, keeping the structured fields.
|
|
126
|
+
*
|
|
127
|
+
* This is where the dispositions actually live; `validatePage` is a projection
|
|
128
|
+
* of it. Single-sourced deliberately — SPEC-135 D5a requires that every caller
|
|
129
|
+
* resolve settings through `resolveValidationIds` rather than reimplementing
|
|
130
|
+
* the three-way refinement, and the cheapest way to guarantee that is for there
|
|
131
|
+
* to be exactly one implementation to call.
|
|
132
|
+
*/
|
|
133
|
+
export declare function validatePageDetailed(ast: Node, config: unknown, opts: ValidatePageOptions): DetailedFinding[];
|
|
102
134
|
export {};
|
|
103
135
|
//# sourceMappingURL=validate.d.ts.map
|
package/dist/validate.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAiB,MAAM,kBAAkB,CAAC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD;;;;;;;;;;;;GAYG;AAEH,4EAA4E;AAC5E,KAAK,YAAY,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,UAAU,CAAC;AAExE;;;;;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otedIds(settings) {
|
|
|
97
97
|
* value in an `info` stream of every check the project has decided against.
|
|
98
98
|
*/
|
|
99
99
|
export function validatePage(ast, config, opts) {
|
|
100
|
+
return validatePageDetailed(ast, config, opts).map((f) => f.warning);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* {@link validatePage}, keeping the structured fields.
|
|
104
|
+
*
|
|
105
|
+
* This is where the dispositions actually live; `validatePage` is a projection
|
|
106
|
+
* of it. Single-sourced deliberately — SPEC-135 D5a requires that every caller
|
|
107
|
+
* resolve settings through `resolveValidationIds` rather than reimplementing
|
|
108
|
+
* the three-way refinement, and the cheapest way to guarantee that is for there
|
|
109
|
+
* to be exactly one implementation to call.
|
|
110
|
+
*/
|
|
111
|
+
export function validatePageDetailed(ast, config, opts) {
|
|
100
112
|
const settings = opts.settings ?? DEFAULT_VALIDATION_SETTINGS;
|
|
101
113
|
const allowed = resolveValidationIds(settings);
|
|
102
114
|
const demoted = demotedIds(settings);
|
|
@@ -108,11 +120,13 @@ export function validatePage(ast, config, opts) {
|
|
|
108
120
|
catch (err) {
|
|
109
121
|
return [
|
|
110
122
|
{
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
123
|
+
warning: {
|
|
124
|
+
severity: 'warning',
|
|
125
|
+
phase: 'validate',
|
|
126
|
+
pluginName,
|
|
127
|
+
url: opts.url,
|
|
128
|
+
message: `content validation could not run: ${err.message}`,
|
|
129
|
+
},
|
|
116
130
|
},
|
|
117
131
|
];
|
|
118
132
|
}
|
|
@@ -133,12 +147,19 @@ export function validatePage(ast, config, opts) {
|
|
|
133
147
|
continue;
|
|
134
148
|
}
|
|
135
149
|
}
|
|
150
|
+
const rawLine = finding.lines?.[0];
|
|
136
151
|
out.push({
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
152
|
+
warning: {
|
|
153
|
+
severity,
|
|
154
|
+
phase: 'validate',
|
|
155
|
+
pluginName,
|
|
156
|
+
url: opts.url,
|
|
157
|
+
message: formatFinding(finding, opts.contributedBy),
|
|
158
|
+
},
|
|
159
|
+
id,
|
|
160
|
+
// `formatFinding` renders `line + 1`; match it so a caller and the
|
|
161
|
+
// message never disagree about which line is meant.
|
|
162
|
+
line: typeof rawLine === 'number' ? rawLine + 1 : undefined,
|
|
142
163
|
});
|
|
143
164
|
}
|
|
144
165
|
return out;
|
package/dist/validate.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,kBAAkB,CAAC;AAqBvC;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAsB;IACxD,2EAA2E;IAC3E,0EAA0E;IAC1E,yCAAyC;IACzC,eAAe;IACf,qBAAqB;IACrB,0EAA0E;IAC1E,0EAA0E;IAC1E,oEAAoE;IACpE,2EAA2E;IAC3E,wEAAwE;IACxE,uCAAuC;IACvC,yBAAyB;IACzB,4BAA4B;IAC5B,wBAAwB;CACxB,CAAC;AAEF;;;;oEAIoE;AACpE,SAAS,WAAW,CAAC,KAAmB;IACvC,QAAQ,KAAK,EAAE,CAAC;QACf,KAAK,UAAU,CAAC;QAChB,KAAK,OAAO;YACX,OAAO,OAAO,CAAC;QAChB,KAAK,SAAS;YACb,OAAO,SAAS,CAAC;QAClB;YACC,OAAO,MAAM,CAAC;IAChB,CAAC;AACF,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,cAAc,CAAC,KAAmB;IACjD,OAAO,KAAK,KAAK,UAAU,CAAC;AAC7B,CAAC;AAoBD,MAAM,CAAC,MAAM,2BAA2B,GAAuB,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAEjF,sDAAsD;AACtD,MAAM,UAAU,oBAAoB,CAAC,QAA6B;IACjE,MAAM,IAAI,GAAG,QAAQ,EAAE,GAAG,IAAI,sBAAsB,CAA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iBAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;gBAC7B,SAAS;YACV,CAAC;QACF,CAAC;QAED,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;QACnC,GAAG,CAAC,IAAI,CAAC;YACR,OAAO,EAAE;gBACR,QAAQ;gBACR,KAAK,EAAE,UAAU;gBACjB,UAAU;gBACV,GAAG,EAAE,IAAI,CAAC,GAAG;gBACb,OAAO,EAAE,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC;aACnD;YACD,EAAE;YACF,mEAAmE;YACnE,oDAAoD;YACpD,IAAI,EAAE,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS;SAC3D,CAAC,CAAC;IACJ,CAAC;IACD,OAAO,GAAG,CAAC;AACZ,CAAC;AAED;yCACyC;AACzC,SAAS,aAAa,CAAC,OAAsB,EAAE,aAAsB;IACpE,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;IAChC,MAAM,EAAE,GAAG,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IACjE,MAAM,MAAM,GAAG,aAAa,CAAC,CAAC,CAAC,kBAAkB,aAAa,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IACvE,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,EAAE,KAAK,OAAO,CAAC,KAAK,CAAC,OAAO,GAAG,EAAE,GAAG,MAAM,EAAE,CAAC;AACtE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@refrakt-md/content",
|
|
3
3
|
"description": "Content loading and transformation pipeline",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.36.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
"build": "tsc"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@refrakt-md/highlight": "0.
|
|
34
|
-
"@refrakt-md/runes": "0.
|
|
35
|
-
"@refrakt-md/transform": "0.
|
|
36
|
-
"@refrakt-md/types": "0.
|
|
33
|
+
"@refrakt-md/highlight": "0.36.0",
|
|
34
|
+
"@refrakt-md/runes": "0.36.0",
|
|
35
|
+
"@refrakt-md/transform": "0.36.0",
|
|
36
|
+
"@refrakt-md/types": "0.36.0",
|
|
37
37
|
"@markdoc/markdoc": "0.4.0",
|
|
38
38
|
"yaml": "^2.4.0"
|
|
39
39
|
}
|