-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
PxlSyl
authored and
PxlSyl
committed
Apr 30, 2024
1 parent
f5a05bc
commit db13754
Showing
5 changed files
with
57 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { MetadataRoute } from 'next' | ||
import siteMetadata from '@/data/siteMetadata' | ||
|
||
export default function robots(): MetadataRoute.Robots { | ||
return { | ||
rules: { | ||
userAgent: '*', | ||
allow: '/', | ||
}, | ||
sitemap: `${siteMetadata.siteUrl}/sitemap.xml`, | ||
host: siteMetadata.siteUrl, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { MetadataRoute } from 'next' | ||
import { allBlogs } from 'contentlayer/generated' | ||
import siteMetadata from '@/data/siteMetadata' | ||
import { fallbackLng, secondLng } from './i18n/locales' | ||
|
||
export default function sitemap(): MetadataRoute.Sitemap { | ||
const locales = [fallbackLng, secondLng] | ||
const siteUrl = siteMetadata.siteUrl | ||
|
||
// blog route for english | ||
const firstBlogRoutes = allBlogs | ||
.filter((p) => p.language === fallbackLng) | ||
.map((post) => ({ | ||
url: `${siteUrl}/${fallbackLng}/${post.path}`, | ||
lastModified: post.lastmod || post.date, | ||
})) | ||
|
||
// blog route for french (or your own second language) | ||
const secondBlogRoutes = allBlogs | ||
.filter((p) => p.language === secondLng) | ||
.map((post) => ({ | ||
url: `${siteUrl}/${secondLng}/${post.path}`, | ||
lastModified: post.lastmod || post.date, | ||
})) | ||
|
||
const BlogRoutes = [...firstBlogRoutes, ...secondBlogRoutes].map((route) => ({ | ||
...route, | ||
})) | ||
|
||
// all routes for all locales | ||
const routes = locales.flatMap((locale) => { | ||
return ['', 'blog', 'projects', 'tags', 'about'].map((route) => ({ | ||
url: `${siteUrl}/${locale}/${route}`, | ||
lastModified: new Date().toISOString().split('T')[0], | ||
})) | ||
}) | ||
|
||
const SitemapRoutes: MetadataRoute.Sitemap = [...routes, ...BlogRoutes].map((route) => ({ | ||
...route, | ||
})) | ||
|
||
return SitemapRoutes | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters