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 28, 2023
1 parent 2fa8a31 commit 33dd8ca
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 33dd8ca

Please sign in to comment.