2024-08-20 01:53:37 +00:00
|
|
|
// by Robb Knight: https://rknight.me/blog/blocking-bots-with-nginx/
|
|
|
|
|
|
|
|
import EleventyFetch from "@11ty/eleventy-fetch";
|
|
|
|
|
|
|
|
export default async function () {
|
|
|
|
const url =
|
|
|
|
"https://raw.githubusercontent.com/ai-robots-txt/ai.robots.txt/main/robots.txt";
|
|
|
|
let txt = await EleventyFetch(url, {
|
|
|
|
duration: "1w",
|
|
|
|
type: "text",
|
|
|
|
});
|
|
|
|
|
|
|
|
txt = txt
|
|
|
|
.split("\n")
|
|
|
|
.filter((line) => line !== "User-agent: Applebot")
|
|
|
|
.join("\n");
|
|
|
|
|
|
|
|
const bots = txt
|
|
|
|
.split("\n")
|
|
|
|
.filter((line) => {
|
|
|
|
return (
|
|
|
|
line.startsWith("User-agent:") &&
|
|
|
|
line !== "User-agent: Applebot"
|
|
|
|
);
|
|
|
|
})
|
|
|
|
.map((line) => line.split(":")[1].trim());
|
|
|
|
|
|
|
|
return {
|
|
|
|
txt: txt,
|
2024-08-20 18:17:28 +00:00
|
|
|
htaccess: bots,
|
2024-08-20 01:53:37 +00:00
|
|
|
};
|
|
|
|
}
|