Skip to content

Commit 7c5713b

Browse files
maximepvrtbenjamincanaclarbish
authored
fix(Header): hide TemplateMenu when logo is set (#126)
Co-authored-by: Benjamin Canac <[email protected]> Co-authored-by: Baptiste Leproux <[email protected]>
1 parent a89c39a commit 7c5713b

File tree

3 files changed

+43
-14
lines changed

3 files changed

+43
-14
lines changed

app/app.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ export default defineAppConfig({
1717
siteName: 'Nuxt UI Pro - Docs template'
1818
},
1919
header: {
20+
title: '',
21+
to: '/',
2022
logo: {
2123
alt: '',
2224
light: '',

app/components/AppHeader.vue

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ const { header } = useAppConfig()
77
</script>
88

99
<template>
10-
<UHeader :ui="{ center: 'flex-1' }">
10+
<UHeader
11+
:ui="{ center: 'flex-1' }"
12+
:to="header?.to || '/'"
13+
>
1114
<UContentSearchButton
1215
v-if="header?.search"
1316
label="Search..."
@@ -22,19 +25,29 @@ const { header } = useAppConfig()
2225
</template>
2326
</UContentSearchButton>
2427

25-
<template #left>
26-
<NuxtLink to="/">
27-
<UColorModeImage
28-
v-if="header?.logo?.dark || header?.logo?.light"
29-
:light="header?.logo?.light!"
30-
:dark="header?.logo?.dark!"
31-
:alt="header?.logo?.alt"
32-
class="h-6 w-auto shrink-0"
33-
/>
34-
<LogoPro
35-
v-else
36-
class="w-auto h-6 shrink-0"
37-
/>
28+
<template
29+
v-if="header?.logo?.dark || header?.logo?.light || header?.title"
30+
#title
31+
>
32+
<UColorModeImage
33+
v-if="header?.logo?.dark || header?.logo?.light"
34+
:light="header?.logo?.light!"
35+
:dark="header?.logo?.dark!"
36+
:alt="header?.logo?.alt"
37+
class="h-6 w-auto shrink-0"
38+
/>
39+
40+
<span v-else-if="header?.title">
41+
{{ header.title }}
42+
</span>
43+
</template>
44+
45+
<template
46+
v-else
47+
#left
48+
>
49+
<NuxtLink :to="header?.to || '/'">
50+
<LogoPro class="w-auto h-6 shrink-0" />
3851
</NuxtLink>
3952

4053
<TemplateMenu />

nuxt.schema.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,20 @@ export default defineNuxtSchema({
9393
description: 'Header configuration.',
9494
icon: 'i-mdi-page-layout-header',
9595
fields: {
96+
title: field({
97+
type: 'string',
98+
title: 'Title',
99+
description: 'Title to display in the header.',
100+
icon: 'i-mdi-format-title',
101+
default: ''
102+
}),
103+
to: field({
104+
type: 'string',
105+
title: 'To',
106+
description: 'URL to redirect to when the title is clicked.',
107+
icon: 'i-mdi-link-variant',
108+
default: ''
109+
}),
96110
logo: group({
97111
title: 'Logo',
98112
description: 'Header logo configuration.',

0 commit comments

Comments
 (0)