11<script setup lang="ts">
22import type { NavigationMenuItem } from ' @nuxt/ui' ;
33
4+ const supa = useSupabaseClient ();
45const user = useSupabaseUser ();
56
6- const open = ref (false );
7-
8- const links: [NavigationMenuItem [], NavigationMenuItem [] ] = [[{
9- label: ' Topic 1' ,
10- to: ' /topic/1' ,
11- }], [{
7+ const links = ref <[NavigationMenuItem [], NavigationMenuItem []]>([[], [{
128 label: ' New Topic' ,
139 icon: ' i-lucide-plus' ,
14- onSelect : async () => navigateTo (` /topic/${await createTopic ()} ` ),
15- }/* , { label: 'Feedback', icon: 'i-lucide-message-circle', to: 'https://github.com/nuxt-ui-pro/dashboard', target: '_blank',} */ ]];
10+ onSelect : async () => navigateTo (` /topic/${await createTopic (supa )} ` ),
11+ }/* , { label: 'Feedback', icon: 'i-lucide-message-circle', to: 'https://github.com/nuxt-ui-pro/dashboard', target: '_blank',} */ ]]) ;
1612
1713const groups = computed (() => [{
1814 id: ' links' ,
1915 label: ' Go to' ,
20- items: links .flat ().map ((item ) => {
16+ items: links .value . flat ().map ((item ) => {
2117 return typeof item .to === ' string' && item .to .startsWith (' /topic/' )
2218 ? { ... item , icon: ' i-lucide-target' }
2319 : item ;
@@ -33,13 +29,28 @@ const groups = computed(() => [{
3329 target: ' _blank' ,
3430 }],
3531}]);
32+
33+ onMounted (async () => {
34+ if (! user .value )
35+ return ;
36+ const { data } = await supa
37+ .from (' topics' )
38+ .select (' id, title' )
39+ .eq (' owner' , user .value .id )
40+ .order (' created_at' , { ascending: false })
41+ .throwOnError ();
42+ links .value [0 ] = data .map ((topic ) => ({
43+ label: topic .title ,
44+ icon: ' i-lucide-target' ,
45+ to: ` /topic/${topic .id } ` ,
46+ }));
47+ })
3648 </script >
3749
3850<template >
3951 <UDashboardGroup unit =" rem" >
4052 <UDashboardSidebar
4153 id =" default"
42- v-model:open =" open"
4354 resizable
4455 class =" bg-(--ui-bg-elevated)/25"
4556 :ui =" { footer: 'lg:border-t lg:border-(--ui-border)' }"
0 commit comments