1
1
<script setup lang="ts">
2
- import {
3
- onMounted ,
4
- useHead ,
5
- useLocaleHead ,
6
- useRoute ,
7
- useRuntimeConfig ,
8
- } from " #imports"
2
+ import { useHead , useLocaleHead , useRuntimeConfig } from " #imports"
3
+ import { computed , onMounted } from " vue"
9
4
10
5
import { meta as commonMeta } from " #shared/constants/meta"
11
6
import { favicons } from " #shared/constants/favicons"
12
- import { useFeatureFlagStore } from " ~/stores/feature-flag "
7
+ import { useUiStore } from " ~/stores/ui "
13
8
import { useDarkMode } from " ~/composables/use-dark-mode"
14
9
import { useLayout } from " ~/composables/use-layout"
15
10
16
11
import VFourOhFour from " ~/components/VFourOhFour.vue"
17
12
18
13
defineProps ([" error" ])
19
14
20
- const route = useRoute ()
21
- const { updateBreakpoint } = useLayout ()
22
15
const config = useRuntimeConfig ()
16
+ const uiStore = useUiStore ()
17
+
18
+ const headerHeight = computed (() => {
19
+ return ` --header-height: ${uiStore .headerHeight }px `
20
+ })
23
21
24
22
/**
25
23
* Update the breakpoint value in the cookie on mounted.
26
24
* The Pinia state might become different from the cookie state if, for example, the cookies were saved when the screen was `sm`,
27
25
* and then a page is opened on SSR on a `lg` screen.
28
26
*/
29
27
onMounted (() => {
28
+ const { updateBreakpoint } = useLayout ()
30
29
updateBreakpoint ()
31
- featureFlagStore .syncAnalyticsWithLocalStorage ()
32
30
})
33
31
34
- /* Feature flag store */
35
-
36
- const featureFlagStore = useFeatureFlagStore ()
37
- featureFlagStore .initFromQuery (route .query )
38
-
39
32
const darkMode = useDarkMode ()
40
- const head = useLocaleHead ({ dir: true , key: " id" , seo: true })
41
33
42
- useHead ({
43
- bodyAttrs: { class: darkMode .cssClass },
44
- title: " Openly Licensed Images, Audio and More | Openverse" ,
45
- meta: commonMeta ,
46
- link: [
34
+ const head = useLocaleHead ({ dir: true , key: " id" , seo: true })
35
+ const htmlI18nProps = computed (() => ({
36
+ lang: head .value ?.htmlAttrs ?.lang ?? " en" ,
37
+ dir: head .value ?.htmlAttrs ?.dir ?? " ltr" ,
38
+ }))
39
+ const link = computed (() => {
40
+ return [
47
41
... favicons ,
42
+ ... (head .value .link ?? []),
48
43
{
49
44
rel: " search" ,
50
45
type: " application/opensearchdescription+xml" ,
@@ -60,37 +55,28 @@ useHead({
60
55
href: config .public .apiUrl ,
61
56
crossorigin: " " ,
62
57
},
63
- ],
58
+ ]
59
+ })
60
+
61
+ const meta = computed (() => {
62
+ return [... commonMeta , ... (head .value .meta ?? [])]
63
+ })
64
+
65
+ useHead ({
66
+ htmlAttrs: htmlI18nProps ,
67
+ bodyAttrs: { class: darkMode .cssClass , style: headerHeight },
68
+ title: " Openly Licensed Images, Audio and More | Openverse" ,
69
+ meta ,
70
+ link ,
64
71
})
65
72
</script >
66
73
67
74
<template >
68
75
<div >
69
- <Html :lang =" head.htmlAttrs?.lang" :dir =" head.htmlAttrs?.dir" >
70
- <Head >
71
- <template v-for =" link in head .link " :key =" link .id " >
72
- <Link
73
- :id =" link.id"
74
- :rel =" link.rel"
75
- :href =" link.href"
76
- :hreflang =" link.hreflang"
77
- />
78
- </template >
79
- <template v-for =" meta in head .meta " :key =" meta .id " >
80
- <Meta
81
- :id =" meta.id"
82
- :property =" meta.property"
83
- :content =" meta.content"
84
- />
85
- </template >
86
- </Head >
87
- <Body >
88
- <VSkipToContentButton />
89
- <NuxtLayout name =" default" >
90
- <VFourOhFour class =" flex-grow" :error =" error" />
91
- </NuxtLayout >
92
- </Body >
93
- </Html >
76
+ <VSkipToContentButton />
77
+ <NuxtLayout name =" default" >
78
+ <VFourOhFour class =" flex-grow" :error =" error" />
79
+ </NuxtLayout >
94
80
</div >
95
81
</template >
96
82
0 commit comments