Skip to content
Merged
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
31 changes: 4 additions & 27 deletions src/app/sitemap.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import type { MetadataRoute } from "next";
import { prisma } from "@/lib/prisma";

export const dynamic = "force-dynamic";

const BASE_URL = process.env.NEXT_PUBLIC_BASE_URL || "https://draftmark.app";

export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
Expand All @@ -25,27 +21,8 @@ export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
{ url: `${BASE_URL}/vs/stackedit`, lastModified: new Date(), changeFrequency: "monthly", priority: 0.7 },
];

// Only verified-owner docs are submitted: anonymous public docs are the
// target of an ongoing spam campaign and stay out of the index until the
// backlog is cleaned up.
const publicDocs = await prisma.doc.findMany({
where: {
visibility: "public",
seoSlug: { not: null },
userId: { not: null },
user: { is: { emailVerifiedAt: { not: null } } },
},
select: { seoSlug: true, updatedAt: true },
orderBy: { updatedAt: "desc" },
take: 1000,
});

const docRoutes: MetadataRoute.Sitemap = publicDocs.map((doc) => ({
url: `${BASE_URL}/public/${doc.seoSlug}`,
lastModified: doc.updatedAt,
changeFrequency: "weekly" as const,
priority: 0.8,
}));

return [...staticRoutes, ...docRoutes];
// User docs are intentionally omitted while the anonymous-doc spam backlog
// is cleaned up (spam accounts verify email too, so ownership is not a
// sufficient signal yet). Re-enable verified-owner docs after moderation.
return staticRoutes;
}
Loading