Skip to content

Commit

Permalink
Add handling for boolean options
Browse files Browse the repository at this point in the history
  • Loading branch information
Fryuni committed Mar 5, 2024
1 parent ff5024e commit 065ab38
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Empty file removed packages/sitemap-ext/foo.astro
Empty file.
16 changes: 13 additions & 3 deletions packages/sitemap-ext/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ export default defineIntegration({

defineRouteConfig({
importName: 'sitemap-ext:config',
callbackHandler: (context, configCb: ConfigCallback) => {
configCb({
callbackHandler: (context, configCb: ConfigCallback | boolean) => {
const hooks: Parameters<ConfigCallback>[0] = {
removeFromSitemap(routeParams) {
for (const route of context.routeData) {
makeDecision(false, route, routeParams);
Expand All @@ -103,7 +103,17 @@ export default defineIntegration({
}
}
},
});
};

if (typeof configCb === 'boolean') {
if (configCb) {
hooks.addToSitemap();
} else {
hooks.removeFromSitemap();
}
} else {
configCb(hooks);
}
},
});

Expand Down

0 comments on commit 065ab38

Please sign in to comment.