| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- import { MetadataRoute } from "next";
- import { siteConfig } from "@/config/site";
- import { localePath } from "@/lib/i18n";
- /** A page's entry in each language, each listing the other as an alternate. */
- const bothLanguages = (
- path: string,
- entry: Omit<MetadataRoute.Sitemap[number], "url">,
- ): MetadataRoute.Sitemap => {
- const languages = {
- en: `${siteConfig.url}${localePath("en", path)}`,
- "zh-CN": `${siteConfig.url}${localePath("zh", path)}`,
- };
- return Object.values(languages).map((url) => ({
- ...entry,
- url,
- alternates: { languages },
- }));
- };
- type ChangeFrequency =
- "always" | "hourly" | "daily" | "weekly" | "monthly" | "yearly" | "never";
- export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
- // No articles for now, so there are no post URLs and no Notion lookup.
- const changeFrequency: ChangeFrequency = "weekly";
- const lastModified = new Date().toISOString();
- return [
- ...bothLanguages("/", {
- lastModified,
- changeFrequency,
- priority: 1.0,
- }),
- ...bothLanguages("/blog", {
- lastModified,
- changeFrequency,
- priority: 0.8,
- }),
- ];
- }
|