Skip to content

Commit

Permalink
Add CCBot to bot exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
helenclx committed Dec 10, 2024
1 parent 5eff106 commit fd7ac97
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/_data/robots.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
// by Robb Knight: https://rknight.me/blog/blocking-bots-with-nginx/
/*
Modified from Robb Knight's script:
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";
const url = "https://raw.githubusercontent.com/ai-robots-txt/ai.robots.txt/main/robots.txt";
let txt = await EleventyFetch(url, {
duration: "1w",
type: "text",
});

const botExceptions = ["Applebot", "CCBot"];
const botExceptionsFullStr = botExceptions.map(bot => "User-agent: " + bot)

txt = txt
.split("\n")
.filter((line) => line !== "User-agent: Applebot")
.filter((line) => !botExceptionsFullStr.includes(line))
.join("\n");

const bots = txt
.split("\n")
.filter((line) => {
return (
line.startsWith("User-agent:") &&
line !== "User-agent: Applebot"
);
})
.filter((line) => line.startsWith("User-agent:"))
.map((line) => line.split(":")[1].trim().replace(/\s/gi, ".*"));

return {
Expand Down

0 comments on commit fd7ac97

Please sign in to comment.