@ox-content/vite-plugin 2.30.0 → 2.31.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/index.cjs +379 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +222 -3
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +222 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +376 -11
- package/dist/index.mjs.map +1 -1
- package/dist/media.cjs +29 -0
- package/dist/media.cjs.map +1 -0
- package/dist/media.mjs +2 -0
- package/dist/media2.mjs +22 -0
- package/dist/media2.mjs.map +1 -0
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -5,6 +5,7 @@ const require_mermaid = require("./mermaid.cjs");
|
|
|
5
5
|
const require_tabs = require("./tabs.cjs");
|
|
6
6
|
require("./pm.cjs");
|
|
7
7
|
const require_youtube = require("./youtube.cjs");
|
|
8
|
+
require("./media.cjs");
|
|
8
9
|
const require_github = require("./github.cjs");
|
|
9
10
|
const require_ogp = require("./ogp.cjs");
|
|
10
11
|
const require_vitepress = require("./vitepress.cjs");
|
|
@@ -19,6 +20,11 @@ let shiki = require("shiki");
|
|
|
19
20
|
let node_module = require("node:module");
|
|
20
21
|
let node_path = require("node:path");
|
|
21
22
|
node_path = require_chunk.__toESM(node_path, 1);
|
|
23
|
+
let node_fs_promises = require("node:fs/promises");
|
|
24
|
+
node_fs_promises = require_chunk.__toESM(node_fs_promises, 1);
|
|
25
|
+
let node_os = require("node:os");
|
|
26
|
+
let node_util = require("node:util");
|
|
27
|
+
let node_child_process = require("node:child_process");
|
|
22
28
|
let fs_promises = require("fs/promises");
|
|
23
29
|
fs_promises = require_chunk.__toESM(fs_promises, 1);
|
|
24
30
|
let crypto = require("crypto");
|
|
@@ -26,8 +32,6 @@ crypto = require_chunk.__toESM(crypto, 1);
|
|
|
26
32
|
let fs = require("fs");
|
|
27
33
|
fs = require_chunk.__toESM(fs, 1);
|
|
28
34
|
let glob = require("glob");
|
|
29
|
-
let node_fs_promises = require("node:fs/promises");
|
|
30
|
-
node_fs_promises = require_chunk.__toESM(node_fs_promises, 1);
|
|
31
35
|
//#region src/markdown.ts
|
|
32
36
|
const DEFAULT_MARKDOWN_EXTENSIONS = [
|
|
33
37
|
".md",
|
|
@@ -281,14 +285,14 @@ async function highlightCode(html, theme = "github-dark", langs = []) {
|
|
|
281
285
|
* Transform all enabled plugins in HTML content.
|
|
282
286
|
*/
|
|
283
287
|
async function transformAllPlugins(html, options = {}) {
|
|
284
|
-
const { tabs = true, pm =
|
|
288
|
+
const { tabs = true, pm = false, youtube = true, github = true, ogp, openGraph, mermaid = true, githubToken, spotify = false, stackBlitz = false, twitter = false, bluesky = false, webContainer = false } = options;
|
|
285
289
|
let result = html;
|
|
286
290
|
const ogpOptions = openGraph ?? ogp ?? true;
|
|
287
291
|
if (tabs) {
|
|
288
292
|
const { transformTabs } = await Promise.resolve().then(() => require("./tabs.cjs")).then((n) => n.tabs_exports);
|
|
289
293
|
result = await transformTabs(result);
|
|
290
294
|
}
|
|
291
|
-
if (pm
|
|
295
|
+
if (pm) {
|
|
292
296
|
const { transformPm } = await Promise.resolve().then(() => require("./pm.cjs")).then((n) => n.pm_exports);
|
|
293
297
|
result = await transformPm(result, typeof pm === "object" ? pm : {});
|
|
294
298
|
}
|
|
@@ -307,6 +311,17 @@ async function transformAllPlugins(html, options = {}) {
|
|
|
307
311
|
const { transformOgp } = await Promise.resolve().then(() => require("./ogp.cjs")).then((n) => n.ogp_exports);
|
|
308
312
|
result = await transformOgp(result, void 0, typeof ogpOptions === "object" ? ogpOptions : {});
|
|
309
313
|
}
|
|
314
|
+
const mediaOptions = {
|
|
315
|
+
spotify,
|
|
316
|
+
stackBlitz,
|
|
317
|
+
twitter,
|
|
318
|
+
bluesky,
|
|
319
|
+
webContainer
|
|
320
|
+
};
|
|
321
|
+
if (Object.values(mediaOptions).some(Boolean)) {
|
|
322
|
+
const { transformMediaEmbeds } = await Promise.resolve().then(() => require("./media.cjs")).then((n) => n.media_exports);
|
|
323
|
+
result = await transformMediaEmbeds(result, mediaOptions);
|
|
324
|
+
}
|
|
310
325
|
if (mermaid) {
|
|
311
326
|
const { transformMermaidStatic } = await Promise.resolve().then(() => require("./mermaid.cjs")).then((n) => n.mermaid_exports);
|
|
312
327
|
result = await transformMermaidStatic(result);
|
|
@@ -329,6 +344,21 @@ async function transformBuiltinEmbeds(html, options) {
|
|
|
329
344
|
const { transformOgp } = await Promise.resolve().then(() => require("./ogp.cjs")).then((n) => n.ogp_exports);
|
|
330
345
|
result = await transformOgp(result, void 0, options.openGraph);
|
|
331
346
|
}
|
|
347
|
+
if (options.pm) {
|
|
348
|
+
const { transformPm } = await Promise.resolve().then(() => require("./pm.cjs")).then((n) => n.pm_exports);
|
|
349
|
+
result = await transformPm(result, typeof options.pm === "object" ? options.pm : {});
|
|
350
|
+
}
|
|
351
|
+
const mediaOptions = {
|
|
352
|
+
spotify: options.spotify,
|
|
353
|
+
stackBlitz: options.stackBlitz,
|
|
354
|
+
twitter: options.twitter,
|
|
355
|
+
bluesky: options.bluesky,
|
|
356
|
+
webContainer: options.webContainer
|
|
357
|
+
};
|
|
358
|
+
if (Object.values(mediaOptions).some(Boolean)) {
|
|
359
|
+
const { transformMediaEmbeds } = await Promise.resolve().then(() => require("./media.cjs")).then((n) => n.media_exports);
|
|
360
|
+
result = await transformMediaEmbeds(result, mediaOptions);
|
|
361
|
+
}
|
|
332
362
|
return result;
|
|
333
363
|
}
|
|
334
364
|
//#endregion
|
|
@@ -386,6 +416,94 @@ function restoreMermaidSvgs(html, svgs) {
|
|
|
386
416
|
});
|
|
387
417
|
}
|
|
388
418
|
//#endregion
|
|
419
|
+
//#region src/code-blocks.ts
|
|
420
|
+
const execFileAsync = (0, node_util.promisify)(node_child_process.execFile);
|
|
421
|
+
async function extractCodeBlocks(source) {
|
|
422
|
+
return (await require_napi.importNapiModule()).extractCodeBlocks(source).map(normalizeBlock);
|
|
423
|
+
}
|
|
424
|
+
async function lintCodeBlocks(source, options = {}) {
|
|
425
|
+
return (await require_napi.importNapiModule()).lintCodeBlocks(source, {
|
|
426
|
+
enabled: true,
|
|
427
|
+
languages: options.languages,
|
|
428
|
+
requireLanguage: options.requireLanguage,
|
|
429
|
+
trailingSpaces: options.trailingSpaces
|
|
430
|
+
}).map(normalizeDiagnostic);
|
|
431
|
+
}
|
|
432
|
+
async function extractDocsTests(source, options = {}) {
|
|
433
|
+
return (await require_napi.importNapiModule()).extractDocsTests(source, {
|
|
434
|
+
enabled: true,
|
|
435
|
+
languages: options.languages,
|
|
436
|
+
requireMeta: options.requireMeta
|
|
437
|
+
}).map(normalizeBlock);
|
|
438
|
+
}
|
|
439
|
+
async function typecheckCodeBlocks(source, options = {}) {
|
|
440
|
+
if (!source.includes("```")) return [];
|
|
441
|
+
const languages = new Set((options.languages ?? ["ts", "tsx"]).map((language) => language.toLowerCase()));
|
|
442
|
+
const blocks = (await extractCodeBlocks(source)).filter((block) => {
|
|
443
|
+
if (!languages.has(block.language.toLowerCase())) return false;
|
|
444
|
+
return options.requireMeta === false || hasTypecheckMeta(block.meta);
|
|
445
|
+
});
|
|
446
|
+
if (blocks.length === 0) return [];
|
|
447
|
+
const temp = await (0, node_fs_promises.mkdtemp)((0, node_path.join)((0, node_os.tmpdir)(), "ox-content-code-blocks-"));
|
|
448
|
+
try {
|
|
449
|
+
const files = [];
|
|
450
|
+
await Promise.all(blocks.map(async (block, index) => {
|
|
451
|
+
const file = (0, node_path.join)(temp, `snippet-${index}.${block.language.toLowerCase() === "tsx" ? "tsx" : "ts"}`);
|
|
452
|
+
files.push(file);
|
|
453
|
+
await (0, node_fs_promises.writeFile)(file, block.code);
|
|
454
|
+
}));
|
|
455
|
+
try {
|
|
456
|
+
await execFileAsync(options.tsgoCommand ?? "tsgo", [
|
|
457
|
+
"--noEmit",
|
|
458
|
+
"--pretty",
|
|
459
|
+
"false",
|
|
460
|
+
...files
|
|
461
|
+
], {
|
|
462
|
+
cwd: process.cwd(),
|
|
463
|
+
maxBuffer: 1024 * 1024 * 4
|
|
464
|
+
});
|
|
465
|
+
return [];
|
|
466
|
+
} catch (error) {
|
|
467
|
+
return [{
|
|
468
|
+
ruleId: "code-block-typecheck",
|
|
469
|
+
severity: "error",
|
|
470
|
+
message: commandOutput(error) || "TypeScript code block type-checking failed.",
|
|
471
|
+
line: blocks[0]?.startLine ?? 1,
|
|
472
|
+
column: 1,
|
|
473
|
+
endLine: blocks[0]?.startLine ?? 1,
|
|
474
|
+
endColumn: 1,
|
|
475
|
+
language: "ts"
|
|
476
|
+
}];
|
|
477
|
+
}
|
|
478
|
+
} finally {
|
|
479
|
+
await (0, node_fs_promises.rm)(temp, {
|
|
480
|
+
recursive: true,
|
|
481
|
+
force: true
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
function hasTypecheckMeta(meta) {
|
|
486
|
+
return meta.split(/\s+/).some((token) => token === "typecheck" || token === "twoslash" || token.startsWith("typecheck="));
|
|
487
|
+
}
|
|
488
|
+
function commandOutput(error) {
|
|
489
|
+
if (!error || typeof error !== "object") return "";
|
|
490
|
+
const value = error;
|
|
491
|
+
return [
|
|
492
|
+
value.stdout,
|
|
493
|
+
value.stderr,
|
|
494
|
+
value.message
|
|
495
|
+
].filter((part) => typeof part === "string" && part.trim().length > 0).join("\n").trim();
|
|
496
|
+
}
|
|
497
|
+
function normalizeBlock(block) {
|
|
498
|
+
return block;
|
|
499
|
+
}
|
|
500
|
+
function normalizeDiagnostic(diagnostic) {
|
|
501
|
+
return {
|
|
502
|
+
...diagnostic,
|
|
503
|
+
severity: diagnostic.severity === "error" || diagnostic.severity === "info" ? diagnostic.severity : "warning"
|
|
504
|
+
};
|
|
505
|
+
}
|
|
506
|
+
//#endregion
|
|
389
507
|
//#region src/transform.ts
|
|
390
508
|
/**
|
|
391
509
|
* Cached NAPI bindings instance.
|
|
@@ -452,6 +570,8 @@ async function loadNapiBindings() {
|
|
|
452
570
|
async function transformMarkdown(source, filePath, options, ssgOptions) {
|
|
453
571
|
const napi = await loadNapiBindings();
|
|
454
572
|
if (!napi) throw new Error("[ox-content] NAPI bindings not available. Please ensure @ox-content/napi is built.");
|
|
573
|
+
runCodeBlockLint(source, napi, options);
|
|
574
|
+
await runCodeBlockTypecheck(source, options);
|
|
455
575
|
const result = napi.transform(source, {
|
|
456
576
|
gfm: options.gfm,
|
|
457
577
|
footnotes: options.footnotes,
|
|
@@ -463,10 +583,32 @@ async function transformMarkdown(source, filePath, options, ssgOptions) {
|
|
|
463
583
|
convertMdLinks: ssgOptions?.convertMdLinks,
|
|
464
584
|
baseUrl: ssgOptions?.baseUrl,
|
|
465
585
|
sourcePath: ssgOptions?.sourcePath ?? filePath,
|
|
466
|
-
codeAnnotations: options.codeAnnotations
|
|
467
|
-
codeAnnotationMetaKey: options.codeAnnotations
|
|
468
|
-
codeAnnotationSyntax: options.codeAnnotations
|
|
469
|
-
codeAnnotationDefaultLineNumbers: options.codeAnnotations
|
|
586
|
+
codeAnnotations: options.codeAnnotations?.enabled ?? false,
|
|
587
|
+
codeAnnotationMetaKey: options.codeAnnotations?.metaKey ?? "annotate",
|
|
588
|
+
codeAnnotationSyntax: options.codeAnnotations?.notation ?? "attribute",
|
|
589
|
+
codeAnnotationDefaultLineNumbers: options.codeAnnotations?.defaultLineNumbers ?? false,
|
|
590
|
+
wikiLinks: options.wikiLinks?.enabled ? {
|
|
591
|
+
enabled: true,
|
|
592
|
+
baseUrl: options.wikiLinks.baseUrl
|
|
593
|
+
} : void 0,
|
|
594
|
+
emojiShortcodes: options.emojiShortcodes?.enabled ? {
|
|
595
|
+
enabled: true,
|
|
596
|
+
custom: options.emojiShortcodes.custom
|
|
597
|
+
} : void 0,
|
|
598
|
+
attributes: options.attrs?.enabled ? { enabled: true } : void 0,
|
|
599
|
+
cjkEmphasis: options.cjkEmphasis ?? false,
|
|
600
|
+
codeImports: options.codeImports?.enabled ? {
|
|
601
|
+
enabled: true,
|
|
602
|
+
rootDir: options.codeImports.rootDir
|
|
603
|
+
} : void 0,
|
|
604
|
+
sanitize: void 0,
|
|
605
|
+
editThisPage: options.editThisPage?.enabled ? {
|
|
606
|
+
enabled: true,
|
|
607
|
+
repoUrl: options.editThisPage.repoUrl,
|
|
608
|
+
branch: options.editThisPage.branch,
|
|
609
|
+
rootDir: options.editThisPage.rootDir,
|
|
610
|
+
label: options.editThisPage.label
|
|
611
|
+
} : void 0
|
|
470
612
|
});
|
|
471
613
|
if (result.errors.length > 0) console.warn("[ox-content] Transform warnings:", result.errors);
|
|
472
614
|
let html = result.html;
|
|
@@ -485,6 +627,7 @@ async function transformMarkdown(source, filePath, options, ssgOptions) {
|
|
|
485
627
|
openGraph: {}
|
|
486
628
|
});
|
|
487
629
|
html = restoreMermaidSvgs(html, svgs);
|
|
630
|
+
if (options.sanitize?.enabled) html = napi.sanitizeHtml(html, toJsSanitizeOptions(options.sanitize));
|
|
488
631
|
return {
|
|
489
632
|
code: generateModuleCode(html, frontmatter, toc, filePath, options),
|
|
490
633
|
html,
|
|
@@ -492,6 +635,43 @@ async function transformMarkdown(source, filePath, options, ssgOptions) {
|
|
|
492
635
|
toc
|
|
493
636
|
};
|
|
494
637
|
}
|
|
638
|
+
async function runCodeBlockTypecheck(source, options) {
|
|
639
|
+
const typecheck = options.codeBlockTypecheck;
|
|
640
|
+
if (!typecheck?.enabled || !source.includes("```")) return;
|
|
641
|
+
const diagnostics = await typecheckCodeBlocks(source, {
|
|
642
|
+
languages: typecheck.languages,
|
|
643
|
+
requireMeta: typecheck.requireMeta,
|
|
644
|
+
tsgoCommand: typecheck.tsgoCommand
|
|
645
|
+
});
|
|
646
|
+
if (diagnostics.length === 0) return;
|
|
647
|
+
const message = diagnostics.slice(0, 3).map((diagnostic) => `${diagnostic.ruleId} at ${diagnostic.line}: ${diagnostic.message}`).join("\n");
|
|
648
|
+
if (typecheck.mode === "error") throw new Error(`[ox-content] Code block type-checking failed:\n${message}`);
|
|
649
|
+
console.warn(`[ox-content] Code block type-checking warnings:\n${message}`);
|
|
650
|
+
}
|
|
651
|
+
function runCodeBlockLint(source, napi, options) {
|
|
652
|
+
const lint = options.codeBlockLint;
|
|
653
|
+
if (!lint?.enabled || !source.includes("```")) return;
|
|
654
|
+
const diagnostics = napi.lintCodeBlocks(source, {
|
|
655
|
+
enabled: true,
|
|
656
|
+
languages: lint.languages,
|
|
657
|
+
requireLanguage: lint.requireLanguage,
|
|
658
|
+
trailingSpaces: lint.trailingSpaces
|
|
659
|
+
});
|
|
660
|
+
if (diagnostics.length === 0) return;
|
|
661
|
+
const message = diagnostics.slice(0, 5).map((diagnostic) => {
|
|
662
|
+
return `${diagnostic.ruleId} at ${diagnostic.line}:${diagnostic.column} ${diagnostic.message}`;
|
|
663
|
+
}).join("\n");
|
|
664
|
+
if (lint.mode === "error") throw new Error(`[ox-content] Code block lint failed:\n${message}`);
|
|
665
|
+
console.warn(`[ox-content] Code block lint warnings:\n${message}`);
|
|
666
|
+
}
|
|
667
|
+
function toJsSanitizeOptions(options) {
|
|
668
|
+
return {
|
|
669
|
+
enabled: true,
|
|
670
|
+
allowedTags: options.allowedTags,
|
|
671
|
+
allowedAttributes: options.allowedAttributes,
|
|
672
|
+
allowedUrlSchemes: options.allowedUrlSchemes
|
|
673
|
+
};
|
|
674
|
+
}
|
|
495
675
|
function parseFrontmatterJson(json) {
|
|
496
676
|
if (!json) return {};
|
|
497
677
|
try {
|
|
@@ -1962,6 +2142,12 @@ async function transformSsgHtml(html, options) {
|
|
|
1962
2142
|
youtube: true,
|
|
1963
2143
|
github: options.embeds.github,
|
|
1964
2144
|
openGraph: options.embeds.openGraph,
|
|
2145
|
+
pm: options.embeds.pm,
|
|
2146
|
+
spotify: options.embeds.spotify,
|
|
2147
|
+
stackBlitz: options.embeds.stackBlitz,
|
|
2148
|
+
twitter: options.embeds.twitter,
|
|
2149
|
+
bluesky: options.embeds.bluesky,
|
|
2150
|
+
webContainer: options.embeds.webContainer,
|
|
1965
2151
|
mermaid: true,
|
|
1966
2152
|
githubToken: process.env.GITHUB_TOKEN
|
|
1967
2153
|
});
|
|
@@ -2271,6 +2457,12 @@ async function renderPage$1(filePath, options, navGroups, siteName, base, root)
|
|
|
2271
2457
|
youtube: true,
|
|
2272
2458
|
github: options.embeds.github,
|
|
2273
2459
|
openGraph: options.embeds.openGraph,
|
|
2460
|
+
pm: options.embeds.pm,
|
|
2461
|
+
spotify: options.embeds.spotify,
|
|
2462
|
+
stackBlitz: options.embeds.stackBlitz,
|
|
2463
|
+
twitter: options.embeds.twitter,
|
|
2464
|
+
bluesky: options.embeds.bluesky,
|
|
2465
|
+
webContainer: options.embeds.webContainer,
|
|
2274
2466
|
mermaid: true,
|
|
2275
2467
|
githubToken: process.env.GITHUB_TOKEN
|
|
2276
2468
|
});
|
|
@@ -3936,6 +4128,16 @@ function resolveOptions(options) {
|
|
|
3936
4128
|
highlightTheme: options.highlightTheme ?? "github-dark",
|
|
3937
4129
|
highlightLangs: options.highlightLangs ?? [],
|
|
3938
4130
|
codeAnnotations: resolveCodeAnnotationsOptions(options.codeAnnotations),
|
|
4131
|
+
wikiLinks: resolveWikiLinkOptions(options.wikiLinks, options.base ?? "/"),
|
|
4132
|
+
emojiShortcodes: resolveEmojiShortcodeOptions(options.emojiShortcodes),
|
|
4133
|
+
attrs: resolveAttrsOptions(options.attrs),
|
|
4134
|
+
codeImports: resolveCodeImportOptions(options.codeImports),
|
|
4135
|
+
sanitize: resolveSanitizeOptions(options.sanitize),
|
|
4136
|
+
editThisPage: resolveEditThisPageOptions(options.editThisPage),
|
|
4137
|
+
cjkEmphasis: options.cjkEmphasis ?? false,
|
|
4138
|
+
codeBlockLint: resolveCodeBlockLintOptions(options.codeBlockLint),
|
|
4139
|
+
codeBlockTypecheck: resolveCodeBlockTypecheckOptions(options.codeBlockTypecheck),
|
|
4140
|
+
docsTests: resolveDocsTestOptions(options.docsTests),
|
|
3939
4141
|
mermaid: options.mermaid ?? false,
|
|
3940
4142
|
frontmatter: options.frontmatter ?? true,
|
|
3941
4143
|
toc: options.toc ?? true,
|
|
@@ -3953,11 +4155,23 @@ function resolveOptions(options) {
|
|
|
3953
4155
|
function resolveBuiltinEmbedOptions(options) {
|
|
3954
4156
|
if (options === false) return {
|
|
3955
4157
|
github: false,
|
|
3956
|
-
openGraph: false
|
|
4158
|
+
openGraph: false,
|
|
4159
|
+
pm: false,
|
|
4160
|
+
spotify: false,
|
|
4161
|
+
stackBlitz: false,
|
|
4162
|
+
twitter: false,
|
|
4163
|
+
bluesky: false,
|
|
4164
|
+
webContainer: false
|
|
3957
4165
|
};
|
|
3958
4166
|
return {
|
|
3959
4167
|
github: resolveSingleEmbedOptions(options?.github),
|
|
3960
|
-
openGraph: resolveSingleEmbedOptions(options?.openGraph)
|
|
4168
|
+
openGraph: resolveSingleEmbedOptions(options?.openGraph),
|
|
4169
|
+
pm: resolvePmOptions(options?.pm),
|
|
4170
|
+
spotify: options?.spotify === true,
|
|
4171
|
+
stackBlitz: options?.stackBlitz === true,
|
|
4172
|
+
twitter: options?.twitter === true,
|
|
4173
|
+
bluesky: options?.bluesky === true,
|
|
4174
|
+
webContainer: options?.webContainer === true
|
|
3961
4175
|
};
|
|
3962
4176
|
}
|
|
3963
4177
|
function resolveSingleEmbedOptions(options) {
|
|
@@ -3965,6 +4179,157 @@ function resolveSingleEmbedOptions(options) {
|
|
|
3965
4179
|
if (options === true || options === void 0) return {};
|
|
3966
4180
|
return options;
|
|
3967
4181
|
}
|
|
4182
|
+
function resolvePmOptions(options) {
|
|
4183
|
+
if (options === false || options === void 0) return false;
|
|
4184
|
+
if (options === true) return {};
|
|
4185
|
+
return options;
|
|
4186
|
+
}
|
|
4187
|
+
function resolveWikiLinkOptions(options, baseUrl) {
|
|
4188
|
+
if (!options) return {
|
|
4189
|
+
enabled: false,
|
|
4190
|
+
baseUrl
|
|
4191
|
+
};
|
|
4192
|
+
if (options === true) return {
|
|
4193
|
+
enabled: true,
|
|
4194
|
+
baseUrl
|
|
4195
|
+
};
|
|
4196
|
+
return {
|
|
4197
|
+
enabled: true,
|
|
4198
|
+
baseUrl: options.baseUrl ?? baseUrl
|
|
4199
|
+
};
|
|
4200
|
+
}
|
|
4201
|
+
function resolveEmojiShortcodeOptions(options) {
|
|
4202
|
+
if (!options) return {
|
|
4203
|
+
enabled: false,
|
|
4204
|
+
custom: {}
|
|
4205
|
+
};
|
|
4206
|
+
if (options === true) return {
|
|
4207
|
+
enabled: true,
|
|
4208
|
+
custom: {}
|
|
4209
|
+
};
|
|
4210
|
+
return {
|
|
4211
|
+
enabled: true,
|
|
4212
|
+
custom: options.custom ?? {}
|
|
4213
|
+
};
|
|
4214
|
+
}
|
|
4215
|
+
function resolveAttrsOptions(options) {
|
|
4216
|
+
if (!options) return { enabled: false };
|
|
4217
|
+
if (options === true) return { enabled: true };
|
|
4218
|
+
return { enabled: options.enabled ?? true };
|
|
4219
|
+
}
|
|
4220
|
+
function resolveCodeImportOptions(options) {
|
|
4221
|
+
if (!options) return { enabled: false };
|
|
4222
|
+
if (options === true) return { enabled: true };
|
|
4223
|
+
return {
|
|
4224
|
+
enabled: true,
|
|
4225
|
+
rootDir: options.rootDir
|
|
4226
|
+
};
|
|
4227
|
+
}
|
|
4228
|
+
function resolveSanitizeOptions(options) {
|
|
4229
|
+
if (!options) return { enabled: false };
|
|
4230
|
+
if (options === true) return { enabled: true };
|
|
4231
|
+
return {
|
|
4232
|
+
enabled: true,
|
|
4233
|
+
allowedTags: options.allowedTags,
|
|
4234
|
+
allowedAttributes: options.allowedAttributes,
|
|
4235
|
+
allowedUrlSchemes: options.allowedUrlSchemes
|
|
4236
|
+
};
|
|
4237
|
+
}
|
|
4238
|
+
function resolveEditThisPageOptions(options) {
|
|
4239
|
+
if (!options) return {
|
|
4240
|
+
enabled: false,
|
|
4241
|
+
branch: "main",
|
|
4242
|
+
label: "Edit this page"
|
|
4243
|
+
};
|
|
4244
|
+
if (options === true) return {
|
|
4245
|
+
enabled: false,
|
|
4246
|
+
branch: "main",
|
|
4247
|
+
label: "Edit this page"
|
|
4248
|
+
};
|
|
4249
|
+
return {
|
|
4250
|
+
enabled: Boolean(options.repoUrl),
|
|
4251
|
+
repoUrl: options.repoUrl,
|
|
4252
|
+
branch: options.branch ?? "main",
|
|
4253
|
+
rootDir: options.rootDir,
|
|
4254
|
+
label: options.label ?? "Edit this page"
|
|
4255
|
+
};
|
|
4256
|
+
}
|
|
4257
|
+
function resolveCodeBlockLintOptions(options) {
|
|
4258
|
+
if (!options) return {
|
|
4259
|
+
enabled: false,
|
|
4260
|
+
requireLanguage: false,
|
|
4261
|
+
trailingSpaces: true,
|
|
4262
|
+
mode: "warn"
|
|
4263
|
+
};
|
|
4264
|
+
if (options === true) return {
|
|
4265
|
+
enabled: true,
|
|
4266
|
+
requireLanguage: false,
|
|
4267
|
+
trailingSpaces: true,
|
|
4268
|
+
mode: "warn"
|
|
4269
|
+
};
|
|
4270
|
+
return {
|
|
4271
|
+
enabled: true,
|
|
4272
|
+
languages: options.languages,
|
|
4273
|
+
requireLanguage: options.requireLanguage ?? false,
|
|
4274
|
+
trailingSpaces: options.trailingSpaces ?? true,
|
|
4275
|
+
mode: options.mode ?? "warn"
|
|
4276
|
+
};
|
|
4277
|
+
}
|
|
4278
|
+
function resolveCodeBlockTypecheckOptions(options) {
|
|
4279
|
+
if (!options) return {
|
|
4280
|
+
enabled: false,
|
|
4281
|
+
languages: ["ts", "tsx"],
|
|
4282
|
+
requireMeta: true,
|
|
4283
|
+
tsgoCommand: "tsgo",
|
|
4284
|
+
mode: "warn"
|
|
4285
|
+
};
|
|
4286
|
+
if (options === true) return {
|
|
4287
|
+
enabled: true,
|
|
4288
|
+
languages: ["ts", "tsx"],
|
|
4289
|
+
requireMeta: true,
|
|
4290
|
+
tsgoCommand: "tsgo",
|
|
4291
|
+
mode: "warn"
|
|
4292
|
+
};
|
|
4293
|
+
return {
|
|
4294
|
+
enabled: true,
|
|
4295
|
+
languages: options.languages ?? ["ts", "tsx"],
|
|
4296
|
+
requireMeta: options.requireMeta ?? true,
|
|
4297
|
+
tsgoCommand: options.tsgoCommand ?? "tsgo",
|
|
4298
|
+
mode: options.mode ?? "warn"
|
|
4299
|
+
};
|
|
4300
|
+
}
|
|
4301
|
+
function resolveDocsTestOptions(options) {
|
|
4302
|
+
if (!options) return {
|
|
4303
|
+
enabled: false,
|
|
4304
|
+
languages: [
|
|
4305
|
+
"js",
|
|
4306
|
+
"jsx",
|
|
4307
|
+
"ts",
|
|
4308
|
+
"tsx"
|
|
4309
|
+
],
|
|
4310
|
+
requireMeta: true
|
|
4311
|
+
};
|
|
4312
|
+
if (options === true) return {
|
|
4313
|
+
enabled: true,
|
|
4314
|
+
languages: [
|
|
4315
|
+
"js",
|
|
4316
|
+
"jsx",
|
|
4317
|
+
"ts",
|
|
4318
|
+
"tsx"
|
|
4319
|
+
],
|
|
4320
|
+
requireMeta: true
|
|
4321
|
+
};
|
|
4322
|
+
return {
|
|
4323
|
+
enabled: true,
|
|
4324
|
+
languages: options.languages ?? [
|
|
4325
|
+
"js",
|
|
4326
|
+
"jsx",
|
|
4327
|
+
"ts",
|
|
4328
|
+
"tsx"
|
|
4329
|
+
],
|
|
4330
|
+
requireMeta: options.requireMeta ?? true
|
|
4331
|
+
};
|
|
4332
|
+
}
|
|
3968
4333
|
function resolveCodeAnnotationsOptions(options) {
|
|
3969
4334
|
if (!options) return {
|
|
3970
4335
|
enabled: false,
|
|
@@ -4055,7 +4420,9 @@ exports.createTheme = createTheme;
|
|
|
4055
4420
|
exports.defaultTheme = require_vitepress.defaultTheme;
|
|
4056
4421
|
exports.defineTheme = require_vitepress.defineTheme;
|
|
4057
4422
|
exports.each = each;
|
|
4423
|
+
exports.extractCodeBlocks = extractCodeBlocks;
|
|
4058
4424
|
exports.extractDocs = extractDocs;
|
|
4425
|
+
exports.extractDocsTests = extractDocsTests;
|
|
4059
4426
|
exports.extractIslandInfo = extractIslandInfo;
|
|
4060
4427
|
exports.extractVideoId = require_youtube.extractVideoId;
|
|
4061
4428
|
exports.fetchGitHubSource = require_github.fetchGitHubSource;
|
|
@@ -4075,6 +4442,7 @@ exports.inferType = inferType;
|
|
|
4075
4442
|
exports.isMarkdownFilePath = isMarkdownFilePath;
|
|
4076
4443
|
exports.jsx = jsx;
|
|
4077
4444
|
exports.jsxs = jsxs;
|
|
4445
|
+
exports.lintCodeBlocks = lintCodeBlocks;
|
|
4078
4446
|
exports.lintMarkdown = lintMarkdown;
|
|
4079
4447
|
exports.lintMarkdownAsync = lintMarkdownAsync;
|
|
4080
4448
|
exports.lintMarkdownFile = lintMarkdownFile;
|
|
@@ -4111,6 +4479,7 @@ exports.transformMermaidStatic = require_mermaid.transformMermaidStatic;
|
|
|
4111
4479
|
exports.transformOgp = require_ogp.transformOgp;
|
|
4112
4480
|
exports.transformTabs = require_tabs.transformTabs;
|
|
4113
4481
|
exports.transformYouTube = require_youtube.transformYouTube;
|
|
4482
|
+
exports.typecheckCodeBlocks = typecheckCodeBlocks;
|
|
4114
4483
|
exports.useIsActive = useIsActive;
|
|
4115
4484
|
exports.useNav = useNav;
|
|
4116
4485
|
exports.usePageProps = usePageProps;
|