@ox-content/vite-plugin 2.87.0 → 2.88.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 CHANGED
@@ -2,6 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_vitepress = require("./vitepress.cjs");
3
3
  const require_interop = require("./interop.cjs");
4
4
  const require_tabs = require("./tabs.cjs");
5
+ const require_jsx_html = require("./jsx-html.cjs");
5
6
  let path = require("path");
6
7
  path = require_vitepress.__toESM(path, 1);
7
8
  let unified = require("unified");
@@ -635,8 +636,8 @@ function assetRecord(src, media) {
635
636
  //#region src/plugins/twitter/render.ts
636
637
  function renderFetchedTweet(permalink, data, assets, options) {
637
638
  const profile = `https://x.com/${encodeURIComponent(data.user.screen_name)}`;
638
- const author = escapeHtml$3(data.user.name);
639
- const handle = escapeHtml$3(data.user.screen_name);
639
+ const author = escapeHtml$2(data.user.name);
640
+ const handle = escapeHtml$2(data.user.screen_name);
640
641
  const avatar = assets.avatar ? `<img class="ox-tweet__avatar" src="${escapeAttribute(assets.avatar)}" alt="" width="48" height="48" loading="lazy" decoding="async">` : "";
641
642
  const media = renderMedia(assets);
642
643
  const footer = renderFooter(permalink, data.created_at, options.lang);
@@ -666,7 +667,7 @@ function renderTweetText(data) {
666
667
  if (entity.kind === "url") {
667
668
  const href = entity.expanded_url ?? entity.url;
668
669
  const label = entity.display_url ?? href;
669
- output += `<a href="${escapeAttribute(href)}" target="_blank" rel="noopener noreferrer">${escapeHtml$3(label)}</a>`;
670
+ output += `<a href="${escapeAttribute(href)}" target="_blank" rel="noopener noreferrer">${escapeHtml$2(label)}</a>`;
670
671
  }
671
672
  cursor = entityEnd;
672
673
  }
@@ -710,15 +711,15 @@ function renderFooter(permalink, createdAt, lang) {
710
711
  timeZone: "UTC"
711
712
  }).format(date);
712
713
  }
713
- return `<footer class="ox-tweet__footer"><a class="ox-tweet__permalink" href="${escapeAttribute(permalink)}" target="_blank" rel="noopener noreferrer"><time datetime="${iso}">${escapeHtml$3(label)}</time></a></footer>`;
714
+ return `<footer class="ox-tweet__footer"><a class="ox-tweet__permalink" href="${escapeAttribute(permalink)}" target="_blank" rel="noopener noreferrer"><time datetime="${iso}">${escapeHtml$2(label)}</time></a></footer>`;
714
715
  }
715
716
  function escapeText(value) {
716
- return escapeHtml$3(value).replaceAll("\n", "<br>");
717
+ return escapeHtml$2(value).replaceAll("\n", "<br>");
717
718
  }
718
719
  function escapeAttribute(value) {
719
- return escapeHtml$3(value).replaceAll("`", "&#96;");
720
+ return escapeHtml$2(value).replaceAll("`", "&#96;");
720
721
  }
