From 89b7150ecf3a81f350f878134161dcd2ef3e1edb Mon Sep 17 00:00:00 2001 From: mewa Date: Tue, 6 Sep 2022 00:59:48 +0200 Subject: [PATCH] Merge Swell-generated and user-supplied routes --- modules/swell/index.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/swell/index.js b/modules/swell/index.js index b9e76a3..7f9dd86 100644 --- a/modules/swell/index.js +++ b/modules/swell/index.js @@ -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;