@@ -8,34 +8,19 @@ const Sitemap = (): React.ReactElement | null => {
8
8
export const getServerSideProps : GetServerSideProps = async ( { res } ) => {
9
9
const BASE_URL = "https://paste.twilio.design" ;
10
10
11
- // Get a list of all pages currently in the site, must be mdx and not tsx which they all currently are
12
- const uncompiledPaths = await globby ( [ "**/*.mdx" ] ) ;
13
-
14
- const cachedpaths = await globby ( [ "**/*" ] , { cwd : __dirname } ) ;
15
-
16
- // eslint-disable-next-line no-console
17
- console . log ( cachedpaths ) ;
18
- // eslint-disable-next-line no-console
19
- console . log ( process . cwd ( ) , __dirname ) ;
20
-
21
- const urlPaths = uncompiledPaths . map ( ( path ) => {
22
- // Remove `src/pages/`
23
- let modifiedPath = path . replace ( / ^ s r c \/ p a g e s \/ / , "" ) ;
24
- // Remove `.mdx`
25
- modifiedPath = modifiedPath . replace ( / \. m d x $ / , "" ) ;
26
- // Remove `/index` if it's at the end of the path
27
- modifiedPath = modifiedPath . replace ( / \/ i n d e x $ / , "" ) ;
28
- return `${ BASE_URL } /${ path } ` ;
11
+ const paths = await globby ( [ "**/*.js" , "!sitemap.xml.js" , "!404.js" , "!_*.js" ] , {
12
+ cwd : __dirname ,
13
+ } ) ;
14
+ const staticPaths = paths . map ( ( staticPagePath ) => {
15
+ const path = staticPagePath . replace ( ".js" , "" ) ;
16
+ const route = path === "index" ? "" : `${ path } /` ;
17
+
18
+ return `${ BASE_URL } /${ route } ` ;
29
19
} ) ;
30
20
31
21
const sitemap = `<?xml version="1.0" encoding="UTF-8"?>
32
22
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
33
- <url>
34
- <loc>${ BASE_URL } </loc>
35
- <changefreq>daily</changefreq>
36
- <priority>0.7</priority>
37
- </url>
38
- ${ urlPaths
23
+ ${ staticPaths
39
24
. map ( ( url ) => {
40
25
return `
41
26
<url>
0 commit comments