721
- function escapeHtml$3(value) {
722
+ function escapeHtml$2(value) {
722
723
  return value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll("\"", "&quot;").replaceAll("'", "&#39;");
723
724
  }
724
725
  //#endregion
@@ -2547,7 +2548,7 @@ function formatChromiumUnavailableDetail(err) {
2547
2548
  /**
2548
2549
  * Escapes HTML special characters.
2549
2550
  */
2550
- function escapeHtml$2(str) {
2551
+ function escapeHtml$1(str) {
2551
2552
  return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
2552
2553
  }
2553
2554
  function normalizeBrandValue(str) {
@@ -2610,12 +2611,12 @@ function getDefaultTemplate() {
2610
2611
  const isBrandCard = normalizeBrandValue(title) === normalizeBrandValue(rawBrand);
2611
2612
  const heroTitle = isBrandCard ? "High-performance Markdown toolkit" : title;
2612
2613
  const heroDescription = isBrandCard ? "Rust-powered docs and high-performance Markdown tooling." : description && description.trim().length > 0 ? description : "Rust-powered docs and Markdown tooling.";
2613
- const descriptionHtml = heroDescription.trim().length > 0 ? `<p style="max-width:760px;font-size:28px;color:#93a4c3;line-height:1.45;margin:0;overflow:hidden;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;">${escapeHtml$2(heroDescription)}</p>` : "";
2614
+ const descriptionHtml = heroDescription.trim().length > 0 ? `<p style="max-width:760px;font-size:28px;color:#93a4c3;line-height:1.45;margin:0;overflow:hidden;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;">${escapeHtml$1(heroDescription)}</p>` : "";
2614
2615
  return `<div style="width:100%;height:100%;position:relative;overflow:hidden;box-sizing:border-box;padding:56px 64px 52px;background:#0b1220;font-family:'IBM Plex Sans','Avenir Next','Segoe UI',system-ui,sans-serif;color:#eff6ff;border:1px solid #223252;border-top:4px solid #4f6fae;">
2615
2616
  <div style="position:relative;z-index:1;display:flex;flex-direction:column;height:100%;">
2616
2617
  <div style="display:flex;align-items:flex-start;">${renderWordmarkSvg()}</div>
2617
2618
  <div style="display:flex;flex-direction:column;justify-content:center;gap:24px;max-width:860px;flex:1;padding:22px 0 0;">
2618
- <h1 style="font-size:78px;font-weight:700;color:#eff6ff;line-height:1.02;letter-spacing:-0.055em;margin:0;overflow:hidden;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;">${escapeHtml$2(heroTitle)}</h1>
2619
+ <h1 style="font-size:78px;font-weight:700;color:#eff6ff;line-height:1.02;letter-spacing:-0.055em;margin:0;overflow:hidden;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;">${escapeHtml$1(heroTitle)}</h1>
2619
2620
  ${descriptionHtml}
2620
2621
  </div>
2621
2622
  </div>
@@ -3582,10 +3583,22 @@ async function createBuildSsgContext(options, root, srcDir, outDir, markdownFile
3582
3583
  base,
3583
3584
  navItems: resolveNavigationGroups(ssgOptions.navigation, base, ssgOptions.extension) ?? (ssgOptions.theme?.sidebar.length ? buildThemeNavItems(ssgOptions.theme.sidebar, base, ssgOptions.extension) : buildNavItems(markdownFiles, srcDir, base, ssgOptions.extension)),
3584
3585
  siteName: await resolveSiteName$1(root, ssgOptions),
3585
- shouldGenerateOgImages: (options.ogImage || ssgOptions.generateOgImage) && !ssgOptions.bare,
3586
+ shouldGenerateOgImages: shouldGenerateOgImages(options),
3586
3587
  napi: ssgOptions.lastUpdated ? await require_vitepress.importNapiModule() : void 0
3587
3588
  };
3588
3589
  }
3590
+ /**
3591
+ * Whether this build emits one Open Graph image per page.
3592
+ *
3593
+ * `ssg.bare` deliberately does not turn this off. Bare mode only drops the
3594
+ * generated page shell, and bringing your own shell is exactly the case where
3595
+ * per-page OG images are still wanted — the images are written to the output
3596
+ * tree and the consumer injects the `<meta>` tags itself. Nothing in the bare
3597
+ * HTML references them, because bare output has no `<head>` to put them in.
3598
+ */
3599
+ function shouldGenerateOgImages(options) {
3600
+ return options.ogImage || options.ssg.generateOgImage;
3601
+ }
3589
3602
  async function resolveSiteName$1(root, ssgOptions) {
3590
3603
  if (ssgOptions.siteName) return ssgOptions.siteName;
3591
3604
  try {
@@ -5740,195 +5753,6 @@ function createEmptyLintResult() {
5740
5753
  };
5741
5754
  }
5742
5755
  //#endregion
5743
- //#region src/jsx-runtime.ts
5744
- /**
5745
- * Custom JSX Runtime for Static HTML Generation
5746
- *
5747
- * This module provides a JSX runtime that outputs static HTML strings.
5748
- * No React, no hydration, no client-side JavaScript - just pure HTML.
5749
- *
5750
- * @example
5751
- * ```tsx
5752
- * // tsconfig.json or vite.config.ts
5753
- * {
5754
- * "compilerOptions": {
5755
- * "jsx": "react-jsx",
5756
- * "jsxImportSource": "@ox-content/vite-plugin"
5757
- * }
5758
- * }
5759
- *
5760
- * // MyComponent.tsx
5761
- * export function Hero({ title }: { title: string }) {
5762
- * return (
5763
- * <section class="hero">
5764
- * <h1>{title}</h1>
5765
- * </section>
5766
- * );
5767
- * }
5768
- * ```
5769
- */
5770
- const VOID_ELEMENTS = /* @__PURE__ */ new Set([
5771
- "area",
5772
- "base",
5773
- "br",
5774
- "col",
5775
- "embed",
5776
- "hr",
5777
- "img",
5778
- "input",
5779
- "link",
5780
- "meta",
5781
- "param",
5782
- "source",
5783
- "track",
5784
- "wbr"
5785
- ]);
5786
- const BOOLEAN_ATTRS = /* @__PURE__ */ new Set([
5787
- "allowfullscreen",
5788
- "async",
5789
- "autofocus",
5790
- "autoplay",
5791
- "checked",
5792
- "controls",
5793
- "default",
5794
- "defer",
5795
- "disabled",
5796
- "formnovalidate",
5797
- "hidden",
5798
- "inert",
5799
- "ismap",
5800
- "itemscope",
5801
- "loop",
5802
- "multiple",
5803
- "muted",
5804
- "nomodule",
5805
- "novalidate",
5806
- "open",
5807
- "playsinline",
5808
- "readonly",
5809
- "required",
5810
- "reversed",
5811
- "selected"
5812
- ]);
5813
- /**
5814
- * Escapes HTML special characters to prevent XSS.
5815
- */
5816
- function escapeHtml$1(str) {
5817
- return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#x27;");
5818
- }
5819
- /**
5820
- * Converts a camelCase attribute name to kebab-case for HTML.
5821
- * Special handling for data-* and aria-* attributes.
5822
- */
5823
- function toHtmlAttr(name) {
5824
- if (name === "className") return "class";
5825
- if (name === "htmlFor") return "for";
5826
- if (name.startsWith("data") || name.startsWith("aria")) return name.replace(/([A-Z])/g, "-$1").toLowerCase();
5827
- return name;
5828
- }
5829
- /**
5830
- * Renders an attribute value to a string.
5831
- */
5832
- function renderAttr(name, value) {
5833
- const htmlName = toHtmlAttr(name);
5834
- if (value === void 0 || value === null || value === false) return "";
5835
- if (BOOLEAN_ATTRS.has(htmlName)) return value ? ` ${htmlName}` : "";
5836
- if (name === "style" && typeof value === "object") return ` style="${escapeHtml$1(Object.entries(value).map(([k, v]) => {
5837
- return `${k.replace(/([A-Z])/g, "-$1").toLowerCase()}:${v}`;
5838
- }).join(";"))}"`;
5839
- return ` ${htmlName}="${escapeHtml$1(String(value))}"`;
5840
- }
5841
- /**
5842
- * Renders children to HTML string.
5843
- */
5844
- function renderChildren(children) {
5845
- if (children === null || children === void 0 || children === false) return "";
5846
- if (children === true) return "";
5847
- if (typeof children === "string") return escapeHtml$1(children);
5848
- if (typeof children === "number") return String(children);
5849
- if (Array.isArray(children)) return children.map(renderChildren).join("");
5850
- if (typeof children === "object" && "__html" in children) return children.__html;
5851
- return "";
5852
- }
5853
- /**
5854
- * Creates a JSX element.
5855
- * This is the core function called by the JSX transform.
5856
- */
5857
- function jsx(type, props, _key) {
5858
- const { children, ...restProps } = props;
5859
- if (typeof type === "function") return type({
5860
- ...restProps,
5861
- children
5862
- });
5863
- const tag = type;
5864
- let html = `<${tag}`;
5865
- for (const [name, value] of Object.entries(restProps)) {
5866
- if (name === "key" || name === "ref") continue;
5867
- html += renderAttr(name, value);
5868
- }
5869
- if (VOID_ELEMENTS.has(tag)) {
5870
- html += " />";
5871
- return { __html: html };
5872
- }
5873
- html += ">";
5874
- if (children !== void 0) html += renderChildren(children);
5875
- html += `</${tag}>`;
5876
- return { __html: html };
5877
- }
5878
- /**
5879
- * Creates a JSX element with static children.
5880
- * Called by the JSX transform for elements with multiple children.
5881
- */
5882
- function jsxs(type, props, key) {
5883
- return jsx(type, props, key);
5884
- }
5885
- /**
5886
- * Fragment component - renders children without a wrapper element.
5887
- */
5888
- function Fragment({ children }) {
5889
- return { __html: renderChildren(children) };
5890
- }
5891
- /**
5892
- * Renders a JSX node to an HTML string.
5893
- */
5894
- function renderToString(node) {
5895
- return node.__html;
5896
- }
5897
- /**
5898
- * Creates raw HTML without escaping.
5899
- * Use with caution - only for trusted content.
5900
- *
5901
- * @example
5902
- * ```tsx
5903
- * <div>{raw('<strong>Bold</strong>')}</div>
5904
- * ```
5905
- */
5906
- function raw(html) {
5907
- return { __html: html };
5908
- }
5909
- /**
5910
- * Conditionally renders content.
5911
- *
5912
- * @example
5913
- * ```tsx
5914
- * {when(isLoggedIn, <UserMenu />)}
5915
- * ```
5916
- */
5917
- function when(condition, content) {
5918
- return condition ? content : { __html: "" };
5919
- }
5920
- /**
5921
- * Maps over an array and renders each item.
5922
- *
5923
- * @example
5924
- * ```tsx
5925
- * {each(items, (item) => <li>{item.name}</li>)}
5926
- * ```
5927
- */
5928
- function each(items, render) {
5929
- return { __html: items.map((item, i) => render(item, i).__html).join("") };
5930
- }
5931
- //#endregion
5932
5756
  //#region src/page-context.ts
