Skip to content

Commit daa078d

Browse files
authored
refactor: migrate sitemap to app router and remove dead pages (#1406)
1 parent cf8ee6e commit daa078d

4 files changed

Lines changed: 87 additions & 351 deletions

File tree

src/app/sitemap.ts

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
import { MetadataRoute } from 'next'
2+
import { graphqlClient } from '@/js/graphql/Client'
3+
import { gql } from '@apollo/client'
4+
import { IndexResponseType } from '@/js/types'
5+
6+
const query = gql`query UsaAreas( $filter: Filter) {
7+
areas(filter: $filter, sort: { totalClimbs: -1 }) {
8+
id
9+
uuid
10+
areaName
11+
pathTokens
12+
totalClimbs
13+
density
14+
}
15+
}`
16+
17+
export default async function sitemap (): Promise<MetadataRoute.Sitemap> {
18+
const baseUrl = process.env.NODE_ENV === 'production'
19+
? 'https://openbeta.io'
20+
: 'http://localhost:3000'
21+
22+
const staticPages: string[] = [
23+
'/about',
24+
'/blog',
25+
'/blog/openbeta-vs-mountain-project-vs-thecrag'
26+
]
27+
28+
// Classic climbs pulled from https://www.climbing.com/places/the-50-classic-climbs-of-north-america/
29+
const classicClimbUuids: string[] = [
30+
'1609469e-2b62-558a-acef-f267536f1f3f',
31+
'b31ffdb5-2089-588c-996c-b1a5568670ea',
32+
'ca9b70a2-8745-505c-9b3a-8964226b564d',
33+
'a3624f5e-e607-5a3e-9f3e-a8d4ccc68dc0',
34+
'c0eeb0d1-04af-5cde-9064-ecbbea3f9c6b',
35+
'5665633f-fd6f-5f7f-a7c8-2d8cb8980221',
36+
'ac737862-3b77-5e46-8e9f-d91c04dcd8ad',
37+
'c693d5e5-d44b-5c9f-82e8-6535f243b5ad',
38+
'288b96ec-74c0-5216-a23a-25b6857e56e6',
39+
'e30e3f6a-1be8-52b7-91da-7c1a1a2ff981',
40+
'b36d4e3e-9ccf-5a04-98e1-2ea6788e350c',
41+
'4b4e454d-e24f-52f9-849b-ba50dcdb5f01',
42+
'0022799a-aa05-55d1-b1a7-5d46c2583dbe',
43+
'dbac7e4c-f4cf-5311-ba82-40c2e21cc932',
44+
'3ba65df3-7be4-567a-8ff4-7b16561fb2bb',
45+
'26dbd70a-68ed-57ae-a074-b212434f4cc5',
46+
'08eddae2-2efa-5f45-b15b-ec9ca8e6d46a',
47+
'e031119e-8fa8-5b82-9b82-7796ee6724b9',
48+
'07bb5409-5e78-53ed-bb62-3438c796d1b3',
49+
'56a5b36e-64bb-59fe-b90d-6d8a39c302cc',
50+
'd587b3c9-86c0-58fa-a87b-6cdf7ef83a79'
51+
]
52+
53+
const { data } = await graphqlClient.query<IndexResponseType>({
54+
query,
55+
variables: {
56+
filter: {
57+
field_compare: [{
58+
field: 'totalClimbs',
59+
num: 400,
60+
comparison: 'gt'
61+
}, {
62+
field: 'density',
63+
num: 0.5,
64+
comparison: 'gt'
65+
}]
66+
}
67+
}
68+
})
69+
70+
const staticEntries: MetadataRoute.Sitemap = staticPages.map((url) => ({
71+
url: `${baseUrl}${url}`,
72+
changeFrequency: 'monthly',
73+
priority: 1.0
74+
}))
75+
76+
const areaEntries: MetadataRoute.Sitemap = (data?.areas ?? []).map(({ uuid }) => ({
77+
url: `${baseUrl}/area/${uuid}`,
78+
changeFrequency: 'monthly',
79+
priority: 1.0
80+
}))
81+
82+
const climbEntries: MetadataRoute.Sitemap = classicClimbUuids.map((uuid) => ({
83+
url: `${baseUrl}/climb/${uuid}`
84+
}))
85+
86+
return [...staticEntries, ...areaEntries, ...climbEntries]
87+
}

src/pages/404.tsx

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/pages/sitemap.xml.tsx

Lines changed: 0 additions & 117 deletions
This file was deleted.

0 commit comments

Comments
 (0)