File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { getSortedPostsData } from "@/lib/blog" ;
22import Link from "next/link" ;
3- import { ExternalLink } from "lucide-react" ;
4- import { BackButton } from "@/components/ui/back-button" ;
3+ import { ExternalLink , ArrowLeft } from "lucide-react" ;
54import { Metadata } from "next" ;
65
76export const metadata : Metadata = {
@@ -18,7 +17,13 @@ export default function BlogArchive() {
1817
1918 { /* Navigation */ }
2019 < nav className = "mb-12 flex items-center justify-between" >
21- < BackButton fallback = "/" />
20+ < Link
21+ href = "/"
22+ className = "group flex items-center gap-2 text-sm font-semibold tracking-wide text-zinc-500 hover:text-blue-400 transition-colors uppercase"
23+ >
24+ < ArrowLeft size = { 16 } className = "transition-transform group-hover:-translate-x-1" />
25+ Back
26+ </ Link >
2227 < Link
2328 href = "/"
2429 className = "text-sm font-semibold tracking-wide text-zinc-500 hover:text-blue-400 transition-colors uppercase"
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ const geistMono = Geist_Mono({
1313} ) ;
1414
1515import { portfolioData } from "@/data/portfolio" ;
16+ import { AppNavigationTracker } from "@/components/ui/back-button" ;
1617
1718export const metadata : Metadata = {
1819 title : `${ portfolioData . personalInfo . name } | ${ portfolioData . personalInfo . tagline } ` ,
@@ -29,6 +30,7 @@ export default function RootLayout({
2930 < body
3031 className = { `${ geistSans . variable } ${ geistMono . variable } antialiased` }
3132 >
33+ < AppNavigationTracker />
3234 { children }
3335 </ body >
3436 </ html >
Original file line number Diff line number Diff line change 11"use client" ;
22
3- import { useRouter } from "next/navigation" ;
3+ import { useRouter , usePathname } from "next/navigation" ;
44import { ArrowLeft } from "lucide-react" ;
5+ import { useEffect , useRef } from "react" ;
6+
7+ export function AppNavigationTracker ( ) {
8+ const pathname = usePathname ( ) ;
9+ const isFirstRender = useRef ( true ) ;
10+
11+ useEffect ( ( ) => {
12+ if ( isFirstRender . current ) {
13+ isFirstRender . current = false ;
14+ ( window as any ) . isInternalNavigation = false ;
15+ } else {
16+ ( window as any ) . isInternalNavigation = true ;
17+ }
18+ } , [ pathname ] ) ;
19+
20+ return null ;
21+ }
22+
523export function BackButton ( { fallback = "/" } : { fallback ?: string } ) {
624 const router = useRouter ( ) ;
725
826 const handleBack = ( ) => {
9- if ( typeof window !== "undefined" && window . history . length > 2 ) {
27+ if ( typeof window !== "undefined" && ( window as any ) . isInternalNavigation ) {
1028 router . back ( ) ;
1129 } else {
1230 router . push ( fallback ) ;
You can’t perform that action at this time.
0 commit comments