Skip to content

Commit

Permalink
Merge Swell-generated and user-supplied routes
Browse files Browse the repository at this point in the history
  • Loading branch information
mewa committed Sep 5, 2022
1 parent fa0ff92 commit 89b7150
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion modules/swell/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,14 @@ export default async function (moduleOptions) {
return extendPluginsFn ? extendPluginsFn(plugins) : plugins;
};

this.options.generate.routes = () => getRoutes(swell);
// add Swell routes to existing routes
const nuxtRoutes = this.options.generate.routes;
if (typeof nuxtRoutes === 'function') {
this.options.generate.routes = async () => (await nuxtRoutes()).concat(await getRoutes(swell));
}
if (Array.isArray(nuxtRoutes)) {
this.options.generate.routes = async () => nuxtRoutes.concat(await getRoutes(swell));
}

this.nuxt.hook('generate:done', (context) => {
const { locales } = context.options.i18n;
Expand Down

0 comments on commit 89b7150

Please sign in to comment.