Files
blitzkit/src/app/tools/layout.tsx
T

101 lines
2.6 KiB
TypeScript
Raw Normal View History

2023-09-18 21:55:40 +00:00
'use client';
2024-01-26 21:34:40 -06:00
import Link from 'next/link';
2023-09-24 17:36:20 -05:00
import { usePathname } from 'next/navigation';
2024-04-18 19:11:50 -05:00
import { ReactNode } from 'react';
2023-09-24 17:24:21 -05:00
import { TOOLS } from '../../constants/tools';
2023-09-18 21:55:40 +00:00
import { theme } from '../../stitches.config';
interface ToolsLayoutProps {
children: ReactNode;
}
export default function ToolsLayout({ children }: ToolsLayoutProps) {
2023-09-24 17:36:20 -05:00
const pathname = usePathname();
2024-02-17 10:43:34 -06:00
const pathSplit = pathname.split('/');
const toolId = pathSplit.at(2);
2024-04-18 18:28:46 -05:00
const isToolRoot = pathname === `/tools/${toolId}`;
2023-09-18 21:55:40 +00:00
const tool = TOOLS.find((tool) => tool.id === toolId);
return (
<>
2024-04-03 19:27:24 -05:00
{tool && (
<>
2024-04-18 18:28:46 -05:00
{isToolRoot && (
<>
<title>{tool.title}</title>
<meta
property="og:image"
content={`/assets/banners/${toolId}.webp`}
/>
2024-04-04 10:18:04 -05:00
2024-04-18 18:28:46 -05:00
{tool.pageDescription !== undefined && (
2024-04-19 09:14:22 -05:00
<>
<meta name="description" content={tool.pageDescription} />
<meta
property="og:description"
content={tool.pageDescription}
/>
</>
2024-04-18 18:28:46 -05:00
)}
</>
)}
2024-04-03 19:27:24 -05:00
</>
)}
2024-02-09 18:09:36 -06:00
2024-02-17 10:43:34 -06:00
{pathSplit.length === 3 && (
2023-10-11 21:26:33 -05:00
<div
style={{
2024-02-17 10:43:34 -06:00
height: 128,
boxShadow: `inset 0 -192px 128px -128px ${theme.colors.appBackground1}`,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
flexDirection: 'column',
position: 'relative',
overflow: 'hidden',
2023-10-11 21:26:33 -05:00
}}
2024-02-17 10:43:34 -06:00
>
<div
style={{
position: 'absolute',
backgroundImage: `url(/assets/banners/${toolId}.webp)`,
backgroundSize: 'cover',
backgroundPosition: 'center',
width: '100%',
height: '100%',
top: 0,
left: 0,
zIndex: -1,
filter: 'blur(4px)',
transform: 'scale(calc((128 + 8) / 128))',
}}
/>
2023-10-11 21:26:33 -05:00
2024-02-17 10:43:34 -06:00
<Link
href={`/tools/${toolId}`}
style={{
textDecoration: 'none',
fontWeight: 900,
color: theme.colors.textHighContrast,
fontSize: 32,
letterSpacing: -1,
}}
>
{tool?.title}
</Link>
<span
style={{
color: theme.colors.textLowContrast,
fontSize: 16,
}}
>
{tool?.description}
</span>
</div>
)}
2023-09-18 21:55:40 +00:00
2024-04-18 19:11:50 -05:00
{children}
2023-09-18 21:55:40 +00:00
</>
);
}