@@ -6,29 +6,38 @@ const dismissedBanners = useCookie('directus-dismissed-banners', {
66});
77
88const bannerVisible = computed (() => {
9- if (! unref (banner )) return false ;
10- return unref (dismissedBanners ).includes (unref (banner )! .id ) === false ;
9+ const bannerValue = unref (banner );
10+ if (! bannerValue ) return false ;
11+ if (Object .keys (bannerValue ).length === 0 ) return false ;
12+
13+ if (! (' id' in bannerValue ) || ! (' content' in bannerValue )) return false ;
14+ return unref (dismissedBanners ).includes (bannerValue .id ) === false ;
1115});
1216
1317const dismiss = (id : string ) => {
1418 dismissedBanners .value = [... unref (dismissedBanners ), id ];
1519};
1620
1721const iconName = computed (() => {
18- if (! unref (banner )) return null ;
19- return getIconName (unref (banner )! .icon );
22+ const bannerValue = unref (banner );
23+ if (
24+ ! bannerValue
25+ || (typeof bannerValue === ' object' && Object .keys (bannerValue ).length === 0 )
26+ )
27+ return null ;
28+ return getIconName (bannerValue .icon );
2029});
2130 </script >
2231
2332<template >
2433 <div
2534 v-if =" banner && bannerVisible"
26- class =" bg-inverted text-inverted cursor-pointer h-8"
35+ class =" bg-inverted text-inverted cursor-pointer h-8"
2736 >
2837 <UContainer class =" h-full flex items-center gap-x-4" >
2938 <NuxtLink
3039 class =" flex-grow h-full flex items-center text-background no-underline text-xs leading-xs font-semibold group"
31- :href =" banner.link ?? undefined"
40+ :href =" banner? .link ?? undefined"
3241 >
3342 <Icon
3443 v-if =" iconName"
@@ -37,7 +46,7 @@ const iconName = computed(() => {
3746 />
3847 <span
3948 class =" whitespace-nowrap overflow-hidden text-ellipsis"
40- v-html =" banner.content"
49+ v-html =" banner? .content"
4150 />
4251 <Icon
4352 class =" hidden md:block transform duration-150 ease-out ml-1 group-hover:translate-x-1 size-5"
@@ -49,7 +58,7 @@ const iconName = computed(() => {
4958 aria-label =" Close"
5059 :padded =" false"
5160 icon =" material-symbols:close"
52- @click =" dismiss(banner.id)"
61+ @click =" banner && dismiss(banner.id)"
5362 >
5463 <Icon
5564 name =" material-symbols:close"
0 commit comments