feat(nav): send logo home and add Sample chapter link
This commit is contained in:
@@ -1,12 +1,29 @@
|
|||||||
import { useEffect, useRef, useState } from "react";
|
import { useEffect, useRef, useState } from "react";
|
||||||
|
import Link from "next/link";
|
||||||
|
|
||||||
const LINKS = [
|
const LINKS = [
|
||||||
{ href: "#recipe", label: "A recipe" },
|
{ href: "#recipe", label: "A recipe" },
|
||||||
{ href: "#contents", label: "Contents" },
|
{ href: "#contents", label: "Contents" },
|
||||||
{ href: "#letter", label: "Why" },
|
{ href: "#letter", label: "Why" },
|
||||||
{ href: "#faq", label: "FAQ" },
|
{ href: "#faq", label: "FAQ" },
|
||||||
|
{ href: "/read", label: "Sample chapter" },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
function NavItem({ href, label, onClick }) {
|
||||||
|
if (href.startsWith("/")) {
|
||||||
|
return (
|
||||||
|
<Link href={href} onClick={onClick}>
|
||||||
|
{label}
|
||||||
|
</Link>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<a href={href} onClick={onClick}>
|
||||||
|
{label}
|
||||||
|
</a>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export default function Nav() {
|
export default function Nav() {
|
||||||
const [scrolled, setScrolled] = useState(false);
|
const [scrolled, setScrolled] = useState(false);
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
@@ -39,16 +56,14 @@ export default function Nav() {
|
|||||||
return (
|
return (
|
||||||
<nav ref={navRef} className={`nav${scrolled ? " scrolled" : ""}${open ? " open" : ""}`}>
|
<nav ref={navRef} className={`nav${scrolled ? " scrolled" : ""}${open ? " open" : ""}`}>
|
||||||
<div className="nav-in">
|
<div className="nav-in">
|
||||||
<a className="logo" href="#top" onClick={close}>
|
<Link className="logo" href="/" onClick={close}>
|
||||||
AIBook<b>.</b>
|
AIBook<b>.</b>
|
||||||
<span className="dot">fun</span>
|
<span className="dot">fun</span>
|
||||||
</a>
|
</Link>
|
||||||
|
|
||||||
<div className="nav-links">
|
<div className="nav-links">
|
||||||
{LINKS.map((l) => (
|
{LINKS.map((l) => (
|
||||||
<a key={l.href} href={l.href}>
|
<NavItem key={l.href} href={l.href} label={l.label} />
|
||||||
{l.label}
|
|
||||||
</a>
|
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -70,9 +85,7 @@ export default function Nav() {
|
|||||||
|
|
||||||
<div className="nav-menu" id="mobile-menu">
|
<div className="nav-menu" id="mobile-menu">
|
||||||
{LINKS.map((l) => (
|
{LINKS.map((l) => (
|
||||||
<a key={l.href} href={l.href} onClick={close}>
|
<NavItem key={l.href} href={l.href} label={l.label} onClick={close} />
|
||||||
{l.label}
|
|
||||||
</a>
|
|
||||||
))}
|
))}
|
||||||
<a href="#get" className="btn btn-primary" onClick={close}>
|
<a href="#get" className="btn btn-primary" onClick={close}>
|
||||||
Get the preview
|
Get the preview
|
||||||
|
|||||||
Reference in New Issue
Block a user