mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-18 06:44:46 -07:00
Include astro template urls in sitemap
getUrlsForAstroDefinedPages
This commit is contained in:
parent
7cc4c04347
commit
8c4700c7ea
2 changed files with 42 additions and 4 deletions
|
|
@ -1,10 +1,39 @@
|
|||
// import fs from 'fs-extra'
|
||||
import glob from 'fast-glob'
|
||||
import { simpleSitemapAndIndex } from 'sitemap'
|
||||
|
||||
|
||||
import {
|
||||
sitemapLocation
|
||||
import {
|
||||
sitemapLocation
|
||||
} from '~/helpers/constants.js'
|
||||
import { getSiteUrl } from '~/helpers/url.js'
|
||||
|
||||
const astroPageTemplatePath = './src/pages'
|
||||
|
||||
export async function getUrlsForAstroDefinedPages () {
|
||||
const siteUrl = getSiteUrl()
|
||||
const filesPaths = await glob( `${ astroPageTemplatePath }/**/*.astro` )
|
||||
|
||||
const urls = []
|
||||
|
||||
for ( const filePath of filesPaths ) {
|
||||
const urlPath = filePath
|
||||
.replace( astroPageTemplatePath, '' )
|
||||
.replace( '.astro', '' )
|
||||
.replace( '/index', '/' )
|
||||
|
||||
// Skip any paths for templates that include '['
|
||||
if ( urlPath.includes( '[' ) ) continue
|
||||
|
||||
console.log( 'urlPath', urlPath )
|
||||
|
||||
// Create a new url object from the site url and the path
|
||||
const url = new URL( urlPath, siteUrl )
|
||||
|
||||
urls.push( url.pathname )
|
||||
}
|
||||
|
||||
return urls
|
||||
}
|
||||
|
||||
export async function saveSitemap ( sitemapUrls ) {
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue