Skip to content

Commit

Permalink
feat: Fix docs sitemap
Browse files Browse the repository at this point in the history
  • Loading branch information
richiemcilroy committed Dec 17, 2024
1 parent 4184f1b commit a8ab944
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions apps/web/app/sitemap.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { promises as fs } from "fs";
import path from "path";
import { getBlogPosts } from "@/utils/blog";
import { getBlogPosts, getDocs } from "@/utils/blog";
import { seoPages } from "../lib/seo-pages";

async function getPagePaths(
Expand All @@ -14,7 +14,6 @@ async function getPagePaths(
if (
entry.isDirectory() &&
entry.name !== "dashboard" &&
!entry.name.startsWith("s") &&
entry.name !== "blog" &&
!entry.name.startsWith("[")
) {
Expand All @@ -28,7 +27,6 @@ async function getPagePaths(
const routePath = "/" + relativePath.split(path.sep).slice(1).join("/");
if (
!routePath.includes("/dashboard") &&
!routePath.split("/").some((segment) => segment.startsWith("s")) &&
!routePath.includes("[")
) {
const stats = await fs.stat(fullPath);
Expand Down Expand Up @@ -58,15 +56,21 @@ export default async function sitemap() {
};
});

// Add docs routes
const docs = getDocs();
const docsRoutes = docs.map((doc) => ({
path: `/docs/${doc.slug}`,
lastModified: new Date().toISOString(), // You might want to add a publishedAt to doc metadata
}));

// Add SEO pages
const seoRoutes = Object.keys(seoPages).map((slug) => ({
path: `/${slug}`,
// Set lastModified to current date since these are static pages
lastModified: new Date().toISOString(),
}));

// Combine routes and ensure '/' is first
const allRoutes = [...pagePaths, ...blogRoutes, ...seoRoutes];
const allRoutes = [...pagePaths, ...blogRoutes, ...docsRoutes, ...seoRoutes];
const homeRoute = allRoutes.find((route) => route.path === "/");
const otherRoutes = allRoutes.filter((route) => route.path !== "/");

Expand Down

1 comment on commit a8ab944

@vercel
Copy link

@vercel vercel bot commented on a8ab944 Dec 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.