Skip to content

Commit

Permalink
add logic to respect "directory" build format
Browse files Browse the repository at this point in the history
  • Loading branch information
atilafassina committed Apr 16, 2023
1 parent 0b07cec commit 45a8d5c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
12 changes: 10 additions & 2 deletions packages/integrations/sitemap/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,16 @@ const createPlugin = (options?: SitemapOptions): AstroIntegration => {
* because `finalSiteUrl` always has trailing slash
*/
const path = finalSiteUrl.pathname + r.generate(r.pathname).substring(1);
const newUrl = new URL(path, finalSiteUrl).href;
urls.push(newUrl);

let newUrl = new URL(path, finalSiteUrl).href;

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

return urls;
Expand Down
9 changes: 2 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 45a8d5c

Please sign in to comment.