Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 13s
Build & Deploy / 🧪 QA (push) Successful in 3m2s
Build & Deploy / 🏗️ Build (push) Successful in 5m58s
Build & Deploy / 🚀 Deploy (push) Successful in 27s
Build & Deploy / 🔔 Notify (push) Has been cancelled
Build & Deploy / 🧪 Post-Deploy Verification (push) Has been cancelled
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
'use client';
|
|
|
|
import React from 'react';
|
|
import { usePathname } from 'next/navigation';
|
|
|
|
export const PDFDownloadBlock: React.FC<{ label: string; style: string }> = ({ label, style }) => {
|
|
const pathname = usePathname();
|
|
|
|
// Extract slug from pathname
|
|
const segments = pathname.split('/').filter(Boolean);
|
|
// Pathname is usually /[locale]/[slug] or /[locale]/products/[slug]
|
|
// We want the page slug.
|
|
const slug = segments[segments.length - 1] || 'home';
|
|
|
|
const href = `/api/pages/${slug}/pdf`;
|
|
|
|
return (
|
|
<div className="my-8">
|
|
<a
|
|
href={href}
|
|
className={`inline-flex items-center px-8 py-3.5 font-bold rounded-full transition-all duration-300 shadow-lg hover:shadow-xl group ${
|
|
style === 'primary'
|
|
? 'bg-primary text-white hover:bg-primary-dark'
|
|
: style === 'secondary'
|
|
? 'bg-accent text-primary-dark hover:bg-neutral-light'
|
|
: 'border-2 border-primary text-primary hover:bg-primary hover:text-white'
|
|
}`}
|
|
>
|
|
<span className="mr-3 transition-transform group-hover:scale-12 bit-bounce">📄</span>
|
|
{label}
|
|
</a>
|
|
</div>
|
|
);
|
|
};
|