ElMassimo/iles

Cannot set dynamic page title on dynamic routes

dhruvkb opened this issue ยท 4 comments

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
ouuan commented

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.

ouuan commented

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>

I get what you're saying, thanks @ouuan! I'll close the issue because the feature exists.