mirror of
https://github.com/lukevella/rallly.git
synced 2025-04-30 10:46:35 +02:00
🔍️ Add sitemap (#1371)
This commit is contained in:
parent
b58b408700
commit
6cfb56d4bc
1 changed files with 54 additions and 0 deletions
54
apps/landing/src/app/sitemap.ts
Normal file
54
apps/landing/src/app/sitemap.ts
Normal file
|
@ -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,
|
||||||
|
})),
|
||||||
|
];
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue