nuxt-ai-ready 0.3.1 → 0.3.2

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/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "nuxt": ">=4.0.0"
5
5
  },
6
6
  "configKey": "aiReady",
7
- "version": "0.3.1",
7
+ "version": "0.3.2",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.2",
10
10
  "unbuild": "3.6.1"
@@ -1,6 +1,16 @@
1
1
  import routes from "#ai-ready/routes.mjs";
2
2
  import { useRuntimeConfig } from "nitropack/runtime";
3
3
  export { jsonResult } from "../utils.js";
4
+ function routeToRegex(routePath) {
5
+ const pattern = routePath.replace(/:[^/]+\(\.\*\)\*?/g, ".*").replace(/:[^/]+/g, "[^/]+");
6
+ return new RegExp(`^${pattern}$`);
7
+ }
8
+ function matchRoute(path, routeRecords) {
9
+ for (const r of routeRecords) {
10
+ if (routeToRegex(r.path).test(path))
11
+ return r;
12
+ }
13
+ }
4
14
  export async function getDevPages() {
5
15
  const config = useRuntimeConfig()["nuxt-ai-ready"];
6
16
  if (!config.hasSitemap)
@@ -12,11 +22,13 @@ export async function getDevPages() {
12
22
  const xml = await sitemapRes.text();
13
23
  const { urls } = await parseSitemapXml(xml);
14
24
  return urls.map((entry) => {
15
- if (typeof entry === "string")
16
- return { route: new URL(entry).pathname };
25
+ const pathname = typeof entry === "string" ? new URL(entry).pathname : new URL(entry.loc).pathname;
26
+ const matched = matchRoute(pathname, routes);
17
27
  return {
18
- route: new URL(entry.loc).pathname,
19
- lastmod: entry.lastmod
28
+ route: pathname,
29
+ ...typeof entry !== "string" && entry.lastmod && { lastmod: entry.lastmod },
30
+ ...matched?.name && { name: matched.name },
31
+ ...matched?.meta && { meta: matched.meta }
20
32
  };
21
33
  });
22
34
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxt-ai-ready",
3
3
  "type": "module",
4
- "version": "0.3.1",
4
+ "version": "0.3.2",
5
5
  "description": "Best practice AI & LLM discoverability for Nuxt sites.",
6
6
  "author": {
7
7
  "name": "Harlan Wilton",