Skip to content

Commit

Permalink
feat(apps/web): fix sitemaps (#1748)
Browse files Browse the repository at this point in the history
  • Loading branch information
LufyCZ authored Nov 13, 2024
1 parent 6ec271d commit 1d3a688
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 7 deletions.
6 changes: 3 additions & 3 deletions apps/web/src/app/(cms)/academy/sitemap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
{
url: 'https://www.sushi.com/academy',
lastModified: new Date(),
changeFrequency: 'yearly',
changeFrequency: 'weekly',
},
{
url: 'https://www.sushi.com/academy/explore',
lastModified: new Date(),
changeFrequency: 'yearly',
changeFrequency: 'weekly',
},
...products.map(
(product) =>
({
url: `https://www.sushi.com/academy/products/${product}`,
lastModified: new Date(),
changeFrequency: 'yearly',
changeFrequency: 'monthly',
}) as const,
),
...articles.map(
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/app/(cms)/blog/sitemap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
{
url: 'https://www.sushi.com/blog',
lastModified: new Date(),
changeFrequency: 'yearly',
changeFrequency: 'daily',
},
...articles.map(
(article) =>
Expand Down
35 changes: 35 additions & 0 deletions apps/web/src/app/(cms)/faq/sitemap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { getFaqAnswerSearch } from '@sushiswap/graph-client/strapi'
import type { MetadataRoute } from 'next'

export const revalidate = 0

export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
try {
const { answers, answerGroups } = await getFaqAnswerSearch({
search: '',
pagination: {
limit: 10000,
},
})

const combined = answers.concat(answerGroups)

return [
{
url: 'https://www.sushi.com/faq',
lastModified: new Date(),
changeFrequency: 'weekly',
},
...combined.map(
(answer) =>
({
url: `https://www.sushi.com/faq/${answer.slug}`,
changeFrequency: 'weekly',
}) as const,
),
]
} catch {
console.error('sitemap: Error fetching faq articles')
return []
}
}
1 change: 1 addition & 0 deletions apps/web/src/app/sitemap-index.xml/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { getNetworkKey } from 'src/lib/network'
const sitemapFiles = [
'/academy/sitemap.xml',
'/blog/sitemap.xml',
'/faq/sitemap.xml',
...CHAIN_IDS.map(getNetworkKey).map((key) => `/sitemap/${key}.xml`),
'/aptos/sitemap.xml',
'/tron/sitemap.xml',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { graphql } from '../graphql'
import { STRAPI_GRAPHQL_URL } from 'src/subgraphs/strapi/constants'

export const StrapiFaqAnswerSearchQuery = graphql(
`query FaqAnswerSearch($search: String!) {
faqAnswers(filters: { name: { containsi: $search } }) {
`query FaqAnswerSearch($search: String!, $pagination: PaginationArg = {}) {
faqAnswers(filters: { name: { containsi: $search } }, pagination: $pagination) {
data {
attributes {
name
Expand All @@ -29,7 +29,7 @@ export const StrapiFaqAnswerSearchQuery = graphql(
}
}
faqAnswerGroups(filters: { name: { containsi: $search } }) {
faqAnswerGroups(filters: { name: { containsi: $search } }, pagination: $pagination) {
data {
attributes {
name
Expand Down

0 comments on commit 1d3a688

Please sign in to comment.