+
Skip to content

feat(vite-plugin-nitro): allow customization of sitemap definition for prerendered routes #1650

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 18, 2025

Conversation

brandonroberts
Copy link
Member

PR Checklist

Closes #1525
Closes #1599

What is the new behavior?

The prerender.routes array can include an object that defines the route and sitemap properties for customizing the sitemap definition for the prerendered route.

import { defineConfig } from 'vite';
import analog from '@analogjs/platform';
import fs from 'node:fs';

// https://vitejs.dev/config/
export default defineConfig(({ mode }) => ({
  plugins: [
    analog({
      prerender: {
        sitemap: {
          host: 'https://analogjs.org/',
        },
        routes: async () => [
          '/',
          '/blog',
          {
            route: '/blog/2022-12-27-my-first-post',
            sitemap: {
              lastmod: '2022-12-27',
            },
          },
          {
            contentDir: '/src/content/archived',
            transform: (file: PrerenderContentFile) => {
              return `/archived/${file.attributes.slug || file.name}`;
            },
            sitemap: (file: PrerenderContentFile) => {
              return {
                lastmod: 'read last modified date for content file',
                changefreq: 'never',
              };
            },
          },
        ],
      },
    }),
  ],
}));

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

[optional] What gif best describes this PR or how it makes you feel?

Copy link

netlify bot commented Mar 17, 2025

Deploy Preview for analog-blog ready!

Name Link
🔨 Latest commit fbcbc80
🔍 Latest deploy log https://app.netlify.com/sites/analog-blog/deploys/67d79e4da7aad00008f6e7ac
😎 Deploy Preview https://deploy-preview-1650--analog-blog.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Mar 17, 2025

Deploy Preview for analog-app ready!

Name Link
🔨 Latest commit fbcbc80
🔍 Latest deploy log https://app.netlify.com/sites/analog-app/deploys/67d79e4d9597170008e15151
😎 Deploy Preview https://deploy-preview-1650--analog-app.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Mar 17, 2025

Deploy Preview for analog-ng-app ready!

Name Link
🔨 Latest commit fbcbc80
🔍 Latest deploy log https://app.netlify.com/sites/analog-ng-app/deploys/67d79e4ddc35a30008f62c88
😎 Deploy Preview https://deploy-preview-1650--analog-ng-app.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Mar 17, 2025

Deploy Preview for analog-docs ready!

Name Link
🔨 Latest commit fbcbc80
🔍 Latest deploy log https://app.netlify.com/sites/analog-docs/deploys/67d79e4d76e40f0008097470
😎 Deploy Preview https://deploy-preview-1650--analog-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@brandonroberts brandonroberts force-pushed the feat-customize-sitemap branch from 7877216 to fbcbc80 Compare March 17, 2025 04:00
@brandonroberts brandonroberts merged commit 7edff18 into beta Mar 18, 2025
24 checks passed
@brandonroberts brandonroberts deleted the feat-customize-sitemap branch March 18, 2025 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sitemap updates all lastmod dates to today when building Priority and ChangeFreq properties are missing in the sitemap generation
1 participant
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载