5933
5757
  var page_context_exports = /* @__PURE__ */ require_vitepress.__exportAll({
5934
5758
  clearRenderContext: () => clearRenderContext,
@@ -6166,7 +5990,8 @@ function renderPage(page, options) {
6166
5990
  }
6167
5991
  });
6168
5992
  try {
6169
- const html = renderToString(theme({ children: raw(page.html) }));
5993
+ const result = theme({ children: require_jsx_html.raw(page.html) });
5994
+ const html = require_jsx_html.renderToString(result);
6170
5995
  if (!html.trimStart().toLowerCase().startsWith("<!doctype")) return `<!DOCTYPE html>\n${html}`;
6171
5996
  return html;
6172
5997
  } finally {
@@ -6850,7 +6675,7 @@ exports.DEFAULT_HTML_TEMPLATE = DEFAULT_HTML_TEMPLATE;
6850
6675
  exports.DEFAULT_MARKDOWN_EXTENSIONS = DEFAULT_MARKDOWN_EXTENSIONS;
6851
6676
  exports.DefaultTheme = DefaultTheme;
6852
6677
  exports.DocsTestRunError = DocsTestRunError;
6853
- exports.Fragment = Fragment;
6678
+ exports.Fragment = require_jsx_html.Fragment;
6854
6679
  exports.IncrementalMarkdownParser = IncrementalMarkdownParser;
6855
6680
  exports.IncrementalMarkdownRenderer = IncrementalMarkdownRenderer;
6856
6681
  exports.buildCollectionManifest = buildCollectionManifest;
@@ -6873,7 +6698,7 @@ exports.defaultTheme = require_vitepress.defaultTheme;
6873
6698
  exports.defineCollection = defineCollection;
6874
6699
  exports.defineCollections = defineCollections;
6875
6700
  exports.defineTheme = require_vitepress.defineTheme;
6876
- exports.each = each;
6701
+ exports.each = require_jsx_html.each;
6877
6702
  exports.escapeSvelteMarkup = escapeSvelteMarkup;
6878
6703
  exports.extractCodeBlocks = extractCodeBlocks;
6879
6704
  exports.extractDocs = extractDocs;
@@ -6896,8 +6721,8 @@ exports.generateVitePressMigrationConfig = require_vitepress.generateVitePressMi
6896
6721
  exports.hasIslands = hasIslands;
6897
6722
  exports.inferType = inferType;
6898
6723
  exports.isMarkdownFilePath = isMarkdownFilePath;
6899
- exports.jsx = jsx;
6900
- exports.jsxs = jsxs;
6724
+ exports.jsx = require_jsx_html.jsx;
6725
+ exports.jsxs = require_jsx_html.jsxs;
6901
6726
  exports.lintCodeBlocks = lintCodeBlocks;
6902
6727
  exports.lintMarkdown = lintMarkdown;
6903
6728
  exports.lintMarkdownAsync = lintMarkdownAsync;
@@ -6913,7 +6738,7 @@ exports.parseGitHubPermalink = parseGitHubPermalink;
6913
6738
  exports.prefetchGitHubRepos = prefetchGitHubRepos;
6914
6739
  exports.prefetchGitHubSources = prefetchGitHubSources;
6915
6740
  exports.prefetchOgpData = prefetchOgpData;
6916
- exports.raw = raw;
6741
+ exports.raw = require_jsx_html.raw;
6917
6742
  exports.renderAllPages = renderAllPages;
6918
6743
  exports.renderHtmlToFrameworkCode = renderHtmlToFrameworkCode;
6919
6744
  exports.renderHtmlToReactComponent = renderHtmlToReactComponent;
@@ -6923,7 +6748,7 @@ exports.renderHtmlToVueComponent = renderHtmlToVueComponent;
6923
6748
  exports.renderHtmlToVueH = renderHtmlToVueH;
6924
6749
  exports.renderMarkdownStream = renderMarkdownStream;
6925
6750
  exports.renderPage = renderPage;
6926
- exports.renderToString = renderToString;
6751
+ exports.renderToString = require_jsx_html.renderToString;
6927
6752
  exports.resolveBuiltinEmbedOptions = resolveBuiltinEmbedOptions;
6928
6753
  exports.resolveCollectionsOptions = resolveCollectionsOptions;
6929
6754
  exports.resolveDocsOptions = resolveDocsOptions;
@@ -6950,7 +6775,7 @@ exports.useNav = useNav;
6950
6775
  exports.usePageProps = usePageProps;
6951
6776
  exports.useRenderContext = useRenderContext;
6952
6777
  exports.useSiteConfig = useSiteConfig;
6953
- exports.when = when;
6778
+ exports.when = require_jsx_html.when;
6954
6779
  exports.writeDocs = writeDocs;
6955
6780
  exports.writeDocsTestFiles = writeDocsTestFiles;
6956
6781
  exports.writeSearchIndex = writeSearchIndex;