@ox-content/vite-plugin 3.0.0-alpha.4 → 3.0.0-alpha.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/dist/index.cjs +39 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +97 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +97 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +38 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -4138,6 +4138,22 @@ function stripLocalePrefix(sitePath, locales) {
|
|
|
4138
4138
|
return normalized;
|
|
4139
4139
|
}
|
|
4140
4140
|
//#endregion
|
|
4141
|
+
//#region src/page-head.ts
|
|
4142
|
+
/** Resolve descriptors to escaped `<head>` markup. Build-time only. */
|
|
4143
|
+
function renderHead(input) {
|
|
4144
|
+
return require_vitepress.importNapiModuleSync().renderHead(JSON.stringify(input));
|
|
4145
|
+
}
|
|
4146
|
+
function resolveHeadValidation(value) {
|
|
4147
|
+
if (value === "warn" || value === "strict") return value;
|
|
4148
|
+
return false;
|
|
4149
|
+
}
|
|
4150
|
+
function reportHeadDiagnostics(diagnostics, validation) {
|
|
4151
|
+
if (!validation || diagnostics.length === 0) return;
|
|
4152
|
+
const fatal = diagnostics.filter((item) => item.strict);
|
|
4153
|
+
if (validation === "strict" && fatal.length > 0) throw new Error(`[ox-content] ${fatal[0].message}`);
|
|
4154
|
+
if (validation === "warn") for (const item of diagnostics) console.warn(`[ox-content] ${item.message}`);
|
|
4155
|
+
}
|
|
4156
|
+
//#endregion
|
|
4141
4157
|
//#region src/page-context.ts
|
|
4142
4158
|
var page_context_exports = /* @__PURE__ */ require_vitepress.__exportAll({
|
|
4143
4159
|
clearRenderContext: () => clearRenderContext,
|
|
@@ -9257,6 +9273,7 @@ function resolveSsgOptions(ssg) {
|
|
|
9257
9273
|
pagination: false,
|
|
9258
9274
|
breadcrumbs: false,
|
|
9259
9275
|
jsonLd: false,
|
|
9276
|
+
headValidation: false,
|
|
9260
9277
|
readerChrome: false,
|
|
9261
9278
|
localeSwitcher: false,
|
|
9262
9279
|
a11y: false,
|
|
@@ -9277,6 +9294,7 @@ function resolveSsgOptions(ssg) {
|
|
|
9277
9294
|
pagination: false,
|
|
9278
9295
|
breadcrumbs: false,
|
|
9279
9296
|
jsonLd: false,
|
|
9297
|
+
headValidation: false,
|
|
9280
9298
|
readerChrome: false,
|
|
9281
9299
|
localeSwitcher: false,
|
|
9282
9300
|
a11y: false,
|
|
@@ -9305,6 +9323,7 @@ function resolveSsgOptions(ssg) {
|
|
|
9305
9323
|
pagination: resolvePaginationOption(ssg.pagination),
|
|
9306
9324
|
breadcrumbs: resolvePaginationOption(ssg.breadcrumbs),
|
|
9307
9325
|
jsonLd: resolveJsonLdOption(ssg.jsonLd),
|
|
9326
|
+
headValidation: resolveHeadValidation(ssg.headValidation),
|
|
9308
9327
|
readerChrome: resolveReaderChromeOption(ssg.readerChrome),
|
|
9309
9328
|
localeSwitcher: resolveLocaleSwitcherOption(ssg.localeSwitcher),
|
|
9310
9329
|
a11y: resolveA11yOption(ssg.a11y),
|
|
@@ -9336,7 +9355,9 @@ function resolveJsonLdOption(value) {
|
|
|
9336
9355
|
const publisher = resolveJsonLdPublisher(value.publisher);
|
|
9337
9356
|
return {
|
|
9338
9357
|
breadcrumbs: value.breadcrumbs !== false,
|
|
9339
|
-
...publisher ? { publisher } : {}
|
|
9358
|
+
...publisher ? { publisher } : {},
|
|
9359
|
+
...value.type ? { type: value.type } : {},
|
|
9360
|
+
...value.graph ? { graph: value.graph } : {}
|
|
9340
9361
|
};
|
|
9341
9362
|
}
|
|
9342
9363
|
return false;
|
|
@@ -9479,7 +9500,7 @@ function localeCodesFor(locales) {
|
|
|
9479
9500
|
async function generateHtmlPage(pageData, navGroups, siteName, base, ogImage, theme, locale, availableLocales, pagination = false, readerChrome = false, breadcrumbs = false, localeSwitcher = false, localePaths, a11y = false, team = {
|
|
9480
9501
|
enabled: false,
|
|
9481
9502
|
members: []
|
|
9482
|
-
}, pageChrome = false, breadcrumbRootHref, jsonLd = false, siteUrl) {
|
|
9503
|
+
}, pageChrome = false, breadcrumbRootHref, jsonLd = false, siteUrl, headValidation = false) {
|
|
9483
9504
|
const mod = await require_vitepress.importNapiModule();
|
|
9484
9505
|
const tocForRust = pageData.toc.map(toRustTocEntry);
|
|
9485
9506
|
const navGroupsForRust = convertNavGroupsForRust(navGroups);
|
|
@@ -9515,7 +9536,7 @@ async function generateHtmlPage(pageData, navGroups, siteName, base, ogImage, th
|
|
|
9515
9536
|
linkText: f.linkText
|
|
9516
9537
|
}))
|
|
9517
9538
|
} : void 0;
|
|
9518
|
-
|
|
9539
|
+
const result = mod.generateSsgHtml({
|
|
9519
9540
|
title: pageData.title,
|
|
9520
9541
|
description: pageData.description,
|
|
9521
9542
|
content: pageData.content,
|
|
@@ -9528,12 +9549,16 @@ async function generateHtmlPage(pageData, navGroups, siteName, base, ogImage, th
|
|
|
9528
9549
|
next: pageData.next,
|
|
9529
9550
|
breadcrumbs: pageData.breadcrumbs,
|
|
9530
9551
|
layout: typeof pageData.frontmatter.layout === "string" ? pageData.frontmatter.layout : void 0,
|
|
9531
|
-
chrome: pageData.chrome
|
|
9552
|
+
chrome: pageData.chrome,
|
|
9553
|
+
robots: typeof pageData.frontmatter.robots === "string" ? pageData.frontmatter.robots : void 0,
|
|
9554
|
+
canonical: typeof pageData.frontmatter.canonical === "string" ? pageData.frontmatter.canonical : void 0
|
|
9532
9555
|
}, navGroupsForRust, {
|
|
9533
9556
|
siteName,
|
|
9534
9557
|
base,
|
|
9535
9558
|
breadcrumbRootHref,
|
|
9536
9559
|
ogImage,
|
|
9560
|
+
siteUrl,
|
|
9561
|
+
headValidation: headValidation || void 0,
|
|
9537
9562
|
theme: themeForRust,
|
|
9538
9563
|
locale,
|
|
9539
9564
|
availableLocales: availableLocales ? toRustLocales(availableLocales) : void 0,
|
|
@@ -9552,9 +9577,14 @@ async function generateHtmlPage(pageData, navGroups, siteName, base, ogImage, th
|
|
|
9552
9577
|
jsonLd: jsonLd ? {
|
|
9553
9578
|
breadcrumbs: jsonLd.breadcrumbs,
|
|
9554
9579
|
publisher: jsonLd.publisher,
|
|
9555
|
-
siteUrl
|
|
9580
|
+
siteUrl,
|
|
9581
|
+
pageType: jsonLd.type,
|
|
9582
|
+
graph: jsonLd.graph?.map((node) => JSON.stringify(node))
|
|
9556
9583
|
} : void 0
|
|
9557
9584
|
});
|
|
9585
|
+
const html = typeof result === "string" ? result : result.html;
|
|
9586
|
+
reportHeadDiagnostics(typeof result === "string" ? [] : result.diagnostics ?? [], headValidation);
|
|
9587
|
+
return html;
|
|
9558
9588
|
}
|
|
9559
9589
|
async function externalizeSharedPageAssets(pages, outDir, base) {
|
|
9560
9590
|
const optimized = (await require_vitepress.importNapiModule()).externalizeSsgAssets(pages, outDir, base);
|
|
@@ -9997,7 +10027,7 @@ async function renderSsgPage(context, pageResult, collected, allPageResults) {
|
|
|
9997
10027
|
return generateHtmlPage(pageData, navItems, context.siteName, context.base, pageOgImage, theme, locale, i18n ? i18n.locales : void 0, context.ssgOptions.pagination, context.ssgOptions.readerChrome, context.ssgOptions.breadcrumbs, context.ssgOptions.localeSwitcher, localePaths, context.ssgOptions.a11y, context.ssgOptions.team ?? {
|
|
9998
10028
|
enabled: false,
|
|
9999
10029
|
members: []
|
|
10000
|
-
}, context.ssgOptions.pageChrome, versionNavigation?.root.href, context.ssgOptions.jsonLd, context.ssgOptions.siteUrl);
|
|
10030
|
+
}, context.ssgOptions.pageChrome, versionNavigation?.root.href, context.ssgOptions.jsonLd, context.ssgOptions.siteUrl, context.ssgOptions.headValidation);
|
|
10001
10031
|
}
|
|
10002
10032
|
function rewritePagerOverride(pager, context) {
|
|
10003
10033
|
return pager?.href ? {
|
|
@@ -10458,7 +10488,7 @@ async function renderPage$1(filePath, options, navGroups, siteName, base, root,
|
|
|
10458
10488
|
let html = await generateHtmlPage(pageData, localizedNav, siteName, base, options.ssg.ogImage, theme, locale, i18n ? i18n.locales : void 0, options.ssg.pagination, options.ssg.readerChrome, options.ssg.breadcrumbs, options.ssg.localeSwitcher, localePaths, options.ssg.a11y, options.ssg.team ?? {
|
|
10459
10489
|
enabled: false,
|
|
10460
10490
|
members: []
|
|
10461
|
-
}, options.ssg.pageChrome, void 0, options.ssg.jsonLd, options.ssg.siteUrl);
|
|
10491
|
+
}, options.ssg.pageChrome, void 0, options.ssg.jsonLd, options.ssg.siteUrl, options.ssg.headValidation);
|
|
10462
10492
|
html = injectViteHmrClient(html);
|
|
10463
10493
|
return html;
|
|
10464
10494
|
}
|
|
@@ -13080,6 +13110,7 @@ exports.prefetchOgpData = prefetchOgpData;
|
|
|
13080
13110
|
exports.raw = require_jsx_html.raw;
|
|
13081
13111
|
exports.readingTimeMinutes = readingTimeMinutes;
|
|
13082
13112
|
exports.renderAllPages = renderAllPages;
|
|
13113
|
+
exports.renderHead = renderHead;
|
|
13083
13114
|
exports.renderHtmlToFrameworkCode = renderHtmlToFrameworkCode;
|
|
13084
13115
|
exports.renderHtmlToReactComponent = renderHtmlToReactComponent;
|
|
13085
13116
|
exports.renderHtmlToReactCreateElement = renderHtmlToReactCreateElement;
|
|
@@ -13102,6 +13133,7 @@ exports.resolveDocsOptions = resolveDocsOptions;
|
|
|
13102
13133
|
exports.resolveDocumentComponentImports = resolveDocumentComponentImports;
|
|
13103
13134
|
exports.resolveFeedsOptions = resolveFeedsOptions;
|
|
13104
13135
|
exports.resolveFileTreeOptions = resolveFileTreeOptions;
|
|
13136
|
+
exports.resolveHeadValidation = resolveHeadValidation;
|
|
13105
13137
|
exports.resolveHeaderNavItems = require_vitepress.resolveHeaderNavItems;
|
|
13106
13138
|
exports.resolveI18nOptions = resolveI18nOptions;
|
|
13107
13139
|
exports.resolveImageOptions = resolveImageOptions;
|