Skip to content

Commit 6f0c622

Browse files
authored
fix(build): do not register web-socket plugin on non-dev env (#1768)
1 parent 22a3acc commit 6f0c622

File tree

2 files changed

+10
-24
lines changed

2 files changed

+10
-24
lines changed

src/module.ts

+4-24
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,6 @@ export default defineNuxtModule<ModuleOptions>({
307307
)
308308
})
309309

310-
// Add Content plugin
311-
addPlugin(resolveRuntimeModule('./plugins/ws'))
312-
313310
nuxt.hook('nitro:config', (nitroConfig) => {
314311
// Init Nitro context
315312
nitroConfig.prerender = nitroConfig.prerender || {}
@@ -541,27 +538,6 @@ export default defineNuxtModule<ModuleOptions>({
541538
])
542539
}
543540

544-
// Register anchor link generation
545-
if (options.markdown.anchorLinks === true) {
546-
options.markdown.anchorLinks = {
547-
depth: 6,
548-
exclude: []
549-
}
550-
} else if (options.markdown.anchorLinks === false) {
551-
options.markdown.anchorLinks = {
552-
depth: 0,
553-
exclude: []
554-
}
555-
} else {
556-
options.markdown.anchorLinks = {
557-
...{
558-
depth: 4,
559-
exclude: [1]
560-
},
561-
...options.markdown.anchorLinks
562-
}
563-
}
564-
565541
// @ts-ignore
566542
await nuxt.callHook('content:context', contentContext)
567543

@@ -651,6 +627,10 @@ export default defineNuxtModule<ModuleOptions>({
651627
})
652628
return
653629
}
630+
// ~~ DEV ~~ //
631+
632+
// Add Content plugin
633+
addPlugin(resolveRuntimeModule('./plugins/ws'))
654634

655635
nuxt.hook('nitro:init', async (nitro) => {
656636
if (!options.watch || !options.watch.ws) { return }

src/utils.ts

+6
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,14 @@ export function createWebSocket () {
154154
}
155155

156156
export function processMarkdownOptions (options: ModuleOptions['markdown']) {
157+
// Refine anchor link generation
158+
const anchorLinks = typeof options.anchorLinks === 'boolean'
159+
? { depth: options.anchorLinks ? 6 : 0, exclude: [] }
160+
: { depth: 4, exclude: [1], ...options.anchorLinks }
161+
157162
return {
158163
...options,
164+
anchorLinks,
159165
remarkPlugins: resolveMarkdownPlugins(options.remarkPlugins),
160166
rehypePlugins: resolveMarkdownPlugins(options.rehypePlugins)
161167
}

0 commit comments

Comments
 (0)