@ox-content/vite-plugin 2.75.1 → 2.79.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
@@ -581,6 +581,8 @@ async function transformMarkdown(source, filePath, options, ssgOptions) {
581
581
  taskLists: options.taskLists,
582
582
  tables: options.tables,
583
583
  strikethrough: options.strikethrough,
584
+ autolinks: options.autolinks,
585
+ autolinkUrls: options.autolinks,
584
586
  frontmatter: options.frontmatter,
585
587
  tocMaxDepth: options.tocMaxDepth,
586
588
  convertMdLinks: ssgOptions?.convertMdLinks,
@@ -3320,6 +3322,8 @@ function createNativeTransformOptions(options) {
3320
3322
  taskLists: options.taskLists,
3321
3323
  tables: options.tables,
3322
3324
  strikethrough: options.strikethrough,
3325
+ autolinks: options.autolinks,
3326
+ autolinkUrls: options.autolinks,
3323
3327
  frontmatter: options.frontmatter,
3324
3328
  tocMaxDepth: options.tocMaxDepth,
3325
3329
  codeAnnotations: options.codeAnnotations?.enabled ?? false,
@@ -3484,6 +3488,7 @@ function createFrameworkMarkdownOptions(options) {
3484
3488
  tables: true,
3485
3489
  taskLists: true,
3486
3490
  strikethrough: true,
3491
+ autolinks: options.gfm,
3487
3492
  highlight: false,
3488
3493
  highlightTheme: "github-dark",
3489
3494
  highlightLangs: [],
@@ -5067,6 +5072,30 @@ function createSearchPlugin(resolvedOptions, getRoot) {
5067
5072
  console.warn("[ox-content] Failed to build search index:", err);
5068
5073
  }
5069
5074
  },
5075
+ configureServer(devServer) {
5076
+ if (!resolvedOptions.search.enabled) return;
5077
+ const srcDir = path.resolve(getRoot(), resolvedOptions.srcDir);
5078
+ let stale = false;
5079
+ devServer.watcher.on("all", (event, file) => {
5080
+ if (event !== "add" && event !== "change" && event !== "unlink") return;
5081
+ const relative = path.relative(srcDir, file);
5082
+ if (relative !== ".." && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative) && isMarkdownFilePath(file, resolvedOptions.extensions)) stale = true;
5083
+ });
5084
+ const indexPath = resolvedOptions.base + "search-index.json";
5085
+ devServer.middlewares.use(async (req, res, next) => {
5086
+ if (req.url?.split("?")[0] !== indexPath) return next();
5087
+ try {
5088
+ if (stale || !searchIndexJson) {
5089
+ searchIndexJson = await buildSearchIndex(srcDir, resolvedOptions.base, resolvedOptions.extensions);
5090
+ stale = false;
5091
+ }
5092
+ res.setHeader("Content-Type", "application/json; charset=utf-8");
5093
+ res.end(searchIndexJson);
5094
+ } catch (err) {
5095
+ next(err);
5096
+ }
5097
+ });
5098
+ },
5070
5099
  async closeBundle() {
5071
5100
  if (!resolvedOptions.search.enabled || !searchIndexJson) return;
5072
5101
  const outDir = path.resolve(getRoot(), resolvedOptions.outDir);
@@ -5094,6 +5123,7 @@ function resolveOptions(options) {
5094
5123
  tables: options.tables ?? true,
5095
5124
  taskLists: options.taskLists ?? true,
5096
5125
  strikethrough: options.strikethrough ?? true,
5126
+ autolinks: options.autolinks ?? options.gfm ?? true,
5097
5127
  highlight: options.highlight ?? false,
5098
5128
  highlightTheme: options.highlightTheme ?? "github-dark",
5099
5129
  highlightLangs: options.highlightLangs ?? [],
@@ -5140,7 +5170,7 @@ function resolveBuiltinEmbedOptions(options) {
5140
5170
  pm: resolvePmOptions(options?.pm),
5141
5171
  spotify: options?.spotify === true,
5142
5172
  stackBlitz: options?.stackBlitz === true,
5143
- twitter: options?.twitter === true,
5173
+ twitter: resolveTwitterEmbedOptions(options?.twitter),
5144
5174
  bluesky: options?.bluesky === true,
5145
5175
  webContainer: options?.webContainer === true
5146
5176
  };
@@ -5150,6 +5180,11 @@ function resolveSingleEmbedOptions(options) {
5150
5180
  if (options === true || options === void 0) return {};
5151
5181
  return options;
5152
5182
  }
5183
+ function resolveTwitterEmbedOptions(options) {
5184
+ if (options === false || options === void 0) return false;
5185
+ if (options === true) return {};
5186
+ return options;
5187
+ }
5153
5188
  function resolvePmOptions(options) {
5154
5189
  if (options === false || options === void 0) return false;
5155
5190
  if (options === true) return {};