defaults.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import { overwriteMerge } from './merge.js';
  2. export const defaultSitemapTransformer = async (config, loc) => {
  3. return {
  4. loc,
  5. lastmod: config?.autoLastmod ? new Date().toISOString() : undefined,
  6. changefreq: config?.changefreq,
  7. priority: config?.priority,
  8. alternateRefs: config.alternateRefs ?? [],
  9. trailingSlash: config?.trailingSlash,
  10. };
  11. };
  12. export const defaultRobotsTxtTransformer = async (_, text) => text;
  13. export const defaultConfig = {
  14. sourceDir: '.next',
  15. outDir: 'public',
  16. priority: 0.7,
  17. sitemapBaseFileName: 'sitemap',
  18. changefreq: 'daily',
  19. sitemapSize: 5000,
  20. autoLastmod: true,
  21. exclude: [],
  22. transform: defaultSitemapTransformer,
  23. generateIndexSitemap: true,
  24. robotsTxtOptions: {
  25. transformRobotsTxt: defaultRobotsTxtTransformer,
  26. policies: [
  27. {
  28. userAgent: '*',
  29. allow: '/',
  30. },
  31. ],
  32. additionalSitemaps: [],
  33. },
  34. };
  35. export const withDefaultConfig = (config) => {
  36. return overwriteMerge(defaultConfig, config);
  37. };