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
30 changes: 13 additions & 17 deletions apps/web/src/app/sitemap.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,28 @@
import { MetadataRoute } from 'next'
import fs from 'fs'
import path from 'path'

function getDocSlugs(): string[] {
const docsDir = path.join(process.cwd(), 'content/docs')
try {
return fs
.readdirSync(docsDir)
.filter((file) => file.endsWith('.mdx'))
.map((file) => file.replace('.mdx', ''))
.filter((slug) => slug !== 'index')
} catch {
return []
}
}

export default function sitemap(): MetadataRoute.Sitemap {
const baseUrl = 'https://replimap.com'
const now = new Date()

// Static list - more reliable than fs.readdirSync in Vercel monorepo
// Update this when adding new docs (matches content/docs/*.mdx)
const docSlugs = [
'quick-start',
'installation',
'cli-reference',
'iam-policy',
'security',
'changelog',
'contributing',
]

// Core pages
const coreRoutes: MetadataRoute.Sitemap = [
{ url: baseUrl, lastModified: now, changeFrequency: 'weekly', priority: 1.0 },
{ url: `${baseUrl}/docs`, lastModified: now, changeFrequency: 'weekly', priority: 0.9 },
]

// Dynamic documentation pages
const docSlugs = getDocSlugs()
// Documentation pages
const docRoutes: MetadataRoute.Sitemap = docSlugs.map((slug) => ({
url: `${baseUrl}/docs/${slug}`,
lastModified: now,
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export default clerkMiddleware(async (auth, req) => {

export const config = {
matcher: [
// Skip Next.js internals and static files
"/((?!_next|[^?]*\\.(?:html?|css|js(?!on)|jpe?g|webp|png|gif|svg|ttf|woff2?|ico|csv|docx?|xlsx?|zip|webmanifest)).*)",
// Skip Next.js internals and static files (including xml for sitemap, txt for robots)
"/((?!_next|[^?]*\\.(?:html?|css|js(?!on)|jpe?g|webp|png|gif|svg|ttf|woff2?|ico|csv|docx?|xlsx?|zip|webmanifest|xml|txt)).*)",
// Always run for API routes
"/(api|trpc)(.*)",
],
Expand Down
Loading