Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

🔍️ Add sitemap (#1371)

Luke Vella6cfb56d4bc0b
diff --git a/apps/landing/src/app/sitemap.ts b/apps/landing/src/app/sitemap.ts
new file mode 100644
index 000000000..b5155e181
--- /dev/null
+++ b/apps/landing/src/app/sitemap.ts
@@ -0,0 +1,54 @@
+import { supportedLngs } from "@rallly/languages";
+import type { MetadataRoute } from "next";
+
+import { getAllPosts } from "@/lib/api";
+import { absoluteUrl } from "@/utils/absolute-url";
+
+const alternateLanguages = supportedLngs.filter((lng) => lng !== "en");
+
+const getAlternateLanguages = (path: string) => {
+ return alternateLanguages.reduce<Record<string, string>>((acc, locale) => {
+ acc[locale] = absoluteUrl(`/${locale}${path}`);
+ return acc;
+ }, {});
+};
+
+export default async function Sitemap(): Promise<MetadataRoute.Sitemap> {
+ const posts = getAllPosts(["slug"]);
+
+ return [
+ {
+ url: absoluteUrl(),
+ lastModified: new Date(),
+ changeFrequency: "weekly",
+ priority: 1,
+ alternates: {
+ languages: getAlternateLanguages("/"),
+ },
+ },
+ {
+ url: absoluteUrl("/pricing"),
+ lastModified: new Date(),
+ changeFrequency: "weekly",
+ priority: 0.8,
+ alternates: {
+ languages: getAlternateLanguages("/pricing"),
+ },
+ },
+ {
+ url: absoluteUrl("/blog"),
+ lastModified: new Date(),
+ changeFrequency: "weekly",
+ priority: 0.8,
+ alternates: {
+ languages: getAlternateLanguages("/blog"),
+ },
+ },
+ ...posts.map((post) => ({
+ url: absoluteUrl(`/blog/${post.slug}`),
+ lastModified: new Date(), // TODO: Update posts to include a lastModified date
+ changeFrequency: "yearly" as const,
+ priority: 0.7,
+ })),
+ ];
+}