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 Mar 15, 2023
1 parent 21f21c3 commit 54ee3d3
Showing 1 changed file with 10 additions and 2 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

0 comments on commit 54ee3d3

Please sign in to comment.