import { component$ } from '@builder.io/qwik' import { Link, useLocation } from '@builder.io/qwik-city' import { WildebeestLogo } from '~/components/MastodonLogo' import { authLoader } from '~/routes/layout' type LinkConfig = { iconName: string linkText: string linkTarget: string linkActiveRegex: RegExp } export default component$(() => { const { isAuthorized, loginUrl } = authLoader().value const location = useLocation() const renderNavLink = ({ iconName, linkText, linkTarget, linkActiveRegex }: LinkConfig) => { let classList = 'mx-4 my-5 h-5 flex no-underline text-semi max-w-max ' + location.pathname if (linkActiveRegex.test(location.pathname)) { classList += ' text-wildebeest-vibrant-400' } else { classList += ' hover:text-white focus:text-white' } return ( ) } const links = [ { iconName: 'fa-hashtag', linkText: 'Explore', linkTarget: '/explore', linkActiveRegex: /^\/explore/ }, { iconName: 'fa-users', linkText: 'Local', linkTarget: '/public/local', linkActiveRegex: /^\/public\/local/ }, { iconName: 'fa-globe', linkText: 'Federated', linkTarget: '/public', linkActiveRegex: /^\/public\/?$/ }, ] const aboutLink = { iconName: 'fa-ellipsis', linkText: 'About', linkTarget: '/about', linkActiveRegex: /^\/about/ } return (
{links.map((link) => renderNavLink(link))}

{renderNavLink(aboutLink)}
{!isAuthorized && ( Sign in )} {isAuthorized && ( Preferences )}
) })