Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions public/robots.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
User-agent: *
Content-Signal: search=yes, ai-input=yes, ai-train=yes
Allow: /

Sitemap: https://docs.dusk.network/sitemap-index.xml
30 changes: 30 additions & 0 deletions test/machine-files.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,36 @@ test("robots.txt permits crawling and advertises the generated sitemap index", a
assert.doesNotMatch(robots, /^Disallow: \/$/m);
});

test("robots.txt explicitly permits search, AI input, and AI training", async () => {
const sourceRobots = await readPublicFile("robots.txt");
const builtRobots = await readFile(
new URL("../dist/robots.txt", import.meta.url),
"utf8",
);
const contentSignal = builtRobots
.split(/\r?\n/)
.find((line) => line.toLowerCase().startsWith("content-signal:"));

assert.equal(builtRobots, sourceRobots);
assert.ok(contentSignal, "robots.txt must include a Content-Signal directive");

const preferences = Object.fromEntries(
contentSignal
.slice(contentSignal.indexOf(":") + 1)
.split(",")
.map((preference) => {
const [name, value] = preference.trim().split("=");
return [name, value];
}),
);

assert.deepEqual(preferences, {
search: "yes",
"ai-input": "yes",
"ai-train": "yes",
});
});

test("the conventional sitemap URL mirrors Astro's generated sitemap index", async () => {
const generatedIndex = await readFile(
new URL("../dist/sitemap-index.xml", import.meta.url),
Expand Down
Loading