Skip to content

Commit da4b6b7

Browse files
committed
feat!: remove support for @vueuse/head. Use @unhead/vue instead.
1 parent 8e2ba8b commit da4b6b7

File tree

4 files changed

+8
-24
lines changed

4 files changed

+8
-24
lines changed

src/core/markdown.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,11 @@ export async function createMarkdown(options: ResolvedOptions) {
182182
scriptLines.push('defineExpose({ frontmatter })')
183183

184184
if (!isVue2 && headEnabled && head) {
185+
// @ts-expect-error legacy option
186+
if (headEnabled === 'vueuse')
187+
throw new Error('unplugin-vue-markdown no longer supports @vueuse/head. Change `headEnabled` to `true` and install `@unhead/vue` instead.')
185188
scriptLines.push(`const head = ${JSON.stringify(head)}`)
186-
const importFrom = headEnabled === 'unhead' ? '@unhead/vue' : '@vueuse/head'
187-
scriptLines.unshift(`import { useHead } from "${importFrom}"`)
189+
scriptLines.unshift(`import { useHead } from "@unhead/vue"`)
188190
scriptLines.push('useHead(head)')
189191
}
190192

src/core/options.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Options, ResolvedOptions } from '../types'
2-
import { getVueVersion, isUnheadVueInstalled } from './utils'
2+
import { getVueVersion } from './utils'
33

44
export function resolveOptions(userOptions: Options): ResolvedOptions {
55
const defaultOptions: ResolvedOptions = {
@@ -36,8 +36,5 @@ export function resolveOptions(userOptions: Options): ResolvedOptions {
3636
...userOptions,
3737
}
3838

39-
if (options.headEnabled === true)
40-
options.headEnabled = isUnheadVueInstalled() ? 'unhead' : 'vueuse'
41-
4239
return options as ResolvedOptions
4340
}

src/core/utils.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,3 @@ export function getVueVersion(defaultVersion = '3.2.0') {
1515
return defaultVersion
1616
}
1717
}
18-
19-
export function isUnheadVueInstalled() {
20-
try {
21-
_require('@unhead/vue')
22-
return true
23-
}
24-
catch {
25-
return false
26-
}
27-
}

src/types.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,9 @@ export interface Options {
5151
/**
5252
* Enable head support, need to install @unhead/vue and register to App in main.js
5353
*
54-
* When `true` is passed, @unhead/vue will be used if installed.
55-
* If not, @vueuse/head will be used.
56-
*
57-
* @default false
54+
* @default true
5855
*/
59-
headEnabled?: boolean | 'unhead' | 'vueuse'
56+
headEnabled?: boolean
6057

6158
/**
6259
* The head field in frontmatter used to be used for @unhead/vue
@@ -197,9 +194,7 @@ export interface Options {
197194
exclude?: FilterPattern
198195
}
199196

200-
export interface ResolvedOptions extends Required<Options> {
201-
headEnabled: 'unhead' | 'vueuse' | false
202-
}
197+
export interface ResolvedOptions extends Required<Options> {}
203198

204199
export interface MarkdownEnv extends MarkdownItEnv {
205200
id: string

0 commit comments

Comments
 (0)