Skip to content

Commit

Permalink
fix(build): do not register web-socket plugin on non-dev env (#1768)
Browse files Browse the repository at this point in the history
  • Loading branch information
farnabaz committed Dec 21, 2022
1 parent 22a3acc commit 6f0c622
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 24 deletions.
28 changes: 4 additions & 24 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,6 @@ export default defineNuxtModule<ModuleOptions>({
)
})

// Add Content plugin
addPlugin(resolveRuntimeModule('./plugins/ws'))

nuxt.hook('nitro:config', (nitroConfig) => {
// Init Nitro context
nitroConfig.prerender = nitroConfig.prerender || {}
Expand Down Expand Up @@ -541,27 +538,6 @@ export default defineNuxtModule<ModuleOptions>({
])
}

// Register anchor link generation
if (options.markdown.anchorLinks === true) {
options.markdown.anchorLinks = {
depth: 6,
exclude: []
}
} else if (options.markdown.anchorLinks === false) {
options.markdown.anchorLinks = {
depth: 0,
exclude: []
}
} else {
options.markdown.anchorLinks = {
...{
depth: 4,
exclude: [1]
},
...options.markdown.anchorLinks
}
}

// @ts-ignore
await nuxt.callHook('content:context', contentContext)

Expand Down Expand Up @@ -651,6 +627,10 @@ export default defineNuxtModule<ModuleOptions>({
})
return
}
// ~~ DEV ~~ //

// Add Content plugin
addPlugin(resolveRuntimeModule('./plugins/ws'))

nuxt.hook('nitro:init', async (nitro) => {
if (!options.watch || !options.watch.ws) { return }
Expand Down
6 changes: 6 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,14 @@ export function createWebSocket () {
}

export function processMarkdownOptions (options: ModuleOptions['markdown']) {
// Refine anchor link generation
const anchorLinks = typeof options.anchorLinks === 'boolean'
? { depth: options.anchorLinks ? 6 : 0, exclude: [] }
: { depth: 4, exclude: [1], ...options.anchorLinks }

return {
...options,
anchorLinks,
remarkPlugins: resolveMarkdownPlugins(options.remarkPlugins),
rehypePlugins: resolveMarkdownPlugins(options.rehypePlugins)
}
Expand Down

0 comments on commit 6f0c622

Please sign in to comment.