Updated robots

This commit is contained in:
2025-08-06 22:50:53 +02:00
parent 3f1e3aabe2
commit 39b7792717

View File

@@ -1,12 +1,28 @@
import { getAllUrls } from "@/lib/db/urls"
import type { MetadataRoute } from "next" import type { MetadataRoute } from "next"
export default function robots(): MetadataRoute.Robots { export default async function robots(): Promise<MetadataRoute.Robots> {
return { const slugs = (await getAllUrls()).map(s => `/r/${s.slug}`)
rules: {
userAgent: "*", const allowed = ["/"]
allow: "/", const allowedBots = ["Discordbot", "Googlebot"]
disallow: ["/api", "/dasboard", "/sign-in"],
const mainRules: MetadataRoute.Robots["rules"] = [{
userAgent: allowedBots,
allow: allowed,
crawlDelay: 60
}]
const dynamicRules: MetadataRoute.Robots["rules"] = [{
userAgent: allowedBots,
allow: slugs,
crawlDelay: 1 crawlDelay: 1
} }]
return {
rules: [...mainRules, ...dynamicRules, {
userAgent: "*",
disallow: "*"
}]
} }
} }