Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,26 @@ const calSans = localFont({
variable: "--font-cal-sans",
});

const baseUrl = async () => {
let h = await headers();
const host = h.get("host") ?? "localhost:3000"
const proto = host.includes("localhost") ? "http" : "https"
return `${proto}://${host}`
}
const getURL = () => {
let url =
process?.env?.NEXT_PUBLIC_SITE_URL ?? // Custom prod domain
process?.env?.NEXT_PUBLIC_VERCEL_URL ?? // Vercel-generated
'http://localhost:3000/';

// Ensure protocol and trailing slash
url = url.startsWith('http') ? url : `https://${url}`;
url = url.endsWith('/') ? url : `${url}/`;
return url;
};


export const metadata: Metadata = {
title: "Apalis - background task and message processing library for Rust",
description:
"Simple, extensible multithreaded background task and message processing library for Rust",
openGraph: {
images: `${baseUrl()}/images/og.png`,
}
images: `${getURL()}images/og.png`,
},
};

export default function RootLayout({ children }: { children: ReactNode }) {
Expand All @@ -46,6 +51,7 @@ export default function RootLayout({ children }: { children: ReactNode }) {
className={`relative ${inter.variable} ${calSans.variable}`}
suppressHydrationWarning
>
<meta name="algolia-site-verification" content="2C97CAF9558A3A92" />
<body className="relative overflow-x-hidden antialiased font-light bg-white dark:bg-[#09090B] text-zinc-700 dark:text-zinc-300">
<Providers>
{children}
Expand Down
4 changes: 2 additions & 2 deletions components/atoms/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export const Button: FC<{
href={href}
className={`inline-flex relative z-10 h-10 rounded-sm p-px shadow-lg button-hover ${
secondary
? "bg-gradient-to-br from-zinc-300 to-zinc-500"
: "bg-gradient-to-b from-white to-zinc-300"
? "bg-gradient-to-br from-zinc-300 to-zinc-500 mx-auto"
: "bg-gradient-to-b from-white to-zinc-300 mx-auto"
} ${className}`}
{...(external && {
rel: "noopener noreferrer",
Expand Down
78 changes: 78 additions & 0 deletions components/layout/mobile-menu.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
"use client"

import { FC, useEffect, useState } from "react"
import { Icon } from "../icons"
import { usePathname } from "next/navigation"
import Link from "next/link"

export const MobileMenu: FC<{
menu: { name: string; href: string }[]
socials: { name: string; icon: string; href: string }[]
}> = ({ menu, socials }) => {
const [open, setOpen] = useState<boolean>(false)
const pathname = usePathname()

useEffect(() => {
if (open) {
document.body.classList.add("no-scroll")
} else {
document.body.classList.remove("no-scroll")
}
}, [open])

const closeMenu = () => setOpen(false)

useEffect(() => {
closeMenu()
}, [pathname])

return (
<>
<button
className="md:hidden z-50"
onClick={() => setOpen((open) => !open)}
>
<Icon
name={open ? "close" : "bars"}
className="h-6 text-black dark:text-white"
/>
</button>
{open && (
<div className="md:hidden fixed left-0 top-0 w-screen h-screen z-40 bg-white/90 dark:bg-[#09090B]/90 backdrop-blur pt-20 px-4 flex flex-col items-center gap-4">
{menu.map(({ name, href }, index) => (
<Link
key={index}
href={href}
className="flex items-start text-black dark:text-white"
onClick={() => closeMenu()}
>
<span>{name}</span>
{href.startsWith("http") && (
<Icon
name="arrow-up-right-light"
className="h-3.5 mt-0.5 ml-0.5"
/>
)}
</Link>
))}
{/*
<div className="mt-8">
<ThemeSwitcher />
</div>
*/}
<div className="flex items-center gap-4 mt-8">
{socials.map(({ name, icon, href }, index) => (
<Link key={index} href={href}>
<span className="sr-only">{name}</span>
<Icon
name={icon as Icon.Name}
className="h-5 text-zinc-400"
/>
</Link>
))}
</div>
</div>
)}
</>
)
}
2 changes: 2 additions & 0 deletions components/layout/navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Icon } from "../icons"
import { Search } from "../atoms/search"
import { usePathname } from "next/navigation"
import React from "react"
import { MobileMenu } from "./mobile-menu"

export interface NavigationLink {
readonly name: string
Expand Down Expand Up @@ -49,6 +50,7 @@ export const Navigation: React.FC<{
<Link href="/" className="z-50">
<Logo className="hidden dark:block h-7 sm:h-8" />
</Link>
<MobileMenu menu={links} socials={socials} />
<div className="hidden md:flex items-center gap-3">
<NavigationMenu />
{searchBox && <Search className="w-56" />}
Expand Down
Loading