Skip to content

Commit

Permalink
feat: add category name in page detail title #350
Browse files Browse the repository at this point in the history
  • Loading branch information
wazolab authored and frodrigo committed Oct 1, 2024
1 parent e49ea58 commit 1ecd1e8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
1 change: 1 addition & 0 deletions components/PoisDetails/PoiDetails.story.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const defaultProps = {
const props = {
Default: {
...defaultProps,
pageTitle: `${defaultProps.poi.properties.classe} - ${defaultProps.poi.properties.name}`,
},
}
</script>
Expand Down
6 changes: 5 additions & 1 deletion components/PoisDetails/PoiDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ export default defineNuxtComponent({
type: Object as PropType<ApiPoiDeps>,
default: null,
},
pageTitle: {
type: String,
required: true,
},
},
data(): {
Expand Down Expand Up @@ -195,7 +199,7 @@ export default defineNuxtComponent({
<PoiLayout
:settings="settings"
:nav-menu-entries="navMenuEntries"
:name="poi.properties.name"
:name="pageTitle"
:icon="poi.properties.display && poi.properties.display.icon"
:color-line="colorLine"
:color-fill="colorFill"
Expand Down
17 changes: 13 additions & 4 deletions pages/poi/[id]/details.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ if (!poi.value) {
})
}
//
// Computed
//
const pageTitle = computed(() => {
if (!poi.value)
return ''
return `${poi.value.properties.classe} - ${poi.value.properties.name}`
})
//
// Hooks
//
Expand All @@ -78,11 +88,9 @@ onBeforeMount(() => {
useHead(
headerFromSettings(settings.value!, {
// @ts-expect-error: Fix typings
title: poiPoiDeps.value?.poi.properties.name,
title: pageTitle.value,
description: {
// @ts-expect-error: Fix typings
fr: poiPoiDeps.value?.poi.properties.description,
fr: poi.value?.properties.description,
},
}),
)
Expand All @@ -95,6 +103,7 @@ useHead(
:nav-menu-entries="contents!"
:poi="poi!"
:poi-deps="poiDeps"
:page-title="pageTitle"
class="page-details tw-overflow-clip"
/>
</template>
Expand Down

0 comments on commit 1ecd1e8

Please sign in to comment.