Cannot set dynamic page title on dynamic routes
dhruvkb opened this issue ยท 4 comments
- I have read the troubleshooting section before opening an issue.
- I have tried upgrading
iles
andvite
.
Description ๐
Dynamic routes do not set page title. If
<page>
title: My Page
</page>
is set, the title is hard-coded.
Reproduction ๐
Dependencies Info
Run npx iles info
and pnpm list
(or npm list
) and provide the output:
iles v0.9.0 vite v4.0.3
This is a question or a feature request. Why are you issuing a bug report? What's the correct behavior if you think it's a bug?
I'm modifying page.frontmatter.title
to set the titles for dynamic routes, where page
is usePage()
.
You can also use useHead({ title: computed(() => 'title') })
.
@ouuan you're right, this is a feature request. How can you set page.frontmatter.title
in getStaticPaths()
? I see that it returns only two keys, params
(used to name the compiled page files) and props
(to populate the page) but not frontmatter
.
I use a separate script setup tag: (See the example in the documentation)
<script lang="ts">
export default definePageComponent({
getStaticPaths() {
},
});
</script>
<script setup lang="ts">
const page = usePage();
page.frontmatter.title = computed(() => 'title');
</script>