mirror of
https://github.com/promplate/pyth-on-line.git
synced 2025-12-03 18:38:18 +00:00
fix: always return markdown content for llms on llms.txt route
This commit is contained in:
@@ -60,6 +60,7 @@
|
||||
"svelte-sonner": "0.3.28",
|
||||
"tailwind-merge": "^3.3.1",
|
||||
"turndown": "^7.2.1",
|
||||
"ua-parser-js": "^2.0.5",
|
||||
"unocss": "~66.4.2",
|
||||
"unzipit": "^1.4.3",
|
||||
"vite": "^5.4.20"
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
import type { Config } from "@netlify/edge-functions";
|
||||
import type { Config, Context } from "@netlify/edge-functions";
|
||||
|
||||
export default async () => Response.redirect("/hmr/llms", 302);
|
||||
import { isAIBot } from "ua-parser-js/helpers";
|
||||
|
||||
export default async (request: Request, context: Context) => {
|
||||
const userAgent = request.headers.get("user-agent") || "";
|
||||
if (isAIBot(userAgent)) {
|
||||
const res = await context.next();
|
||||
res.headers.set("content-type", "text/markdown; charset=utf-8");
|
||||
return res;
|
||||
}
|
||||
else {
|
||||
return Response.redirect("/hmr/llms", 302);
|
||||
}
|
||||
};
|
||||
|
||||
export const config: Config = {
|
||||
path: "/hmr/llms*",
|
||||
|
||||
@@ -10,6 +10,13 @@
|
||||
"value": ".*text/html.*"
|
||||
}
|
||||
],
|
||||
"missing": [
|
||||
{
|
||||
"type": "header",
|
||||
"key": "user-agent",
|
||||
"value": ".*(ai|bot).*"
|
||||
}
|
||||
],
|
||||
"destination": "/hmr/llms",
|
||||
"permanent": false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user