Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

init option of createHead doesn't apply initial title #513

Open
innocenzi opened this issue Mar 6, 2025 · 0 comments
Open

init option of createHead doesn't apply initial title #513

innocenzi opened this issue Mar 6, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@innocenzi
Copy link

Environment

@unhead/vue 2.0.0-rc.2
node v23.6.0

My app is using Hybridly, but I was able to reproduce on a Vite SPA on Stackblitz.

Reproduction

https://stackblitz.com/edit/vitejs-vite-j1drwgle?file=src%2Fmain.js

Describe the bug

I would like to have a default titleTemplate for all my pages, such as if I don't specify a title in a page, it will use the default one. In @unhead/vue v1. I am using it like this:

// v1
const head = createHead()
head.push({
	titleTemplate: (title) => `${title ?? ''} — Jetfly Group`.replace(/^  /, ''),
})
vue.use(head)


// v2
vue.use(createHead({
	init: [
		{ titleTemplate: (title) => `${title ?? ''} — Jetfly Group`.replace(/^  /, '') },
	],
}))

However, in v2, this no longer works. titleTemplate is never called, unless a page calls useHead with a title property.

Additional context

No response

Logs

@innocenzi innocenzi added the bug Something isn't working label Mar 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant