|
1 | 1 | import { fileURLToPath } from 'url' |
2 | | -import { defineNuxtModule, addPlugin, createResolver, addImportsDir, addServerHandler } from '@nuxt/kit' |
| 2 | +import { defineNuxtModule, addPlugin, createResolver, addImportsDir, addServerHandler, addServerImports, addImports } from '@nuxt/kit' |
3 | 3 | import { defu } from 'defu' |
4 | 4 | import type { NuxtOptionsWithDrupalCe } from './types' |
5 | 5 |
|
6 | 6 | export interface ModuleOptions { |
7 | | - baseURL?: string, |
8 | 7 | drupalBaseUrl: string, |
9 | 8 | serverDrupalBaseUrl?: string, |
10 | 9 | ceApiEndpoint: string, |
@@ -49,31 +48,17 @@ export default defineNuxtModule<ModuleOptions>({ |
49 | 48 | if (!nuxtOptions.drupalCe?.serverApiProxy && options.exposeAPIRouteRules !== undefined) { |
50 | 49 | options.serverApiProxy = options.exposeAPIRouteRules |
51 | 50 | } |
52 | | - // Keep backwards compatibility for baseURL(deprecated). |
53 | | - if (options.baseURL && options.baseURL.startsWith('http')) { |
54 | | - const baseURL = new URL(options.baseURL) |
55 | | - if (!options.drupalBaseUrl) { |
56 | | - options.drupalBaseUrl = baseURL.origin |
57 | | - } |
58 | | - options.ceApiEndpoint = baseURL.pathname |
59 | | - } else if (!options.baseURL) { |
60 | | - options.baseURL = options.drupalBaseUrl + options.ceApiEndpoint |
61 | | - } |
62 | | - |
63 | | - if (!options.menuBaseUrl) { |
64 | | - options.menuBaseUrl = options.drupalBaseUrl + options.ceApiEndpoint |
65 | | - } |
66 | 51 |
|
67 | | - // Disable the server routes for static sites OR when baseURL is not a full URL. |
68 | | - if (nuxt.options._generate || !options.baseURL.startsWith('http')) { |
| 52 | + // Disable the server routes for static sites. |
| 53 | + if (nuxt.options._generate) { |
69 | 54 | options.serverApiProxy = false |
70 | 55 | } |
71 | 56 |
|
72 | 57 | const { resolve } = createResolver(import.meta.url) |
73 | 58 | const runtimeDir = fileURLToPath(new URL('./runtime', import.meta.url)) |
74 | 59 | nuxt.options.build.transpile.push(runtimeDir) |
75 | 60 | addPlugin(resolve(runtimeDir, 'plugin')) |
76 | | - addImportsDir(resolve(runtimeDir, 'composables')) |
| 61 | + addImportsDir(resolve(runtimeDir, 'composables/useDrupalCe')) |
77 | 62 |
|
78 | 63 | nuxt.options.runtimeConfig.public.drupalCe = defu(nuxt.options.runtimeConfig.public.drupalCe ?? {}, options) |
79 | 64 |
|
|
0 commit comments