File tree Expand file tree Collapse file tree 11 files changed +59
-57
lines changed Expand file tree Collapse file tree 11 files changed +59
-57
lines changed Original file line number Diff line number Diff line change @@ -89,7 +89,7 @@ Or you can use [`vite-plugin-components`](#work-with-vite-plugin-components) for
89
89
90
90
## Frontmatter
91
91
92
- Frontmatter will be parsed and inject into Vue's instance data ` frontmatter ` field.
92
+ Frontmatter will be parsed and inject into Vue's instance data ` frontmatter ` field.
93
93
94
94
For example:
95
95
@@ -114,10 +114,10 @@ It will also be passed to the wrapper component's props if you have set `wrapper
114
114
115
115
## Document head and meta
116
116
117
- To manage document head and meta, you would need to install [ ` @vueuse/head ` ] ( https://github. com/vueuse/head ) and do some setup.
117
+ To manage document head and meta, you would need to install [ ` @unhead/vue ` ] ( https://unhead.harlanzw. com/integrations/vue/setup ) and do some setup.
118
118
119
119
``` bash
120
- npm i @vueuse/head
120
+ npm i @unhead/vue
121
121
```
122
122
123
123
``` js
@@ -140,7 +140,7 @@ export default {
140
140
``` js
141
141
// src/main.js
142
142
import { createApp } from ' vue'
143
- import { createHead } from ' @vueuse/head ' // <--
143
+ import { createHead } from ' @unhead/vue ' // <--
144
144
145
145
const app = createApp (App)
146
146
@@ -159,7 +159,7 @@ meta:
159
159
---
160
160
```
161
161
162
- For more options available, please refer to [ ` @vueuse/head ` 's docs] ( https://github. com/vueuse/head ) .
162
+ For more options available, please refer to [ ` @unhead/vue ` 's docs] ( https://unhead.harlanzw. com/integrations/vue/setup ) .
163
163
164
164
## Options
165
165
Original file line number Diff line number Diff line change 1
1
import { createApp } from 'vue'
2
- import { createHead } from '@vueuse/head '
2
+ import { createHead } from '@unhead/vue '
3
3
import {
4
4
createRouter ,
5
5
createWebHistory ,
Original file line number Diff line number Diff line change 5
5
"build" : " cross-env DEBUG=vite-plugin-vue-markdown:* vite build"
6
6
},
7
7
"dependencies" : {
8
- "@vueuse/head " : " ^1.0.24 " ,
8
+ "@unhead/vue " : " ^1.1.26 " ,
9
9
"vue" : " ^3.2.47" ,
10
10
"vue-router" : " ^4.1.6"
11
11
},
Original file line number Diff line number Diff line change 56
56
"@antfu/eslint-config" : " ^0.38.4" ,
57
57
"@antfu/ni" : " ^0.21.3" ,
58
58
"@types/node" : " ^18.15.11" ,
59
+ "@unhead/vue" : " ^1.1.26" ,
59
60
"@vue/test-utils" : " ^2.3.2" ,
60
- "@vueuse/head" : " ^1.1.23" ,
61
61
"bumpp" : " ^9.1.0" ,
62
62
"eslint" : " ^8.38.0" ,
63
63
"rollup" : " ^3.20.2" ,
Original file line number Diff line number Diff line change @@ -132,7 +132,8 @@ export function createMarkdown(options: ResolvedOptions) {
132
132
133
133
if ( ! isVue2 && headEnabled && head ) {
134
134
scriptLines . push ( `const head = ${ JSON . stringify ( head ) } ` )
135
- scriptLines . unshift ( 'import { useHead } from "@vueuse/head"' )
135
+ const importFrom = headEnabled === 'unhead' ? '@unhead/vue' : '@vueuse/head'
136
+ scriptLines . unshift ( `import { useHead } from "${ importFrom } "` )
136
137
scriptLines . push ( 'useHead(head)' )
137
138
}
138
139
}
Original file line number Diff line number Diff line change 1
1
import { toArray } from '@antfu/utils'
2
2
import type { Options , ResolvedOptions } from './types'
3
- import { getVueVersion } from './utils'
3
+ import { getVueVersion , isUnheadVueInstalled } from './utils'
4
4
5
5
export function resolveOptions ( userOptions : Options ) : ResolvedOptions {
6
6
const defaultOptions : ResolvedOptions = {
@@ -36,6 +36,9 @@ export function resolveOptions(userOptions: Options): ResolvedOptions {
36
36
...userOptions ,
37
37
}
38
38
39
+ if ( options . headEnabled === true )
40
+ options . headEnabled = isUnheadVueInstalled ( ) ? 'unhead' : 'vueuse'
41
+
39
42
options . wrapperClasses = toArray ( options . wrapperClasses )
40
43
. filter ( ( i ?: string ) => i )
41
44
. join ( ' ' )
Original file line number Diff line number Diff line change @@ -49,14 +49,17 @@ export interface Options {
49
49
vueVersion ?: string
50
50
51
51
/**
52
- * Enable head support, need to install @vueuse/head and register to App in main.js
52
+ * Enable head support, need to install @unhead/vue and register to App in main.js
53
+ *
54
+ * When `true` is passed, @unhead/vue will be used if installed.
55
+ * If not, @vueuse/head will be used.
53
56
*
54
57
* @default false
55
58
*/
56
- headEnabled ?: boolean
59
+ headEnabled ?: boolean | 'unhead' | 'vueuse'
57
60
58
61
/**
59
- * The head field in frontmatter used to be used for @vueuse/head
62
+ * The head field in frontmatter used to be used for @unhead/vue
60
63
*
61
64
* When an empty string is passed, it will use the root properties of the frontmatter
62
65
*
@@ -184,6 +187,7 @@ export interface Options {
184
187
}
185
188
186
189
export interface ResolvedOptions extends Required < Options > {
190
+ headEnabled : 'unhead' | 'vueuse' | false
187
191
wrapperClasses : string
188
192
}
189
193
Original file line number Diff line number Diff line change @@ -10,3 +10,14 @@ export function getVueVersion(defaultVersion = '3.2.0') {
10
10
return defaultVersion
11
11
}
12
12
}
13
+
14
+ export function isUnheadVueInstalled ( ) {
15
+ try {
16
+ const _require = require
17
+ _require ( '@unhead/vue' )
18
+ return true
19
+ }
20
+ catch {
21
+ return false
22
+ }
23
+ }
Original file line number Diff line number Diff line change 1
- // Vitest Snapshot v1
1
+ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
2
3
3
exports [` excerpt > raw excerpt 1` ] = `
4
4
"<template ><div class =\\"markdown-body\\"><p>This is an excerpt which is kept as <strong>raw Markdown</strong>.</p>
You can’t perform that action at this time.
0 commit comments