Skip to content

Commit

Permalink
feat: unhead 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
harlan-zw committed Feb 24, 2023
1 parent 068ae2d commit ded5534
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 38 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@
"vue": ">=2.7 || >=3"
},
"dependencies": {
"@unhead/dom": "^1.0.22",
"@unhead/schema": "^1.0.22",
"@unhead/ssr": "^1.0.22",
"@unhead/vue": "^1.0.22"
"@unhead/dom": "^1.1.0",
"@unhead/schema": "^1.1.0",
"@unhead/ssr": "^1.1.0",
"@unhead/vue": "^1.1.0"
},
"devDependencies": {
"@antfu/eslint-config": "^0.35.2",
Expand Down
78 changes: 57 additions & 21 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 11 additions & 3 deletions src/createHead.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import type { HeadTag, MaybeComputedRef, MergeHead, ReactiveHead, VueHeadClient } from '@unhead/vue'
import { createHead as createUnhead, useHead } from '@unhead/vue'
import { debouncedRenderDOMHead, renderDOMHead } from '@unhead/dom'
import type { ActiveHeadEntry, Head, HeadEntry, HeadEntryOptions, HeadPlugin, Unhead } from '@unhead/schema'
import type {
ActiveHeadEntry,
CreateHeadOptions,
Head,
HeadEntry,
HeadEntryOptions,
HeadPlugin,
Unhead
} from '@unhead/schema'
import type { App } from 'vue'
import { version } from 'vue'

Expand Down Expand Up @@ -89,8 +97,8 @@ export interface HeadClient<T extends MergeHead = {}> {
unhead: VueHeadClient<T>
}

export function createHead<T extends MergeHead = {}>(initHeadObject?: Head<T>): HeadClient<T> {
const unhead = createUnhead<T>()
export function createHead<T extends MergeHead = {}>(initHeadObject?: Head<T>, options?: CreateHeadOptions): HeadClient<T> {
const unhead = createUnhead<T>(options || {})

// make migration easier
const legacyHead: HeadClient<T> = {
Expand Down
7 changes: 5 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ export { VueHeadMixin, unheadVueComposablesImports, Vue2ProvideUnheadPlugin, cre
export {
injectHead,
useHead,
useSeoMeta,
useServerSeoMeta,
useHeadSafe,
useServerHead,
useServerHeadSafe,
useTagTitle,
useTagBase,
useTagMeta,
useSeoMeta,
useTagMetaFlat,
useTagLink,
useTagScript,
Expand All @@ -20,7 +24,6 @@ export {
useHtmlAttrs,
useBodyAttrs,
useTitleTemplate,
useServerHead,
useServerTagTitle,
useServerTagBase,
useServerTagMeta,
Expand Down
2 changes: 1 addition & 1 deletion tests/backwards-compatibility/add-head-objs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ describe('addHeadObjs', () => {
"_d": "title",
"_e": 0,
"_p": 0,
"children": "test",
"props": {},
"tag": "title",
"textContent": "test",
},
{
"_e": 0,
Expand Down
2 changes: 1 addition & 1 deletion tests/backwards-compatibility/head-tags.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ describe('head tags', () => {
"_d": "title",
"_e": 0,
"_p": 0,
"children": "test",
"props": {},
"tag": "title",
"textContent": "test",
},
{
"_e": 0,
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/vite-ssr/vite-ssr.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ describe('e2e: vite ssr', async () => {
}
let tags = await getHeadTags() as HeadTag[]
expect(
tags.find(t => t.tag === 'title')!.children,
tags.find(t => t.tag === 'title')!.textContent,
).toMatchInlineSnapshot('"0 | @vueuse/head"')
await page.click('button')
tags = await getHeadTags()
expect(
tags.find(t => t.tag === 'title')!.children,
tags.find(t => t.tag === 'title')!.textContent,
).toMatchInlineSnapshot('"1 | @vueuse/head"')
})

Expand Down
6 changes: 3 additions & 3 deletions tests/hooks/tags-resolved.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ describe('hook tags resolved', () => {

const tags = await hookTags
expect(tags[0].tag).toEqual('title')
expect(tags[0].children).toEqual('test')
expect(tags[0].textContent).toEqual('test')
expect(tags).toMatchInlineSnapshot(`
[
{
"_d": "title",
"_e": 0,
"_p": 0,
"children": "test",
"props": {},
"tag": "title",
"textContent": "test",
},
]
`)
Expand Down Expand Up @@ -63,11 +63,11 @@ describe('hook tags resolved', () => {
"_d": "title",
"_e": 0,
"_p": 0,
"children": "test",
"props": {
"extra": true,
},
"tag": "title",
"textContent": "test",
}
`)
})
Expand Down
2 changes: 1 addition & 1 deletion tests/vue-ssr.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ describe('vue ssr', () => {
}))

expect(headResult.htmlAttrs).toMatchInlineSnapshot(
'" data-something=\\"\\""',
'" data-something=\\"true\\""',
)
})
})

0 comments on commit ded5534

Please sign in to comment.