@usenotra/agentside 0.2.0 → 0.2.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/build.d.ts CHANGED
@@ -18,8 +18,16 @@ export declare function llmsTxt(pages: readonly PrerenderedPage[], options: {
18
18
  }): string;
19
19
  export declare function llmsFullTxt(pages: readonly PrerenderedPage[]): string;
20
20
  export declare function vercelRoutes(paths?: readonly string[]): {
21
- rewrites: {
22
- source: string;
21
+ routes: ({
22
+ src: string;
23
+ headers: {
24
+ "Content-Type": string;
25
+ Vary: string;
26
+ "X-Robots-Tag": string;
27
+ };
28
+ continue: boolean;
29
+ } | {
30
+ src: string;
23
31
  has: ({
24
32
  readonly type: "header";
25
33
  readonly key: "accept";
@@ -29,13 +37,11 @@ export declare function vercelRoutes(paths?: readonly string[]): {
29
37
  readonly key: "user-agent";
30
38
  readonly value: `.*(${string}).*`;
31
39
  })[];
32
- destination: string;
33
- }[];
34
- headers: {
35
- source: string;
40
+ dest: string;
36
41
  headers: {
37
- key: string;
38
- value: string;
39
- }[];
40
- }[];
42
+ "Content-Type": string;
43
+ Vary: string;
44
+ "X-Robots-Tag": string;
45
+ };
46
+ })[];
41
47
  };
package/dist/build.js CHANGED
@@ -103,24 +103,23 @@ export function vercelRoutes(paths) {
103
103
  { type: "header", key: "accept", value: ".*text/markdown.*" },
104
104
  { type: "header", key: "user-agent", value: `.*(${agentTokens.map(escapeRegex).join("|")}).*` },
105
105
  ];
106
- const nested = paths?.filter((path) => path !== "/").map((path) => escapeRegex(path.slice(1)));
107
- const rewrites = conditions.flatMap((condition) => [
108
- ...(!paths || paths.includes("/") ? [{ source: "/", has: [condition], destination: "/index.md" }] : []),
109
- ...(!nested
110
- ? [{ source: "/((?!.*\\.)[^?]*[^/])/?", has: [condition], destination: "/$1.md" }]
111
- : nested.length > 0
112
- ? [{ source: `/:path(${nested.join("|")})`, has: [condition], destination: "/:path.md" }]
106
+ const markdownHeaders = {
107
+ "Content-Type": "text/markdown; charset=utf-8",
108
+ Vary: "Accept, User-Agent",
109
+ "X-Robots-Tag": "noindex",
110
+ };
111
+ const nested = paths?.filter((path) => path !== "/").map((path) => path.slice(1).replace(/[.*+?^${}()|[\]\\]/g, "\\$&"));
112
+ const pagePattern = nested ? `(${nested.join("|")})` : "((?!.*\\.).*[^/])";
113
+ const routes = [
114
+ { src: "^/(.+)\\.md$", headers: markdownHeaders, continue: true },
115
+ ...conditions.flatMap((condition) => [
116
+ ...(!paths || paths.includes("/")
117
+ ? [{ src: "^/$", has: [condition], dest: "/index.md", headers: markdownHeaders }]
113
118
  : []),
114
- ]);
115
- const headers = [
116
- {
117
- source: "/(.*)\\.md",
118
- headers: [
119
- { key: "Content-Type", value: "text/markdown; charset=utf-8" },
120
- { key: "Vary", value: "Accept, User-Agent" },
121
- { key: "X-Robots-Tag", value: "noindex" },
122
- ],
123
- },
119
+ ...(!nested || nested.length > 0
120
+ ? [{ src: `^/${pagePattern}/?$`, has: [condition], dest: "/$1.md", headers: markdownHeaders }]
121
+ : []),
122
+ ]),
124
123
  ];
125
- return { rewrites, headers };
124
+ return { routes };
126
125
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usenotra/agentside",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Serve markdown to AI agents and A/B test what they read. Built on Effect. By Notra.",
5
5
  "keywords": [
6
6
  "ai",