nuxt-ai-ready 2.2.0 → 2.2.1

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.
@@ -2,7 +2,7 @@ import { createHash } from 'node:crypto';
2
2
  import { realpath, readFile } from 'node:fs/promises';
3
3
  import { resolve, isAbsolute, relative, sep } from 'node:path';
4
4
  import { parseDocument } from 'yaml';
5
- import { A as AGENT_SKILLS_SCHEMA } from '../shared/nuxt-ai-ready.D5URd0TD.mjs';
5
+ import { A as AGENT_SKILLS_SCHEMA } from '../shared/nuxt-ai-ready.BVWXwmUS.mjs';
6
6
  import 'node:module';
7
7
  import '@nuxt/kit';
8
8
  import 'defu';
@@ -5,7 +5,7 @@ import { colorize } from 'consola/utils';
5
5
  import { resolveLocaleFromRoute } from 'nuxtseo-shared/i18n-runtime';
6
6
  import { collectSitemap } from 'sitemapd/parse';
7
7
  import { withLeadingSlash, joinURL, withBase } from 'ufo';
8
- import { l as logger, s as supportsNativeNodeSqlite, M as MARKDOWN_LINK_AVAILABILITY_FILE } from '../shared/nuxt-ai-ready.D5URd0TD.mjs';
8
+ import { l as logger, s as supportsNativeNodeSqlite, M as MARKDOWN_LINK_AVAILABILITY_FILE } from '../shared/nuxt-ai-ready.BVWXwmUS.mjs';
9
9
  import { normalizePagePath, toMarkdownPath } from '../../dist/runtime/markdown-path.js';
10
10
  import { toDeployedRoute, toLogicalRoute } from '../../dist/runtime/route-path.js';
11
11
  import { initSchema, computeContentHash, insertPage, queryAllPages, exportDbDump } from '../../dist/runtime/server/db/shared.js';
package/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "nuxt": ">=4.0.0"
5
5
  },
6
6
  "configKey": "aiReady",
7
- "version": "2.2.0",
7
+ "version": "2.2.1",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.3",
10
10
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -7,7 +7,7 @@ import 'defu';
7
7
  import 'nuxt-site-config/kit';
8
8
  import 'nuxtseo-shared/kit';
9
9
  import 'pkg-types';
10
- export { m as default } from './shared/nuxt-ai-ready.D5URd0TD.mjs';
10
+ export { m as default } from './shared/nuxt-ai-ready.BVWXwmUS.mjs';
11
11
  import '../dist/runtime/markdown-path.js';
12
12
  import '../dist/runtime/server/utils/sitemap-md.js';
13
13
  import '../dist/runtime/server/utils/discovery-response.js';
@@ -863,6 +863,34 @@ function ensureStaticHeader(contents, route, name, value) {
863
863
  const prefix = blockStart === routeLineEnd ? eol : "";
864
864
  return `${contents.slice(0, blockStart)}${prefix} ${name}: ${value}${eol}${contents.slice(blockStart)}`;
865
865
  }
866
+ const CLOUDFLARE_STATIC_HEADER_RULE_LIMIT = 100;
867
+ const RE_EXACT_MARKDOWN_ROUTE = /^\/[^*\s]*\.md[\t ]*\r?$/;
868
+ function splitHeaderBlocks(contents) {
869
+ const blocks = [];
870
+ let current = { route: null, text: "" };
871
+ for (const line of contents.split(/(?<=\n)/)) {
872
+ const isRoute = /^[^\s#]/.test(line);
873
+ if (isRoute) {
874
+ blocks.push(current);
875
+ current = { route: line.trimEnd(), text: "" };
876
+ }
877
+ current.text += line;
878
+ }
879
+ blocks.push(current);
880
+ return blocks;
881
+ }
882
+ function enforceStaticHeaderBudget(contents, limit) {
883
+ const blocks = splitHeaderBlocks(contents);
884
+ const ruleCount = blocks.filter((block) => block.route !== null).length;
885
+ if (ruleCount <= limit)
886
+ return { contents, total: ruleCount, dropped: 0 };
887
+ const kept = blocks.filter((block) => block.route === null || !RE_EXACT_MARKDOWN_ROUTE.test(block.route));
888
+ return {
889
+ contents: kept.map((block) => block.text).join(""),
890
+ total: kept.filter((block) => block.route !== null).length,
891
+ dropped: ruleCount - kept.filter((block) => block.route !== null).length
892
+ };
893
+ }
866
894
 
867
895
  const RE_MD_EXT = /\.md$/;
868
896
  function isStaticMarkdownSourceRoute(route) {
@@ -1815,6 +1843,15 @@ export const logger = createModuleLogger('nuxt-ai-ready', ${!!config.debug})
1815
1843
  staticDescribedbyEntry(nitro.options.baseURL || "/")
1816
1844
  );
1817
1845
  }
1846
+ if (String(nitro.options.preset || "").startsWith("cloudflare")) {
1847
+ const budget = enforceStaticHeaderBudget(mergedHeaders, CLOUDFLARE_STATIC_HEADER_RULE_LIMIT);
1848
+ if (budget.dropped > 0) {
1849
+ mergedHeaders = budget.contents;
1850
+ logger.warn(`_headers had ${budget.total + budget.dropped} rules and Cloudflare allows ${CLOUDFLARE_STATIC_HEADER_RULE_LIMIT}. Dropped the ${budget.dropped} per-page .md rules; the /*.md glob still sets the charset and describedby entries, but static markdown no longer sends a per-page canonical Link.`);
1851
+ }
1852
+ if (budget.total > CLOUDFLARE_STATIC_HEADER_RULE_LIMIT)
1853
+ logger.warn(`_headers still has ${budget.total} rules after dropping the .md rules. Cloudflare will reject the deploy until the other rules fit under ${CLOUDFLARE_STATIC_HEADER_RULE_LIMIT}.`);
1854
+ }
1818
1855
  if (mergedHeaders !== headers) {
1819
1856
  await writeFile(headersPath, mergedHeaders);
1820
1857
  logger.debug("Merged .md charset header into _headers");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxt-ai-ready",
3
3
  "type": "module",
4
- "version": "2.2.0",
4
+ "version": "2.2.1",
5
5
  "description": "Best practice AI & LLM discoverability for Nuxt sites.",
6
6
  "author": {
7
7
  "name": "Harlan Wilton",