Skip to content

Commit

Permalink
fix(#7080): sitemap should only add trailing slash to pages
Browse files Browse the repository at this point in the history
  • Loading branch information
natemoo-re committed Jul 14, 2023
1 parent 795d598 commit d2642d2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/giant-tomatoes-dream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/sitemap': patch
---

Ensure trailing slash is only added to page routes
4 changes: 2 additions & 2 deletions packages/integrations/sitemap/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { AstroConfig, AstroIntegration } from 'astro';
import type { AstroConfig, AstroIntegration, RouteType } from 'astro';
import {
EnumChangefreq,
simpleSitemapAndIndex,
Expand Down Expand Up @@ -107,7 +107,7 @@ const createPlugin = (options?: SitemapOptions): AstroIntegration => {

if (config.trailingSlash === 'never') {
urls.push(newUrl);
} else if (config.build.format === 'directory' && !newUrl.endsWith('/')) {
} else if (config.build.format === 'directory' && !newUrl.endsWith('/') && r.type === 'page') {
urls.push(newUrl + '/');
} else {
urls.push(newUrl);
Expand Down

0 comments on commit d2642d2

Please sign in to comment.