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

Vue 3: titleTemplate no longer working #783

Open
xaddict opened this issue Oct 14, 2022 · 3 comments
Open

Vue 3: titleTemplate no longer working #783

xaddict opened this issue Oct 14, 2022 · 3 comments

Comments

@xaddict
Copy link

xaddict commented Oct 14, 2022

Working in Vue 3 with the options API and vue-meta 3.0.0-alpha.10.

It seems there's no longer a way to set a titleTemplate?

Any other ideas on how to do nested routes with nested title?
Example:
Start Page: 'Application Name'
Module Page: 'Module Name - Application Name'
Everything inside the module: 'Page Name - Module Name - Application Name'

@DengSihan
Copy link

DengSihan commented Oct 21, 2022

<metainfo>
    <template v-slot:title="{ content, metainfo }">
        {{
            metainfo.titleTemplate
                ? metainfo.titleTemplate.replace('%s', content)
                : content
        }}
    </template>
</metainfo>

works for me


then, you can use it in vue3 just like vue2

in <script setup>

// with titleTemplate
import { useMeta } from	'vue-meta';
useMeta({
    title: 'Nuxt',
    titleTemplate: '%s - A SSR JavaScript Framework',
});

// without titleTemplate
import { useMeta } from	'vue-meta';
useMeta({
    title: 'Nuxt',
    titleTemplate: false,
});

@xaddict
Copy link
Author

xaddict commented Oct 24, 2022

@DengSihan Yes and No.

Because all meta stuff gets injected into the dom the document so you end up with:
<titletemplate>%s - Level in between - Our Application</titletemplate>

Which is not optimal?

@tripflex
Copy link

tripflex commented Feb 7, 2024

For anybody showing up later searching, this project is no longer maintained ( #808 ) and suggest looking at using something like https://github.com/unjs/unhead/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants