sitemap.config.ts 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import process from 'node:process'
  2. import axios from 'axios'
  3. const BASE_URL = process.env.NODE_ENV === 'production'
  4. ? 'https://www.ejetselection.com'
  5. : 'http://localhost:8000'
  6. export const sitemapConfig = {
  7. hostname: BASE_URL,
  8. // 静态路由
  9. staticRoutes: [
  10. {
  11. loc: '/',
  12. changefreq: 'daily',
  13. priority: 1,
  14. },
  15. ],
  16. // 动态路由生成函数
  17. async generateDynamicRoutes() {
  18. const routes: any[] = []
  19. try {
  20. // 获取品牌列表
  21. // const { data: brandData }: any = await axios.get(`${BASE_URL}/client/brand/list/default`, { params: { pageSize: 10000, pageNo: 1 } })
  22. // if (brandData.code === 200) {
  23. // brandData.result.records.forEach((brand: any) => {
  24. // routes.push({
  25. // loc: `${BASE_URL}/brand/${brand.id}`,
  26. // changefreq: 'weekly',
  27. // priority: 0.7,
  28. // })
  29. // })
  30. // }
  31. }
  32. catch (error) {
  33. console.error('Error fetching brands:', error)
  34. }
  35. return routes
  36. },
  37. }