This repository was archived by the owner on May 20, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +10
-12
lines changed Expand file tree Collapse file tree 4 files changed +10
-12
lines changed Original file line number Diff line number Diff line change @@ -3,8 +3,6 @@ const fs = require('fs/promises')
33const excludedDirectories = [ '[[...slug]]' ] // ignore dynamic routes
44const pages = [ ]
55
6- const URL = 'https://nitric.io/docs'
7-
86const readDirRecursive = async ( dir ) => {
97 const files = await fs . readdir ( dir )
108
@@ -14,11 +12,12 @@ const readDirRecursive = async (dir) => {
1412 if ( stats . isDirectory ( ) && ! excludedDirectories . includes ( file ) ) {
1513 await readDirRecursive ( filePath )
1614 } else if ( file . startsWith ( 'page.' ) ) {
17- const loc = ` ${ URL } ${ filePath
15+ const loc = filePath
1816 . replace ( 'src/app' , '' )
1917 . replace ( '.tsx' , '' )
2018 . replace ( '.mdx' , '' )
21- . replace ( 'page' , '' ) } `. replace ( / \/ $ / , '' )
19+ . replace ( 'page' , '' )
20+ . replace ( / \/ $ / , '' )
2221
2322 pages . push ( loc )
2423 }
Original file line number Diff line number Diff line change @@ -4,16 +4,14 @@ import { XMLParser } from 'fast-xml-parser'
44const parser = new XMLParser ( )
55
66import { allDocs } from '../.contentlayer/generated/index.mjs'
7- import pages from '../src/assets/sitemap.json' with { type : 'json' }
7+ import basePages from '../src/assets/sitemap.json' with { type : 'json' }
88
99const FIXTURE_PATH = 'cypress/fixtures/pages.json'
1010
1111const PROD_PAGES_PATH = 'cypress/fixtures/prod_pages.json'
1212
1313async function run ( ) {
1414 try {
15- const basePages = pages . map ( ( p ) => p . replace ( 'https://nitric.io' , '' ) )
16-
1715 const docPages = allDocs . map ( ( doc ) => {
1816 return doc . slug === '/' ? '/docs' : `/docs/${ doc . slug } `
1917 } )
Original file line number Diff line number Diff line change 11import { allDocs } from '@/content'
22import staticPaths from '@/assets/sitemap.json'
3+ import { BASE_URL } from '@/lib/constants'
34
4- const URL = 'https://nitric.io/ docs'
5+ const URL = ` ${ BASE_URL } / docs`
56
67interface SitemapItem {
78 loc : string
@@ -15,7 +16,7 @@ const lastmod = new Date().toISOString()
1516// Function to construct the XML structure of the sitemap index.
1617export async function GET ( ) {
1718 const pages = staticPaths . map ( ( page ) => ( {
18- loc : page ,
19+ loc : ` ${ URL } ${ page } ` ,
1920 lastmod,
2021 changefreq : 'daily' ,
2122 priority : 0.7 ,
Original file line number Diff line number Diff line change 1+ import { BASE_URL } from '@/lib/constants'
2+
13// Function to construct the XML structure of the sitemap index.
24export async function GET ( ) {
3- const sitemapIndexXML = buildSitemapIndex ( [
4- 'https://nitric.io/docs/sitemap-0.xml' ,
5- ] )
5+ const sitemapIndexXML = buildSitemapIndex ( [ `${ BASE_URL } /docs/sitemap-0.xml` ] )
66
77 // Return the sitemap index XML with the appropriate content type.
88 return new Response ( sitemapIndexXML , {
You can’t perform that action at this time.
0 commit comments