Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

Fix sitemaps

Jakub Novake0f7a8910e23
diff --git a/apps/docs/src/app/(dashboard)/dashboard/sitemap.ts b/apps/docs/src/app/(dashboard)/dashboard/sitemap.ts
new file mode 100644
index 000000000..f1aadeb20
--- /dev/null
+++ b/apps/docs/src/app/(dashboard)/dashboard/sitemap.ts
@@ -0,0 +1,29 @@
+import { MetadataRoute } from 'next'
+import fs from 'fs'
+import path from 'path'
+import { getAllPageFilePaths } from '@/utils/sitemap'
+
+function nonNull<T>(value: T | null): value is T {
+ return value !== null
+}
+
+export default function sitemap(): MetadataRoute.Sitemap {
+ const appDirectory = path.join(process.cwd(), 'src', 'app', '(dashboard)', 'dashboard')
+ const mdxFilePaths = getAllPageFilePaths(appDirectory)
+ const priority = 0.5
+
+ return mdxFilePaths
+ .map((filePath) => {
+ const pathname = path
+ .relative(appDirectory, filePath)
+ .replace(/\/page\.mdx$/, '')
+ const url = `https://e2b.dev/dashboard/${pathname}`
+ const lastModified = fs.statSync(filePath).mtime
+ return {
+ url,
+ lastModified,
+ priority,
+ }
+ })
+ .filter(nonNull)
+}
diff --git a/apps/docs/src/app/(docs)/docs/sitemap.ts b/apps/docs/src/app/(docs)/docs/sitemap.ts
new file mode 100644
index 000000000..515fe9304
--- /dev/null
+++ b/apps/docs/src/app/(docs)/docs/sitemap.ts
@@ -0,0 +1,30 @@
+import { MetadataRoute } from 'next'
+import fs from 'fs'
+import path from 'path'
+import { getAllPageFilePaths } from '@/utils/sitemap'
+
+function nonNull<T>(value: T | null): value is T {
+ return value !== null
+}
+
+export default function sitemap(): MetadataRoute.Sitemap {
+ const appDirectory = path.join(process.cwd(), 'src', 'app', '(docs)', 'docs')
+ const mdxFilePaths = getAllPageFilePaths(appDirectory)
+ const priority = 0.5
+
+ return mdxFilePaths
+ .map((filePath) => {
+ const pathname = path
+ .relative(appDirectory, filePath)
+ .replace(/\/page\.mdx$/, '')
+ const url = `https://e2b.dev/docs/${pathname}`
+ const lastModified = fs.statSync(filePath).mtime
+ return {
+ url,
+ lastModified,
+ priority,
+ }
+ })
+ .filter(nonNull)
+}
+
diff --git a/apps/docs/src/app/sitemap.ts b/apps/docs/src/app/sitemap.ts
deleted file mode 100644
index 0e1ca2ac8..000000000
--- a/apps/docs/src/app/sitemap.ts
+++ /dev/null
@@ -1,48 +0,0 @@
-import { MetadataRoute } from 'next'
-import fs from 'fs'
-import path from 'path'
-
-function nonNull<T>(value: T | null): value is T {
- return value !== null
-}
-
-export default function sitemap(): MetadataRoute.Sitemap {
- const appDirectory = path.join(process.cwd(), 'src', 'app')
- const mdxFilePaths = getAllMdxFilePaths(appDirectory)
- const priority = 0.5
-
- return mdxFilePaths
- .map((filePath) => {
- const pathname = path
- .relative(appDirectory, filePath)
- .replace(/\/page\.mdx$/, '')
- if (pathname === 'page.mdx') {
- return null
- }
- const url = `https://e2b.dev/docs/${pathname}`
- const lastModified = fs.statSync(filePath).mtime
- return {
- url,
- lastModified,
- priority,
- }
- })
- .filter(nonNull)
-}
-
-function getAllMdxFilePaths(directory: string): string[] {
- const fileNames = fs.readdirSync(directory)
- const filePaths = fileNames
- .map((fileName) => {
- const filePath = path.join(directory, fileName)
- const stat = fs.statSync(filePath)
- if (stat.isDirectory()) {
- return getAllMdxFilePaths(filePath)
- } else if (path.basename(filePath) === 'page.mdx') {
- return filePath
- }
- })
- .filter(Boolean)
-
- return Array.prototype.concat(...filePaths)
-}
diff --git a/apps/docs/src/utils/sitemap.ts b/apps/docs/src/utils/sitemap.ts
new file mode 100644
index 000000000..00d595360
--- /dev/null
+++ b/apps/docs/src/utils/sitemap.ts
@@ -0,0 +1,19 @@
+import fs from 'fs'
+import path from 'path'
+
+export function getAllPageFilePaths(directory: string): string[] {
+ const fileNames = fs.readdirSync(directory)
+ const filePaths = fileNames
+ .map((fileName) => {
+ const filePath = path.join(directory, fileName)
+ const stat = fs.statSync(filePath)
+ if (stat.isDirectory()) {
+ return getAllPageFilePaths(filePath)
+ } else if (path.basename(filePath) === 'page.mdx' || path.basename(filePath) === 'page.tsx') {
+ return filePath
+ }
+ })
+ .filter(Boolean)
+
+ return Array.prototype.concat(...filePaths)
+}
diff --git a/apps/reverse-proxy/app/sitemap.ts b/apps/reverse-proxy/app/sitemap.ts
index 169152f6b..85d3b6413 100644
--- a/apps/reverse-proxy/app/sitemap.ts
+++ b/apps/reverse-proxy/app/sitemap.ts
@@ -34,6 +34,11 @@ const sites: Site[] = [
priority: 0.5,
changeFrequency: 'weekly',
},
+ {
+ sitemapUrl: 'https://e2b.dev/dashboard/sitemap.xml',
+ priority: 0.5,
+ changeFrequency: 'weekly',
+ },
{
sitemapUrl: 'https://e2b-changelog.framer.website/sitemap.xml',
priority: 0.2,