feat: redirect to first channel in list when going to server url
This commit is contained in:
parent
5011affd49
commit
abf3b248c4
2 changed files with 18 additions and 2 deletions
15
middleware/server.ts
Normal file
15
middleware/server.ts
Normal file
|
@ -0,0 +1,15 @@
|
|||
import type { ChannelResponse } from "~/types/interfaces";
|
||||
|
||||
export default defineNuxtRouteMiddleware(async (to, from) => {
|
||||
const { fetchChannels } = useApi();
|
||||
|
||||
const guildId = to.params.serverId as string;
|
||||
|
||||
const channels: ChannelResponse[] | undefined = await fetchChannels(guildId);
|
||||
console.log("channels:", channels);
|
||||
|
||||
if (channels && channels.length > 0) {
|
||||
console.log("wah");
|
||||
return await navigateTo(`/servers/${guildId}/channels/${channels[0].uuid}`, { replace: true });
|
||||
}
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue