Skip to content

Commit

Permalink
Migrated legacy sitemap
Browse files Browse the repository at this point in the history
  • Loading branch information
gregory-buffard committed Jan 8, 2025
1 parent 07fb979 commit 091c7e6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
12 changes: 6 additions & 6 deletions web/actions/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -391,37 +391,37 @@ export const fetchSitemap = async () => {
query Sitemap {
Articles(limit: 0) {
docs {
id
slug
updatedAt
}
}
Yachts(limit: 0) {
docs {
id
slug
updatedAt
}
}
Charters(limit: 0) {
docs {
id
slug
updatedAt
}
}
NewConstructions(limit: 0) {
docs {
id
slug
updatedAt
}
}
Destinations(limit: 0) {
docs {
id
slug
updatedAt
}
}
Events(limit: 0) {
docs {
id
slug
updatedAt
}
}
Expand Down
12 changes: 8 additions & 4 deletions web/app/server-sitemap.xml/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,24 @@ export const GET = async (request: Request) => {
const addURLs = (category: string, basePath: { en: string; fr: string }) => {
data[category].docs.forEach((doc: IDoc) => {
URLs.push({
loc: `https://www.g-yachts.com/${basePath.en}/${doc.id}`,
loc: `https://www.g-yachts.com/${basePath.en}/${doc.slug}`,
lastmod: doc.updatedAt,
priority: 0.8,
alternateRefs: [
{
href: `https://www.g-yachts.com/${basePath.fr}/${doc.id}`,
href: `https://www.g-yachts.com/${basePath.en}/${doc.slug}`,
hreflang: "en",
},
{
href: `https://www.g-yachts.com/${basePath.fr}/${doc.slug}`,
hreflang: "fr",
},
{
href: `https://www.g-yachts.com/en/${basePath.en}/${doc.id}`,
href: `https://www.g-yachts.com/en/${basePath.en}/${doc.slug}`,
hreflang: "en",
},
{
href: `https://www.g-yachts.com/fr/${basePath.fr}/${doc.id}`,
href: `https://www.g-yachts.com/fr/${basePath.fr}/${doc.slug}`,
hreflang: "fr",
},
],
Expand Down
4 changes: 4 additions & 0 deletions web/next-sitemap.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ module.exports = {
lastmod: new Date().toISOString(),
priority: 0.7,
alternateRefs: [
{
href: `${config.siteUrl}/${staticPaths[0].paths[i]}`,
hreflang: staticPaths[0].locale,
},
{
href: `${config.siteUrl}/${staticPaths[1].paths[i]}`,
hreflang: staticPaths[1].locale,
Expand Down

0 comments on commit 091c7e6

Please sign in to comment.