@@ -5,50 +5,23 @@ import { fetchRepoDirectoryContents } from '~/utils/docs'
55import type { GitHubFileNode } from '~/utils/documents.server'
66import { env } from '~/utils/env'
77
8- const TOP_LEVEL_ROUTE_MODULES = Object . keys (
9- import . meta. glob ( '../routes/*.{ts,tsx}' ) ,
10- )
11-
12- const TOP_LEVEL_INDEX_ROUTE_MODULES = Object . keys (
13- import . meta. glob ( '../routes/*/index.tsx' ) ,
14- )
15-
168export type SitemapEntry = {
179 path : string
1810 lastModified ?: string
1911}
2012
2113const MAX_DOCS_SITEMAP_DEPTH = 3
2214
23- const EXCLUDED_TOP_LEVEL_ROUTE_NAMES = new Set ( [
24- '__root' ,
25- 'account' ,
26- 'ads' ,
27- 'blog.$' ,
28- 'brand-guide' ,
29- 'builder.docs' ,
30- 'dashboard' ,
31- 'feed' ,
32- 'feedback-leaderboard' ,
33- 'llms.txt' ,
34- 'login' ,
35- 'merch' ,
36- 'partners-embed' ,
37- 'privacy' ,
38- 'terms' ,
39- 'robots.txt' ,
40- 'rss.xml' ,
41- 'sitemap.xml' ,
42- 'sponsors-embed' ,
43- ] )
44-
45- const EXCLUDED_TOP_LEVEL_ROUTE_DIRECTORIES = new Set ( [
46- '$libraryId' ,
47- '[.]well-known' ,
48- 'account' ,
49- 'admin' ,
50- 'stats' ,
51- ] )
15+ const HIGH_VALUE_NON_DOC_PAGES = [
16+ '/' ,
17+ '/blog' ,
18+ '/libraries' ,
19+ '/learn' ,
20+ '/showcase' ,
21+ '/support' ,
22+ '/workshops' ,
23+ '/paid-support' ,
24+ ] as const satisfies ReadonlyArray < string >
5225
5326function trimTrailingSlash ( url : string ) {
5427 return url . replace ( / \/ $ / , '' )
@@ -67,56 +40,6 @@ function asLastModified(value: string) {
6740 return new Date ( `${ value } T12:00:00.000Z` ) . toISOString ( )
6841}
6942
70- function normalizeRouteName ( routeName : string ) {
71- return routeName . replace ( / \[ \. \] / g, '.' )
72- }
73-
74- function getTopLevelRoutePath ( routeName : string ) {
75- if ( routeName === 'index' ) {
76- return '/'
77- }
78-
79- if ( routeName . endsWith ( '.index' ) ) {
80- return `/${ routeName . slice ( 0 , - '.index' . length ) } `
81- }
82-
83- return `/${ routeName } `
84- }
85-
86- function getTopLevelEntries ( ) : Array < SitemapEntry > {
87- const fileEntries = TOP_LEVEL_ROUTE_MODULES . flatMap ( ( modulePath ) => {
88- const routeName = normalizeRouteName (
89- modulePath
90- . split ( '/' )
91- . at ( - 1 )
92- ?. replace ( / \. ( t s | t s x ) $ / , '' ) ?? '' ,
93- )
94-
95- if ( ! routeName || EXCLUDED_TOP_LEVEL_ROUTE_NAMES . has ( routeName ) ) {
96- return [ ]
97- }
98-
99- return [ { path : getTopLevelRoutePath ( routeName ) } ]
100- } )
101-
102- const directoryEntries = TOP_LEVEL_INDEX_ROUTE_MODULES . flatMap (
103- ( modulePath ) => {
104- const routeDirectory = modulePath . split ( '/' ) . at ( - 2 )
105-
106- if (
107- ! routeDirectory ||
108- EXCLUDED_TOP_LEVEL_ROUTE_DIRECTORIES . has ( routeDirectory )
109- ) {
110- return [ ]
111- }
112-
113- return [ { path : `/${ normalizeRouteName ( routeDirectory ) } ` } ]
114- } ,
115- )
116-
117- return [ ...fileEntries , ...directoryEntries ]
118- }
119-
12043function getLibraryEntries ( ) : Array < SitemapEntry > {
12144 return libraries . flatMap ( ( library ) => {
12245 if (
@@ -213,7 +136,7 @@ export async function getSitemapEntries(): Promise<Array<SitemapEntry>> {
213136 )
214137
215138 const entries = [
216- ...getTopLevelEntries ( ) ,
139+ ...HIGH_VALUE_NON_DOC_PAGES . map ( ( path ) => ( { path } ) ) ,
217140 ...getLibraryEntries ( ) ,
218141 ...docsEntries . flat ( ) ,
219142 ...getBlogEntries ( ) ,
0 commit comments