I am trying to figure out how to use next.js routes to populate a sidebar component with route instructions so that when a sidebar option is clicked, the main div is populted with the relevant component.
I can find tutorials showing the CSS for side bar menu items, but I cannot find the next.js route instructions for this task.
So far, I have a Sidebar component with:
function Sidebar({}) {
// I also tried adding href inside the above {} but it didn't work
// const { me, loading } = useMe()
const { me, loading: meLoading } = useMe()
if (meLoading)
return (
<Center>
<Spinner />
</Center>
)
return (
<Flex as="section" minH="100vh" bg="bg-canvas" maxW="100%" p="0">
<Flex
// px={{ base: '4', sm: '6' }}
>
<Stack justify="space-between" spacing="1">
<Stack spacing={{ base: '5', sm: '6' }} shouldWrapChildren>
<InputGroup>
<InputLeftElement pointerEvents="none">
<Icon as={FiSearch} color="muted" boxSize="5" />
</InputLeftElement>
<Input placeholder="Search" />
</InputGroup>
<Stack spacing="1" >
<NavButton label="Home" fontWeight="normal"/>
<Link href={Library} passHref>
// I have tried several other versions of this without the passHref, using href="/Library" and a range of other things - but I cant find anything that works - or makes sense as way to put the content in the Container that currently displays lorem ipsum as below
<NavButton label="Library" aria-current="page" fontWeight="normal" />
</Link>
<NavButton label="Tasks" fontWeight="normal" />
</Stack>
</Stack>
Then I have another component called Dashbase which should be where the relevant component for the selected sidebar option is displayed (instead of the lorem ipsum).
const DashBase = () => {
const isDesktop = useBreakpointValue({ base: false, lg: true })
const router = useRouter()
return (
<Flex
as="section"
direction={{ base: 'column', lg: 'row' }}
height="100vh"
bg="white"
mb="100px"
overflowY="auto"
minW="100%"
px={0}
mx="0px"
// minW="120em"
// margin="auto"
>
{isDesktop ? <Sidebar /> : <Navbar />}
<Container py="8" flex="none">
<Text> lorem ipsum dolor sit amet, consectetur adipiscing lorem ipsum dolor sit amet, consectetur adipiscing
</Text>
</Container>
</Flex>
)
}
export default DashBase;
<Stack spacing={{ base: '5', sm: '6' }}>
<Stack spacing="1">
<NavButton label="Help" fontWeight="normal"/>
<NavButton label="Settings" fontWeight="normal"/>
</Stack>
<UserProfile
name={me.firstName + " " + me.lastName}
// image="h"
bio={me.bio}
/>
</Stack>
</Stack>
</Flex>
</Flex>
)
}