@ox-content/vite-plugin 2.10.0 → 2.11.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/github.cjs +381 -10
- package/dist/github.cjs.map +1 -1
- package/dist/github.mjs +352 -11
- package/dist/github.mjs.map +1 -1
- package/dist/index.cjs +164 -76
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +251 -167
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +251 -167
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +156 -78
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as importNapiModuleSync, c as __exportAll, d as __toESM, i as importNapiModule, l as __require, o as __commonJSMin, r as transformMermaidStatic, s as __esmMin, t as mermaidClientScript, u as __toCommonJS } from "./mermaid.mjs";
|
|
2
2
|
import { i as transformTabs, n as resetTabGroupCounter, t as generateTabsCSS } from "./tabs.mjs";
|
|
3
3
|
import { n as transformYouTube, t as extractVideoId } from "./youtube.mjs";
|
|
4
|
-
import {
|
|
4
|
+
import { c as prefetchGitHubRepos, i as fetchRepoData, l as prefetchGitHubSources, n as collectGitHubSources, o as parseGitHubLineRange, r as fetchGitHubSource, s as parseGitHubPermalink, t as collectGitHubRepos, u as transformGitHub } from "./github.mjs";
|
|
5
5
|
import { a as transformOgp, i as prefetchOgpData, n as fetchOgpData, t as collectOgpUrls } from "./ogp.mjs";
|
|
6
6
|
import { a as normalizeVitePressFrontmatter, c as mergeThemes, i as generateVitePressMigrationConfig, l as resolveTheme, n as convertVitePressSidebar, o as defaultTheme, r as fromVitePressConfig, s as defineTheme, t as convertVitePressNav, u as themeToNapi } from "./vitepress.mjs";
|
|
7
7
|
import { createRequire } from "node:module";
|
|
@@ -18,6 +18,40 @@ import { glob } from "glob";
|
|
|
18
18
|
import * as crypto from "crypto";
|
|
19
19
|
import * as fs from "node:fs/promises";
|
|
20
20
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
21
|
+
//#region src/markdown.ts
|
|
22
|
+
const DEFAULT_MARKDOWN_EXTENSIONS = [
|
|
23
|
+
".md",
|
|
24
|
+
".markdown",
|
|
25
|
+
".mdx"
|
|
26
|
+
];
|
|
27
|
+
function normalizeMarkdownExtensions(extensions) {
|
|
28
|
+
const values = extensions?.length ? extensions : DEFAULT_MARKDOWN_EXTENSIONS;
|
|
29
|
+
const seen = /* @__PURE__ */ new Set();
|
|
30
|
+
const normalized = [];
|
|
31
|
+
for (const extension of values) {
|
|
32
|
+
const value = extension.startsWith(".") ? extension : `.${extension}`;
|
|
33
|
+
const key = value.toLowerCase();
|
|
34
|
+
if (!seen.has(key)) {
|
|
35
|
+
seen.add(key);
|
|
36
|
+
normalized.push(value);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return normalized;
|
|
40
|
+
}
|
|
41
|
+
function isMarkdownFilePath(filePath, extensions = DEFAULT_MARKDOWN_EXTENSIONS) {
|
|
42
|
+
const pathname = filePath.split("?")[0].split("#")[0].toLowerCase();
|
|
43
|
+
return extensions.some((extension) => pathname.endsWith(extension.toLowerCase()));
|
|
44
|
+
}
|
|
45
|
+
function stripMarkdownExtension(filePath, extensions = DEFAULT_MARKDOWN_EXTENSIONS) {
|
|
46
|
+
const match = [...extensions].sort((left, right) => right.length - left.length).find((extension) => filePath.toLowerCase().endsWith(extension.toLowerCase()));
|
|
47
|
+
return match ? filePath.slice(0, -match.length) : filePath;
|
|
48
|
+
}
|
|
49
|
+
function markdownGlobPattern(srcDir, extensions) {
|
|
50
|
+
const suffixes = extensions.map((extension) => extension.replace(/^\./, ""));
|
|
51
|
+
if (suffixes.length === 1) return path$1.join(srcDir, `**/*.${suffixes[0]}`);
|
|
52
|
+
return path$1.join(srcDir, `**/*.{${suffixes.join(",")}}`);
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
21
55
|
//#region src/environment.ts
|
|
22
56
|
/**
|
|
23
57
|
* Creates the Markdown processing environment configuration.
|
|
@@ -50,7 +84,7 @@ function createMarkdownEnvironment(options) {
|
|
|
50
84
|
rollupOptions: { external: [/^node:/, /\.node$/] }
|
|
51
85
|
},
|
|
52
86
|
resolve: {
|
|
53
|
-
extensions:
|
|
87
|
+
extensions: options.extensions,
|
|
54
88
|
conditions: [
|
|
55
89
|
"markdown",
|
|
56
90
|
"node",
|
|
@@ -6798,6 +6832,58 @@ async function highlightCode(html, theme = "github-dark", langs = []) {
|
|
|
6798
6832
|
return String(result);
|
|
6799
6833
|
}
|
|
6800
6834
|
//#endregion
|
|
6835
|
+
//#region src/plugins/index.ts
|
|
6836
|
+
/**
|
|
6837
|
+
* Transform all enabled plugins in HTML content.
|
|
6838
|
+
*/
|
|
6839
|
+
async function transformAllPlugins(html, options = {}) {
|
|
6840
|
+
const { tabs = true, youtube = true, github = true, ogp, openGraph, mermaid = true, githubToken } = options;
|
|
6841
|
+
let result = html;
|
|
6842
|
+
const ogpOptions = openGraph ?? ogp ?? true;
|
|
6843
|
+
if (tabs) {
|
|
6844
|
+
const { transformTabs } = await import("./tabs.mjs").then((n) => n.r);
|
|
6845
|
+
result = await transformTabs(result);
|
|
6846
|
+
}
|
|
6847
|
+
if (youtube) {
|
|
6848
|
+
const { transformYouTube } = await import("./youtube.mjs").then((n) => n.r);
|
|
6849
|
+
result = await transformYouTube(result);
|
|
6850
|
+
}
|
|
6851
|
+
if (github !== false) {
|
|
6852
|
+
const { transformGitHub } = await import("./github.mjs").then((n) => n.a);
|
|
6853
|
+
result = await transformGitHub(result, void 0, {
|
|
6854
|
+
token: githubToken,
|
|
6855
|
+
...typeof github === "object" ? github : {}
|
|
6856
|
+
});
|
|
6857
|
+
}
|
|
6858
|
+
if (ogpOptions !== false) {
|
|
6859
|
+
const { transformOgp } = await import("./ogp.mjs").then((n) => n.r);
|
|
6860
|
+
result = await transformOgp(result, void 0, typeof ogpOptions === "object" ? ogpOptions : {});
|
|
6861
|
+
}
|
|
6862
|
+
if (mermaid) {
|
|
6863
|
+
const { transformMermaidStatic } = await import("./mermaid.mjs").then((n) => n.n);
|
|
6864
|
+
result = await transformMermaidStatic(result);
|
|
6865
|
+
}
|
|
6866
|
+
return result;
|
|
6867
|
+
}
|
|
6868
|
+
/**
|
|
6869
|
+
* Transform built-in embed components in HTML content.
|
|
6870
|
+
*/
|
|
6871
|
+
async function transformBuiltinEmbeds(html, options) {
|
|
6872
|
+
let result = html;
|
|
6873
|
+
if (options.github) {
|
|
6874
|
+
const { transformGitHub } = await import("./github.mjs").then((n) => n.a);
|
|
6875
|
+
result = await transformGitHub(result, void 0, {
|
|
6876
|
+
token: process.env.GITHUB_TOKEN,
|
|
6877
|
+
...options.github
|
|
6878
|
+
});
|
|
6879
|
+
}
|
|
6880
|
+
if (options.openGraph) {
|
|
6881
|
+
const { transformOgp } = await import("./ogp.mjs").then((n) => n.r);
|
|
6882
|
+
result = await transformOgp(result, void 0, options.openGraph);
|
|
6883
|
+
}
|
|
6884
|
+
return result;
|
|
6885
|
+
}
|
|
6886
|
+
//#endregion
|
|
6801
6887
|
//#region src/plugins/mermaid-protect.ts
|
|
6802
6888
|
/**
|
|
6803
6889
|
* Extract `<div class="ox-mermaid">...</div>` blocks and replace
|
|
@@ -6979,6 +7065,10 @@ async function transformMarkdown(source, filePath, options, ssgOptions) {
|
|
|
6979
7065
|
const highlightedHtml = await highlightCode(html, options.highlightTheme, options.highlightLangs);
|
|
6980
7066
|
html = napi.mergeHighlightedCodeBlocks(originalHtml, highlightedHtml);
|
|
6981
7067
|
}
|
|
7068
|
+
html = await transformBuiltinEmbeds(html, options.embeds ?? {
|
|
7069
|
+
github: {},
|
|
7070
|
+
openGraph: {}
|
|
7071
|
+
});
|
|
6982
7072
|
html = restoreMermaidSvgs(html, svgs);
|
|
6983
7073
|
return {
|
|
6984
7074
|
code: generateModuleCode(html, frontmatter, toc, filePath, options),
|
|
@@ -8578,36 +8668,6 @@ async function renderSinglePage(entry, templateFn, templateSource, options, cach
|
|
|
8578
8668
|
}
|
|
8579
8669
|
}
|
|
8580
8670
|
//#endregion
|
|
8581
|
-
//#region src/plugins/index.ts
|
|
8582
|
-
/**
|
|
8583
|
-
* Transform all enabled plugins in HTML content.
|
|
8584
|
-
*/
|
|
8585
|
-
async function transformAllPlugins(html, options = {}) {
|
|
8586
|
-
const { tabs = true, youtube = true, github = true, ogp = true, mermaid = true, githubToken } = options;
|
|
8587
|
-
let result = html;
|
|
8588
|
-
if (tabs) {
|
|
8589
|
-
const { transformTabs } = await import("./tabs.mjs").then((n) => n.r);
|
|
8590
|
-
result = await transformTabs(result);
|
|
8591
|
-
}
|
|
8592
|
-
if (youtube) {
|
|
8593
|
-
const { transformYouTube } = await import("./youtube.mjs").then((n) => n.r);
|
|
8594
|
-
result = await transformYouTube(result);
|
|
8595
|
-
}
|
|
8596
|
-
if (github) {
|
|
8597
|
-
const { transformGitHub } = await import("./github.mjs").then((n) => n.r);
|
|
8598
|
-
result = await transformGitHub(result, void 0, { token: githubToken });
|
|
8599
|
-
}
|
|
8600
|
-
if (ogp) {
|
|
8601
|
-
const { transformOgp } = await import("./ogp.mjs").then((n) => n.r);
|
|
8602
|
-
result = await transformOgp(result);
|
|
8603
|
-
}
|
|
8604
|
-
if (mermaid) {
|
|
8605
|
-
const { transformMermaidStatic } = await import("./mermaid.mjs").then((n) => n.n);
|
|
8606
|
-
result = await transformMermaidStatic(result);
|
|
8607
|
-
}
|
|
8608
|
-
return result;
|
|
8609
|
-
}
|
|
8610
|
-
//#endregion
|
|
8611
8671
|
//#region src/island/parse.ts
|
|
8612
8672
|
/**
|
|
8613
8673
|
* Island Parser
|
|
@@ -10376,8 +10436,8 @@ function formatTitle(name) {
|
|
|
10376
10436
|
/**
|
|
10377
10437
|
* Collects all markdown files from the source directory.
|
|
10378
10438
|
*/
|
|
10379
|
-
async function collectMarkdownFiles$1(srcDir) {
|
|
10380
|
-
return (await glob(
|
|
10439
|
+
async function collectMarkdownFiles$1(srcDir, extensions = DEFAULT_MARKDOWN_EXTENSIONS) {
|
|
10440
|
+
return (await glob(markdownGlobPattern(srcDir, extensions), {
|
|
10381
10441
|
nodir: true,
|
|
10382
10442
|
ignore: [
|
|
10383
10443
|
"**/node_modules/**",
|
|
@@ -10419,7 +10479,7 @@ async function buildSsg(options, root) {
|
|
|
10419
10479
|
force: true
|
|
10420
10480
|
});
|
|
10421
10481
|
} catch {}
|
|
10422
|
-
const markdownFiles = await collectMarkdownFiles$1(srcDir);
|
|
10482
|
+
const markdownFiles = await collectMarkdownFiles$1(srcDir, options.extensions);
|
|
10423
10483
|
const navItems = resolveNavigationGroups(ssgOptions.navigation, base, ssgOptions.extension) ?? (ssgOptions.theme?.sidebar.length ? buildThemeNavItems(ssgOptions.theme.sidebar, base, ssgOptions.extension) : buildNavItems(markdownFiles, srcDir, base, ssgOptions.extension));
|
|
10424
10484
|
let siteName = ssgOptions.siteName ?? "Documentation";
|
|
10425
10485
|
if (!ssgOptions.siteName) try {
|
|
@@ -10446,8 +10506,8 @@ async function buildSsg(options, root) {
|
|
|
10446
10506
|
const pluginOptions = {
|
|
10447
10507
|
tabs: true,
|
|
10448
10508
|
youtube: true,
|
|
10449
|
-
github:
|
|
10450
|
-
|
|
10509
|
+
github: options.embeds.github,
|
|
10510
|
+
openGraph: options.embeds.openGraph,
|
|
10451
10511
|
mermaid: true,
|
|
10452
10512
|
githubToken: process.env.GITHUB_TOKEN
|
|
10453
10513
|
};
|
|
@@ -10593,7 +10653,7 @@ function resolveSearchOptions(options) {
|
|
|
10593
10653
|
/**
|
|
10594
10654
|
* Collects all Markdown files from a directory.
|
|
10595
10655
|
*/
|
|
10596
|
-
async function collectMarkdownFiles(dir) {
|
|
10656
|
+
async function collectMarkdownFiles(dir, extensions = DEFAULT_MARKDOWN_EXTENSIONS) {
|
|
10597
10657
|
const files = [];
|
|
10598
10658
|
async function walk(currentDir) {
|
|
10599
10659
|
try {
|
|
@@ -10601,7 +10661,7 @@ async function collectMarkdownFiles(dir) {
|
|
|
10601
10661
|
for (const entry of entries) {
|
|
10602
10662
|
const fullPath = path$1.join(currentDir, entry.name);
|
|
10603
10663
|
if (entry.isDirectory() && !entry.name.startsWith(".") && entry.name !== "node_modules") await walk(fullPath);
|
|
10604
|
-
else if (entry.isFile() && entry.name
|
|
10664
|
+
else if (entry.isFile() && isMarkdownFilePath(entry.name, extensions)) files.push(fullPath);
|
|
10605
10665
|
}
|
|
10606
10666
|
} catch {}
|
|
10607
10667
|
}
|
|
@@ -10611,7 +10671,7 @@ async function collectMarkdownFiles(dir) {
|
|
|
10611
10671
|
/**
|
|
10612
10672
|
* Builds the search index from Markdown files.
|
|
10613
10673
|
*/
|
|
10614
|
-
async function buildSearchIndex(srcDir, base) {
|
|
10674
|
+
async function buildSearchIndex(srcDir, base, extensions = DEFAULT_MARKDOWN_EXTENSIONS) {
|
|
10615
10675
|
const napi = await getOxContent();
|
|
10616
10676
|
if (!napi) return JSON.stringify({
|
|
10617
10677
|
documents: [],
|
|
@@ -10620,13 +10680,12 @@ async function buildSearchIndex(srcDir, base) {
|
|
|
10620
10680
|
avg_dl: 0,
|
|
10621
10681
|
doc_count: 0
|
|
10622
10682
|
});
|
|
10623
|
-
const files = await collectMarkdownFiles(srcDir);
|
|
10683
|
+
const files = await collectMarkdownFiles(srcDir, extensions);
|
|
10624
10684
|
const documents = [];
|
|
10625
10685
|
for (const file of files) try {
|
|
10626
10686
|
const content = await fs$1.readFile(file, "utf-8");
|
|
10627
|
-
const
|
|
10628
|
-
const url = base +
|
|
10629
|
-
const id = relativePath.replace(/\.md$/, "").replace(/\\/g, "/");
|
|
10687
|
+
const id = stripMarkdownExtension(path$1.relative(srcDir, file), extensions).replace(/\\/g, "/");
|
|
10688
|
+
const url = base + id;
|
|
10630
10689
|
const extractSearchContent = napi.extractSearchContent;
|
|
10631
10690
|
if (!extractSearchContent) {
|
|
10632
10691
|
console.warn("[ox-content] Search not available: extractSearchContent not implemented");
|
|
@@ -10721,26 +10780,27 @@ function shouldSkip(url) {
|
|
|
10721
10780
|
* Resolve a request URL to a markdown file path.
|
|
10722
10781
|
* Returns null if no matching file exists.
|
|
10723
10782
|
*/
|
|
10724
|
-
async function resolveMarkdownFile(url, srcDir) {
|
|
10783
|
+
async function resolveMarkdownFile(url, srcDir, extensions) {
|
|
10725
10784
|
let pathname = url.split("?")[0].split("#")[0];
|
|
10726
10785
|
if (pathname.endsWith("/index.html")) pathname = pathname.slice(0, -11) || "/";
|
|
10727
10786
|
if (pathname !== "/" && pathname.endsWith("/")) pathname = pathname.slice(0, -1);
|
|
10728
|
-
|
|
10729
|
-
|
|
10730
|
-
|
|
10731
|
-
|
|
10732
|
-
|
|
10733
|
-
|
|
10734
|
-
|
|
10735
|
-
|
|
10736
|
-
|
|
10787
|
+
const routePath = pathname === "/" ? "" : pathname.slice(1);
|
|
10788
|
+
const directCandidates = pathname === "/" ? extensions.map((extension) => `index${extension}`) : isMarkdownFilePath(routePath, extensions) ? [routePath] : extensions.map((extension) => `${routePath}${extension}`);
|
|
10789
|
+
for (const relativePath of directCandidates) {
|
|
10790
|
+
const filePath = path$1.join(srcDir, relativePath);
|
|
10791
|
+
try {
|
|
10792
|
+
await fs$1.access(filePath);
|
|
10793
|
+
return filePath;
|
|
10794
|
+
} catch {}
|
|
10795
|
+
}
|
|
10796
|
+
for (const extension of extensions) {
|
|
10797
|
+
const indexPath = path$1.join(srcDir, routePath, `index${extension}`);
|
|
10737
10798
|
try {
|
|
10738
10799
|
await fs$1.access(indexPath);
|
|
10739
10800
|
return indexPath;
|
|
10740
|
-
} catch {
|
|
10741
|
-
return null;
|
|
10742
|
-
}
|
|
10801
|
+
} catch {}
|
|
10743
10802
|
}
|
|
10803
|
+
return null;
|
|
10744
10804
|
}
|
|
10745
10805
|
/**
|
|
10746
10806
|
* Inject Vite HMR client script into the HTML.
|
|
@@ -10802,8 +10862,8 @@ async function renderPage$1(filePath, options, navGroups, siteName, base, root)
|
|
|
10802
10862
|
transformedHtml = await transformAllPlugins(transformedHtml, {
|
|
10803
10863
|
tabs: true,
|
|
10804
10864
|
youtube: true,
|
|
10805
|
-
github:
|
|
10806
|
-
|
|
10865
|
+
github: options.embeds.github,
|
|
10866
|
+
openGraph: options.embeds.openGraph,
|
|
10807
10867
|
mermaid: true,
|
|
10808
10868
|
githubToken: process.env.GITHUB_TOKEN
|
|
10809
10869
|
});
|
|
@@ -10841,7 +10901,7 @@ function createDevServerMiddleware(options, root, cache) {
|
|
|
10841
10901
|
let routeUrl = url;
|
|
10842
10902
|
if (base !== "/" && routeUrl.startsWith(base)) routeUrl = "/" + routeUrl.slice(base.length);
|
|
10843
10903
|
if (shouldSkip(routeUrl)) return next();
|
|
10844
|
-
const filePath = await resolveMarkdownFile(routeUrl, srcDir);
|
|
10904
|
+
const filePath = await resolveMarkdownFile(routeUrl, srcDir, options.extensions);
|
|
10845
10905
|
if (!filePath) return next();
|
|
10846
10906
|
try {
|
|
10847
10907
|
const cached = cache.pages.get(filePath);
|
|
@@ -10853,7 +10913,7 @@ function createDevServerMiddleware(options, root, cache) {
|
|
|
10853
10913
|
}
|
|
10854
10914
|
if (!cache.siteName) cache.siteName = await resolveSiteName(options, root);
|
|
10855
10915
|
if (!cache.navGroups) {
|
|
10856
|
-
const markdownFiles = await collectMarkdownFiles$1(srcDir);
|
|
10916
|
+
const markdownFiles = await collectMarkdownFiles$1(srcDir, options.extensions);
|
|
10857
10917
|
cache.navGroups = resolveNavigationGroups(options.ssg.navigation, base, options.ssg.extension) ?? (options.ssg.theme?.sidebar.length ? buildThemeNavItems(options.ssg.theme.sidebar, base, options.ssg.extension) : buildNavItems(markdownFiles, srcDir, base, options.ssg.extension));
|
|
10858
10918
|
}
|
|
10859
10919
|
const html = await renderPage$1(filePath, options, cache.navGroups, cache.siteName, base, root);
|
|
@@ -10900,9 +10960,9 @@ function extractTitle(content, frontmatter) {
|
|
|
10900
10960
|
const match = content.match(/^#\s+(.+)$/m);
|
|
10901
10961
|
return match ? match[1].trim() : "";
|
|
10902
10962
|
}
|
|
10903
|
-
function getUrlPath(filePath, srcDir) {
|
|
10963
|
+
function getUrlPath(filePath, srcDir, extensions) {
|
|
10904
10964
|
let rel = path$1.relative(srcDir, filePath).replace(/\\/g, "/");
|
|
10905
|
-
rel = rel
|
|
10965
|
+
rel = stripMarkdownExtension(rel, extensions);
|
|
10906
10966
|
if (rel === "index") return "/";
|
|
10907
10967
|
if (rel.endsWith("/index")) rel = rel.slice(0, -6);
|
|
10908
10968
|
return "/" + rel;
|
|
@@ -10942,10 +11002,7 @@ function validatePage(page, options) {
|
|
|
10942
11002
|
}
|
|
10943
11003
|
async function collectPages(options, root) {
|
|
10944
11004
|
const srcDir = path$1.resolve(root, options.srcDir);
|
|
10945
|
-
const files = await glob(
|
|
10946
|
-
cwd: srcDir,
|
|
10947
|
-
absolute: true
|
|
10948
|
-
});
|
|
11005
|
+
const files = await glob(markdownGlobPattern(srcDir, options.extensions), { absolute: true });
|
|
10949
11006
|
const pages = [];
|
|
10950
11007
|
const generateOgImage = options.ogImage || options.ssg.generateOgImage;
|
|
10951
11008
|
for (const file of files.sort()) {
|
|
@@ -10956,7 +11013,7 @@ async function collectPages(options, root) {
|
|
|
10956
11013
|
const description = typeof frontmatter.description === "string" ? frontmatter.description : "";
|
|
10957
11014
|
const author = typeof frontmatter.author === "string" ? frontmatter.author : "";
|
|
10958
11015
|
const tags = Array.isArray(frontmatter.tags) ? frontmatter.tags : typeof frontmatter.tags === "string" ? [frontmatter.tags] : [];
|
|
10959
|
-
const urlPath = getUrlPath(file, srcDir);
|
|
11016
|
+
const urlPath = getUrlPath(file, srcDir, options.extensions);
|
|
10960
11017
|
const ogImageUrl = computeOgImageUrl(urlPath, options.base, options.ssg.siteUrl, generateOgImage, options.ssg.ogImage);
|
|
10961
11018
|
const page = {
|
|
10962
11019
|
path: path$1.relative(srcDir, file),
|
|
@@ -11605,7 +11662,11 @@ function sortDiagnostics(diagnostics) {
|
|
|
11605
11662
|
}
|
|
11606
11663
|
//#endregion
|
|
11607
11664
|
//#region src/lint-files.ts
|
|
11608
|
-
const DEFAULT_LINT_FILE_INCLUDE = [
|
|
11665
|
+
const DEFAULT_LINT_FILE_INCLUDE = [
|
|
11666
|
+
"**/*.md",
|
|
11667
|
+
"**/*.markdown",
|
|
11668
|
+
"**/*.mdx"
|
|
11669
|
+
];
|
|
11609
11670
|
const DEFAULT_LINT_FILE_EXCLUDE = [
|
|
11610
11671
|
"**/node_modules/**",
|
|
11611
11672
|
"**/.git/**",
|
|
@@ -12312,13 +12373,13 @@ function oxContent(options = {}) {
|
|
|
12312
12373
|
configureServer(devServer) {
|
|
12313
12374
|
devServer.middlewares.use(async (req, res, next) => {
|
|
12314
12375
|
const url = req.url;
|
|
12315
|
-
if (!url || !url.
|
|
12376
|
+
if (!url || !isMarkdownFilePath(url, resolvedOptions.extensions)) return next();
|
|
12316
12377
|
next();
|
|
12317
12378
|
});
|
|
12318
12379
|
},
|
|
12319
12380
|
resolveId(id) {
|
|
12320
12381
|
if (id.startsWith("virtual:ox-content/")) return "\0" + id;
|
|
12321
|
-
if (id.
|
|
12382
|
+
if (isMarkdownFilePath(id, resolvedOptions.extensions)) return id;
|
|
12322
12383
|
return null;
|
|
12323
12384
|
},
|
|
12324
12385
|
async load(id) {
|
|
@@ -12326,14 +12387,14 @@ function oxContent(options = {}) {
|
|
|
12326
12387
|
return null;
|
|
12327
12388
|
},
|
|
12328
12389
|
async transform(code, id) {
|
|
12329
|
-
if (!id.
|
|
12390
|
+
if (!isMarkdownFilePath(id, resolvedOptions.extensions)) return null;
|
|
12330
12391
|
return {
|
|
12331
12392
|
code: (await transformMarkdown(code, id, resolvedOptions)).code,
|
|
12332
12393
|
map: null
|
|
12333
12394
|
};
|
|
12334
12395
|
},
|
|
12335
12396
|
async handleHotUpdate({ file, server }) {
|
|
12336
|
-
if (file.
|
|
12397
|
+
if (isMarkdownFilePath(file, resolvedOptions.extensions)) {
|
|
12337
12398
|
server.ws.send({
|
|
12338
12399
|
type: "custom",
|
|
12339
12400
|
event: "ox-content:update",
|
|
@@ -12386,7 +12447,7 @@ function oxContent(options = {}) {
|
|
|
12386
12447
|
const srcDir = path$1.resolve(root, resolvedOptions.srcDir);
|
|
12387
12448
|
devServer.middlewares.use(createDevServerMiddleware(resolvedOptions, root, ssgDevCache));
|
|
12388
12449
|
devServer.watcher.on("add", (file) => {
|
|
12389
|
-
if (file.startsWith(srcDir) && file.
|
|
12450
|
+
if (file.startsWith(srcDir) && isMarkdownFilePath(file, resolvedOptions.extensions)) {
|
|
12390
12451
|
invalidateNavCache(ssgDevCache);
|
|
12391
12452
|
devServer.ws.send({
|
|
12392
12453
|
type: "custom",
|
|
@@ -12399,7 +12460,7 @@ function oxContent(options = {}) {
|
|
|
12399
12460
|
}
|
|
12400
12461
|
});
|
|
12401
12462
|
devServer.watcher.on("unlink", (file) => {
|
|
12402
|
-
if (file.startsWith(srcDir) && file.
|
|
12463
|
+
if (file.startsWith(srcDir) && isMarkdownFilePath(file, resolvedOptions.extensions)) {
|
|
12403
12464
|
invalidateNavCache(ssgDevCache);
|
|
12404
12465
|
devServer.ws.send({
|
|
12405
12466
|
type: "custom",
|
|
@@ -12412,7 +12473,7 @@ function oxContent(options = {}) {
|
|
|
12412
12473
|
}
|
|
12413
12474
|
});
|
|
12414
12475
|
devServer.watcher.on("change", (file) => {
|
|
12415
|
-
if (file.startsWith(srcDir) && file.
|
|
12476
|
+
if (file.startsWith(srcDir) && isMarkdownFilePath(file, resolvedOptions.extensions)) invalidatePageCache(ssgDevCache, file);
|
|
12416
12477
|
});
|
|
12417
12478
|
},
|
|
12418
12479
|
async closeBundle() {
|
|
@@ -12452,7 +12513,7 @@ function oxContent(options = {}) {
|
|
|
12452
12513
|
const root = config?.root || process.cwd();
|
|
12453
12514
|
const srcDir = path$1.resolve(root, resolvedOptions.srcDir);
|
|
12454
12515
|
try {
|
|
12455
|
-
searchIndexJson = await buildSearchIndex(srcDir, resolvedOptions.base);
|
|
12516
|
+
searchIndexJson = await buildSearchIndex(srcDir, resolvedOptions.base, resolvedOptions.extensions);
|
|
12456
12517
|
console.log("[ox-content] Search index built");
|
|
12457
12518
|
} catch (err) {
|
|
12458
12519
|
console.warn("[ox-content] Failed to build search index:", err);
|
|
@@ -12483,6 +12544,7 @@ function resolveOptions(options) {
|
|
|
12483
12544
|
srcDir: options.srcDir ?? "content",
|
|
12484
12545
|
outDir: options.outDir ?? "dist",
|
|
12485
12546
|
base: options.base ?? "/",
|
|
12547
|
+
extensions: normalizeMarkdownExtensions(options.extensions),
|
|
12486
12548
|
ssg: resolveSsgOptions(options.ssg),
|
|
12487
12549
|
gfm: options.gfm ?? true,
|
|
12488
12550
|
footnotes: options.footnotes ?? true,
|
|
@@ -12503,9 +12565,25 @@ function resolveOptions(options) {
|
|
|
12503
12565
|
docs: resolveDocsOptions(options.docs),
|
|
12504
12566
|
search: resolveSearchOptions(options.search),
|
|
12505
12567
|
ogViewer: options.ogViewer ?? true,
|
|
12568
|
+
embeds: resolveBuiltinEmbedOptions(options.embeds),
|
|
12506
12569
|
i18n: resolveI18nOptions(options.i18n)
|
|
12507
12570
|
};
|
|
12508
12571
|
}
|
|
12572
|
+
function resolveBuiltinEmbedOptions(options) {
|
|
12573
|
+
if (options === false) return {
|
|
12574
|
+
github: false,
|
|
12575
|
+
openGraph: false
|
|
12576
|
+
};
|
|
12577
|
+
return {
|
|
12578
|
+
github: resolveSingleEmbedOptions(options?.github),
|
|
12579
|
+
openGraph: resolveSingleEmbedOptions(options?.openGraph)
|
|
12580
|
+
};
|
|
12581
|
+
}
|
|
12582
|
+
function resolveSingleEmbedOptions(options) {
|
|
12583
|
+
if (options === false) return false;
|
|
12584
|
+
if (options === true || options === void 0) return {};
|
|
12585
|
+
return options;
|
|
12586
|
+
}
|
|
12509
12587
|
function resolveCodeAnnotationsOptions(options) {
|
|
12510
12588
|
if (!options) return {
|
|
12511
12589
|
enabled: false,
|
|
@@ -12578,6 +12656,6 @@ function normalizeRuntimeBase(base) {
|
|
|
12578
12656
|
return withLeading.endsWith("/") ? withLeading : `${withLeading}/`;
|
|
12579
12657
|
}
|
|
12580
12658
|
//#endregion
|
|
12581
|
-
export { DEFAULT_HTML_TEMPLATE, DefaultTheme, Fragment, buildSearchIndex, buildSsg, clearRenderContext, collectGitHubRepos, collectOgpUrls, convertVitePressNav, convertVitePressSidebar, createI18nPlugin, createMarkdownEnvironment, createTheme, defaultTheme, defineTheme, each, extractDocs, extractIslandInfo, extractVideoId, fetchOgpData, fetchRepoData, fromVitePressConfig, generateFrontmatterTypes, generateHydrationScript, generateMarkdown, generateOgImages, generateTabsCSS, generateTypes, generateVirtualModule, generateVitePressMigrationConfig, hasIslands, inferType, jsx, jsxs, lintMarkdown, lintMarkdownAsync, lintMarkdownFile, lintMarkdownFiles, mergeThemes, mermaidClientScript, normalizeVitePressFrontmatter, oxContent, prefetchGitHubRepos, prefetchOgpData, raw, renderAllPages, renderPage, renderToString, resolveDocsOptions, resolveI18nOptions, resolveOgImageOptions, resolveSearchOptions, resolveSsgOptions, resolveTheme, setRenderContext, shouldLintMarkdownFile, transformAllPlugins, transformGitHub, transformIslands, transformMarkdown, transformMermaidStatic, transformOgp, transformTabs, transformYouTube, useIsActive, useNav, usePageProps, useRenderContext, useSiteConfig, when, writeDocs, writeSearchIndex };
|
|
12659
|
+
export { DEFAULT_HTML_TEMPLATE, DEFAULT_MARKDOWN_EXTENSIONS, DefaultTheme, Fragment, buildSearchIndex, buildSsg, clearRenderContext, collectGitHubRepos, collectGitHubSources, collectOgpUrls, convertVitePressNav, convertVitePressSidebar, createI18nPlugin, createMarkdownEnvironment, createTheme, defaultTheme, defineTheme, each, extractDocs, extractIslandInfo, extractVideoId, fetchGitHubSource, fetchOgpData, fetchRepoData, fromVitePressConfig, generateFrontmatterTypes, generateHydrationScript, generateMarkdown, generateOgImages, generateTabsCSS, generateTypes, generateVirtualModule, generateVitePressMigrationConfig, hasIslands, inferType, isMarkdownFilePath, jsx, jsxs, lintMarkdown, lintMarkdownAsync, lintMarkdownFile, lintMarkdownFiles, mergeThemes, mermaidClientScript, normalizeMarkdownExtensions, normalizeVitePressFrontmatter, oxContent, parseGitHubLineRange, parseGitHubPermalink, prefetchGitHubRepos, prefetchGitHubSources, prefetchOgpData, raw, renderAllPages, renderPage, renderToString, resolveBuiltinEmbedOptions, resolveDocsOptions, resolveI18nOptions, resolveOgImageOptions, resolveSearchOptions, resolveSsgOptions, resolveTheme, setRenderContext, shouldLintMarkdownFile, stripMarkdownExtension, transformAllPlugins, transformGitHub, transformIslands, transformMarkdown, transformMermaidStatic, transformOgp, transformTabs, transformYouTube, useIsActive, useNav, usePageProps, useRenderContext, useSiteConfig, when, writeDocs, writeSearchIndex };
|
|
12582
12660
|
|
|
12583
12661
|
//# sourceMappingURL=index.mjs.map
|