Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

feat: Robots txt + sitemap.xml

Richie McIlroy0bb5f1a01bd0
diff --git a/apps/web/app/robots.txt b/apps/web/app/robots.txt
new file mode 100644
index 000000000..1925f60cd
--- /dev/null
+++ b/apps/web/app/robots.txt
@@ -0,0 +1,12 @@
+User-agent: *
+Allow: /
+
+# Disallow dashboard and any routes starting with 's'
+Disallow: /dashboard
+Disallow: /s
+
+# Allow crawling of updates
+Allow: /updates/
+
+# Sitemap location
+Sitemap: https://cap.so/sitemap.xml
\ No newline at end of file
diff --git a/apps/web/app/sitemap.ts b/apps/web/app/sitemap.ts
new file mode 100644
index 000000000..4eb8a175d
--- /dev/null
+++ b/apps/web/app/sitemap.ts
@@ -0,0 +1,51 @@
+import { promises as fs } from 'fs';
+import path from 'path';
+import { getBlogPosts } from "@/utils/updates";
+
+async function getPagePaths(dir: string): Promise<{ path: string; lastModified: string }[]> {
+ const entries = await fs.readdir(dir, { withFileTypes: true });
+ const paths: { path: string; lastModified: string }[] = [];
+
+ for (const entry of entries) {
+ const fullPath = path.join(dir, entry.name);
+ if (entry.isDirectory() && entry.name !== 'dashboard' && !entry.name.startsWith('s') && entry.name !== 'updates') {
+ const subPaths = await getPagePaths(fullPath);
+ paths.push(...subPaths);
+ } else if (entry.isFile() && (entry.name === 'page.tsx' || entry.name === 'page.mdx')) {
+ const relativePath = path.relative(process.cwd(), dir);
+ const routePath = '/' + relativePath.split(path.sep).slice(1).join('/');
+ if (!routePath.includes('/dashboard') && !routePath.split('/').some(segment => segment.startsWith('s'))) {
+ const stats = await fs.stat(fullPath);
+ paths.push({
+ path: routePath === '/app' ? '/' : routePath,
+ lastModified: stats.mtime.toISOString()
+ });
+ }
+ }
+ }
+
+ return paths;
+ }
+
+ export default async function sitemap() {
+ const appDirectory = path.join(process.cwd(), 'app');
+ const pagePaths = await getPagePaths(appDirectory);
+
+ // Add blog post routes
+ const blogPosts = getBlogPosts();
+ const blogRoutes = blogPosts.map(post => {
+ const publishDate = new Date(post.metadata.publishedAt);
+ publishDate.setHours(9, 0, 0, 0); // Set time to 9:00 AM
+ return {
+ path: `/updates/${post.slug}`,
+ lastModified: publishDate.toISOString()
+ };
+ });
+
+ const routes = [...pagePaths, ...blogRoutes].map((route) => ({
+ url: `https://cap.so${route.path}`,
+ lastModified: route.lastModified,
+ }));
+
+ return routes;
+ }
\ No newline at end of file
diff --git a/packages/ui-solid/src/auto-imports.d.ts b/packages/ui-solid/src/auto-imports.d.ts
index 304b9a1d5..3d2b7b708 100644
--- a/packages/ui-solid/src/auto-imports.d.ts
+++ b/packages/ui-solid/src/auto-imports.d.ts
@@ -3,6 +3,7 @@
// @ts-nocheck
// noinspection JSUnusedGlobalSymbols
// Generated by unplugin-auto-import
+// biome-ignore lint: disable
export {}
declare global {
const IconCapArrows: typeof import('~icons/cap/arrows.jsx')['default']