Compare commits
6 Commits
landing-up
...
bc745cfa8b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bc745cfa8b | ||
|
|
06155c9dbe | ||
| 87cf7946f9 | |||
|
|
4ccd8fd759 | ||
| fb25989be9 | |||
|
|
68d9b61bbb |
758
.claude/skills/nextjs-coding-standards/SKILL.md
Normal file
758
.claude/skills/nextjs-coding-standards/SKILL.md
Normal file
@@ -0,0 +1,758 @@
|
||||
---
|
||||
name: nextjs-coding-standards
|
||||
description: Next.js 16 coding standards including file naming conventions, API patterns, theming, styling guidelines, and directory structure. Use when writing or reviewing code.
|
||||
allowed-tools: Read, Grep, Glob
|
||||
---
|
||||
|
||||
# Next.js 16 Coding Standards
|
||||
|
||||
Reference this skill when writing or reviewing code to ensure consistency with project conventions.
|
||||
|
||||
---
|
||||
|
||||
## File Naming Conventions
|
||||
|
||||
### Files and Directories
|
||||
|
||||
**Use kebab-case for all file names:**
|
||||
```
|
||||
✅ user-profile.tsx
|
||||
✅ blog-post-card.tsx
|
||||
✅ theme-toggle.tsx
|
||||
|
||||
❌ UserProfile.tsx
|
||||
❌ blogPostCard.tsx
|
||||
❌ ThemeToggle.tsx
|
||||
```
|
||||
|
||||
**Why kebab-case?**
|
||||
- Cross-platform compatibility (Windows vs Unix)
|
||||
- URL-friendly (file names often map to routes)
|
||||
- Easier to parse and read
|
||||
- Industry standard for Next.js projects
|
||||
|
||||
**Special Next.js Files:**
|
||||
```
|
||||
page.tsx # Route pages
|
||||
layout.tsx # Layout components
|
||||
not-found.tsx # 404 pages
|
||||
loading.tsx # Loading states
|
||||
error.tsx # Error boundaries
|
||||
route.ts # API route handlers
|
||||
```
|
||||
|
||||
### Component Names (Inside Files)
|
||||
|
||||
**Use PascalCase for component names:**
|
||||
```typescript
|
||||
// File: user-profile.tsx
|
||||
export function UserProfile() {
|
||||
return <div>...</div>
|
||||
}
|
||||
|
||||
// File: blog-post-card.tsx
|
||||
export default function BlogPostCard() {
|
||||
return <article>...</article>
|
||||
}
|
||||
```
|
||||
|
||||
### Variables, Functions, Props
|
||||
|
||||
**Use camelCase:**
|
||||
```typescript
|
||||
// Variables
|
||||
const userSettings = {}
|
||||
const isLoading = false
|
||||
|
||||
// Functions
|
||||
function handleSubmit() {}
|
||||
function formatDate(date: string) {}
|
||||
|
||||
// Props
|
||||
interface ButtonProps {
|
||||
onClick: () => void
|
||||
isDisabled: boolean
|
||||
className?: string
|
||||
}
|
||||
|
||||
// Custom Hooks
|
||||
function useTheme() {}
|
||||
function useMarkdown() {}
|
||||
```
|
||||
|
||||
### Constants
|
||||
|
||||
**Use SCREAMING_SNAKE_CASE:**
|
||||
```typescript
|
||||
const API_BASE_URL = "https://api.example.com"
|
||||
const MAX_RETRIES = 3
|
||||
const DEFAULT_LOCALE = "ro-RO"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Next.js 16 API Patterns
|
||||
|
||||
### Route Handlers
|
||||
|
||||
**Use Route Handlers (not legacy API Routes):**
|
||||
|
||||
```typescript
|
||||
// app/api/posts/route.ts
|
||||
import { NextRequest, NextResponse } from 'next/server'
|
||||
|
||||
// Export named functions for HTTP methods
|
||||
export async function GET(request: NextRequest) {
|
||||
const posts = await getAllPosts()
|
||||
return NextResponse.json({ posts })
|
||||
}
|
||||
|
||||
export async function POST(request: NextRequest) {
|
||||
const body = await request.json()
|
||||
// Process request
|
||||
return NextResponse.json({ success: true }, { status: 201 })
|
||||
}
|
||||
```
|
||||
|
||||
### Type-Safe Validation with Zod
|
||||
|
||||
**Always validate input with Zod:**
|
||||
|
||||
```typescript
|
||||
import { z } from 'zod'
|
||||
import { NextRequest, NextResponse } from 'next/server'
|
||||
|
||||
const bodySchema = z.object({
|
||||
title: z.string().min(1).max(200),
|
||||
content: z.string(),
|
||||
tags: z.array(z.string()).max(3),
|
||||
})
|
||||
|
||||
export async function POST(request: NextRequest) {
|
||||
const json = await request.json()
|
||||
const parsed = bodySchema.safeParse(json)
|
||||
|
||||
if (!parsed.success) {
|
||||
return NextResponse.json(
|
||||
{ error: 'Validation failed', details: parsed.error },
|
||||
{ status: 400 }
|
||||
)
|
||||
}
|
||||
|
||||
// parsed.data is fully typed
|
||||
const { title, content, tags } = parsed.data
|
||||
// ... business logic
|
||||
}
|
||||
```
|
||||
|
||||
**Key Points:**
|
||||
- Use `safeParse()` instead of `parse()` to avoid try/catch
|
||||
- Return structured error responses
|
||||
- Use appropriate HTTP status codes
|
||||
- Infer TypeScript types from Zod schemas
|
||||
|
||||
### Error Handling
|
||||
|
||||
**Return meaningful status codes:**
|
||||
```typescript
|
||||
200 // Success
|
||||
201 // Created
|
||||
400 // Bad Request (validation errors)
|
||||
401 // Unauthorized
|
||||
403 // Forbidden
|
||||
404 // Not Found
|
||||
500 // Internal Server Error
|
||||
```
|
||||
|
||||
**Structured error responses:**
|
||||
```typescript
|
||||
return NextResponse.json(
|
||||
{
|
||||
error: 'Resource not found',
|
||||
code: 'NOT_FOUND',
|
||||
timestamp: new Date().toISOString()
|
||||
},
|
||||
{ status: 404 }
|
||||
)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Theming Patterns
|
||||
|
||||
### next-themes Setup
|
||||
|
||||
**Root Layout (Server Component):**
|
||||
|
||||
```typescript
|
||||
// app/layout.tsx
|
||||
import { ThemeProvider } from 'next-themes'
|
||||
|
||||
export default function RootLayout({ children }) {
|
||||
return (
|
||||
<html lang="ro" suppressHydrationWarning>
|
||||
<body>
|
||||
<ThemeProvider
|
||||
attribute="class"
|
||||
defaultTheme="dark"
|
||||
enableSystem={false}
|
||||
storageKey="blog-theme"
|
||||
>
|
||||
{children}
|
||||
</ThemeProvider>
|
||||
</body>
|
||||
</html>
|
||||
)
|
||||
}
|
||||
```
|
||||
|
||||
**Critical:** Always add `suppressHydrationWarning` to `<html>` tag.
|
||||
|
||||
### Theme Toggle Component
|
||||
|
||||
**Avoid hydration mismatches with mounted state:**
|
||||
|
||||
```typescript
|
||||
// components/theme-toggle.tsx
|
||||
'use client'
|
||||
|
||||
import { useTheme } from 'next-themes'
|
||||
import { useEffect, useState } from 'react'
|
||||
|
||||
export function ThemeToggle() {
|
||||
const { theme, setTheme } = useTheme()
|
||||
const [mounted, setMounted] = useState(false)
|
||||
|
||||
// Prevent hydration mismatch
|
||||
useEffect(() => setMounted(true), [])
|
||||
|
||||
if (!mounted) {
|
||||
return <div className="w-9 h-9 animate-pulse" />
|
||||
}
|
||||
|
||||
return (
|
||||
<button onClick={() => setTheme(theme === 'dark' ? 'light' : 'dark')}>
|
||||
{theme === 'dark' ? '🌙' : '☀️'}
|
||||
</button>
|
||||
)
|
||||
}
|
||||
```
|
||||
|
||||
**Pattern:** Always check `mounted` state before rendering theme-dependent UI.
|
||||
|
||||
### CSS Variables for Theme Tokens
|
||||
|
||||
**Define in globals.css:**
|
||||
|
||||
```css
|
||||
@layer base {
|
||||
:root {
|
||||
--bg-primary: 255 255 255;
|
||||
--bg-secondary: 248 250 252;
|
||||
--text-primary: 15 23 42;
|
||||
--text-secondary: 51 65 85;
|
||||
}
|
||||
|
||||
.dark {
|
||||
--bg-primary: 24 24 27;
|
||||
--bg-secondary: 15 23 42;
|
||||
--text-primary: 241 245 249;
|
||||
--text-secondary: 203 213 225;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Use in components:**
|
||||
|
||||
```tsx
|
||||
<div className="bg-[rgb(var(--bg-primary))] text-[rgb(var(--text-primary))]">
|
||||
Theme-aware component
|
||||
</div>
|
||||
```
|
||||
|
||||
### Tailwind Configuration
|
||||
|
||||
**Enable class-based dark mode:**
|
||||
|
||||
```javascript
|
||||
// tailwind.config.js
|
||||
module.exports = {
|
||||
darkMode: 'class', // Required for next-themes
|
||||
theme: {
|
||||
extend: {
|
||||
colors: {
|
||||
'dark-primary': '#18181b',
|
||||
'accent': {
|
||||
DEFAULT: '#164e63',
|
||||
hover: '#155e75',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
**Use dark: variant:**
|
||||
|
||||
```tsx
|
||||
<div className="bg-slate-100 dark:bg-zinc-900 text-slate-900 dark:text-slate-100">
|
||||
Automatically switches based on theme
|
||||
</div>
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Styling Guidelines (Tailwind CSS)
|
||||
|
||||
### Utility-First Philosophy
|
||||
|
||||
**Prefer inline utilities over custom CSS:**
|
||||
|
||||
```tsx
|
||||
// ✅ Good: Inline utilities
|
||||
<article className="border-4 border-slate-800 p-6 bg-zinc-900 hover:border-cyan-900">
|
||||
<h2 className="text-2xl font-bold uppercase tracking-wider">Title</h2>
|
||||
</article>
|
||||
|
||||
// ❌ Avoid: @apply (increases bundle size)
|
||||
/* styles.css */
|
||||
.card {
|
||||
@apply border-4 border-slate-800 p-6 bg-zinc-900;
|
||||
}
|
||||
```
|
||||
|
||||
**Exception:** Only use `@apply` for truly global base styles in `globals.css`.
|
||||
|
||||
### Component Extraction
|
||||
|
||||
**Extract to React components when reused:**
|
||||
|
||||
```typescript
|
||||
// ✅ Extract repeated patterns to components
|
||||
export function Card({ children, className = "" }) {
|
||||
return (
|
||||
<div className={`border-4 border-slate-800 p-6 bg-zinc-900 ${className}`}>
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
// Usage
|
||||
<Card className="hover:border-cyan-900">
|
||||
<h2>Title</h2>
|
||||
</Card>
|
||||
```
|
||||
|
||||
**Don't extract:** One-off components or single-use patterns.
|
||||
|
||||
### Class Organization
|
||||
|
||||
**Group utilities logically:**
|
||||
|
||||
```tsx
|
||||
// Layout → Spacing → Colors → Typography → Effects
|
||||
<div className="
|
||||
flex flex-col // Layout
|
||||
gap-4 p-6 // Spacing
|
||||
bg-zinc-900 // Colors
|
||||
border-4 border-slate-800
|
||||
text-slate-100
|
||||
font-mono text-sm // Typography
|
||||
uppercase tracking-wider
|
||||
hover:border-cyan-900 // Effects
|
||||
transition-colors
|
||||
">
|
||||
```
|
||||
|
||||
**Tip:** Use Prettier plugin for automatic Tailwind class sorting.
|
||||
|
||||
### Responsive Design
|
||||
|
||||
**Mobile-first approach:**
|
||||
|
||||
```tsx
|
||||
// Base classes = mobile, add breakpoints for larger screens
|
||||
<div className="
|
||||
flex-col // Mobile: vertical stack
|
||||
md:flex-row // Tablet+: horizontal layout
|
||||
lg:gap-8 // Desktop: more spacing
|
||||
">
|
||||
```
|
||||
|
||||
**Standard breakpoints:**
|
||||
```
|
||||
sm: 640px // Small tablets
|
||||
md: 768px // Tablets
|
||||
lg: 1024px // Laptops
|
||||
xl: 1280px // Desktops
|
||||
2xl: 1536px // Large screens
|
||||
```
|
||||
|
||||
### Conditional Styling
|
||||
|
||||
**For complex conditions, use variants:**
|
||||
|
||||
```typescript
|
||||
const cardVariants = {
|
||||
default: "border-slate-800 bg-zinc-900",
|
||||
highlighted: "border-cyan-600 bg-cyan-950",
|
||||
error: "border-red-600 bg-red-950",
|
||||
}
|
||||
|
||||
<Card className={cardVariants[variant]} />
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Directory Structure Standards
|
||||
|
||||
### Project Organization
|
||||
|
||||
```
|
||||
app/
|
||||
├── (auth)/ # Route groups (no URL segment)
|
||||
│ ├── login/
|
||||
│ └── register/
|
||||
├── api/ # API routes
|
||||
│ └── posts/
|
||||
│ └── route.ts
|
||||
├── blog/
|
||||
│ ├── page.tsx
|
||||
│ └── [slug]/
|
||||
│ └── page.tsx
|
||||
├── @breadcrumbs/ # Parallel routes
|
||||
│ └── default.tsx
|
||||
├── layout.tsx # Root layout
|
||||
├── globals.css
|
||||
└── page.tsx
|
||||
|
||||
components/
|
||||
├── blog/ # Domain-specific components
|
||||
│ ├── post-card.tsx
|
||||
│ └── markdown-renderer.tsx
|
||||
├── layout/ # Layout components
|
||||
│ ├── header.tsx
|
||||
│ └── footer.tsx
|
||||
└── ui/ # Reusable UI primitives
|
||||
├── button.tsx
|
||||
└── card.tsx
|
||||
|
||||
lib/
|
||||
├── api/ # API clients, fetch wrappers
|
||||
│ └── client.ts
|
||||
├── types/ # TypeScript type definitions
|
||||
│ └── post.ts
|
||||
├── markdown.ts # Business logic modules
|
||||
├── seo.ts
|
||||
└── utils.ts # Pure utility functions
|
||||
|
||||
public/
|
||||
├── blog/ # Blog-specific assets
|
||||
│ └── images/
|
||||
└── icons/
|
||||
|
||||
content/ # Content files (outside app/)
|
||||
└── blog/
|
||||
└── posts.md
|
||||
```
|
||||
|
||||
### lib/ Organization
|
||||
|
||||
**Modules in lib/:**
|
||||
- Substantial business logic (markdown.ts, seo.ts)
|
||||
- API clients and data fetching
|
||||
- Database connections
|
||||
- Authentication logic
|
||||
|
||||
**Utils in lib/utils.ts:**
|
||||
- Pure helper functions
|
||||
- Formatters (formatDate, formatCurrency)
|
||||
- Validators (isEmail, isValidUrl)
|
||||
- String manipulations
|
||||
|
||||
**Types in lib/types/:**
|
||||
- Shared TypeScript interfaces
|
||||
- API response types
|
||||
- Domain models
|
||||
- Colocated with their modules when possible
|
||||
|
||||
### Component Organization
|
||||
|
||||
**By domain/feature:**
|
||||
```
|
||||
components/
|
||||
├── blog/ # Blog-specific
|
||||
│ ├── post-card.tsx
|
||||
│ ├── post-list.tsx
|
||||
│ └── markdown-renderer.tsx
|
||||
├── auth/ # Auth-specific
|
||||
│ ├── login-form.tsx
|
||||
│ └── signup-form.tsx
|
||||
└── ui/ # Reusable primitives
|
||||
├── button.tsx
|
||||
├── card.tsx
|
||||
└── input.tsx
|
||||
```
|
||||
|
||||
**Not by type:**
|
||||
```
|
||||
❌ Don't organize like this:
|
||||
components/
|
||||
├── forms/
|
||||
├── buttons/
|
||||
├── cards/
|
||||
└── modals/
|
||||
```
|
||||
|
||||
### Public Assets
|
||||
|
||||
**Organize by feature:**
|
||||
```
|
||||
public/
|
||||
├── blog/
|
||||
│ ├── images/
|
||||
│ └── thumbnails/
|
||||
├── icons/
|
||||
│ ├── social/
|
||||
│ └── ui/
|
||||
└── fonts/
|
||||
```
|
||||
|
||||
**Naming conventions:**
|
||||
- Use descriptive names: `hero-background.jpg` not `img1.jpg`
|
||||
- Use kebab-case: `user-avatar.png`
|
||||
- Include dimensions for images: `logo-512x512.png`
|
||||
|
||||
---
|
||||
|
||||
## TypeScript Best Practices
|
||||
|
||||
### Type Safety
|
||||
|
||||
**Avoid `any`:**
|
||||
```typescript
|
||||
// ❌ Bad
|
||||
function processData(data: any) { }
|
||||
|
||||
// ✅ Good
|
||||
function processData(data: unknown) {
|
||||
if (typeof data === 'string') {
|
||||
// TypeScript knows data is string here
|
||||
}
|
||||
}
|
||||
|
||||
// ✅ Better: Use specific types
|
||||
interface PostData {
|
||||
title: string
|
||||
content: string
|
||||
}
|
||||
function processData(data: PostData) { }
|
||||
```
|
||||
|
||||
### Infer Types from Zod
|
||||
|
||||
**Don't duplicate types:**
|
||||
|
||||
```typescript
|
||||
import { z } from 'zod'
|
||||
|
||||
// Define schema once
|
||||
const postSchema = z.object({
|
||||
title: z.string(),
|
||||
content: z.string(),
|
||||
tags: z.array(z.string()),
|
||||
})
|
||||
|
||||
// Infer TypeScript type
|
||||
type Post = z.infer<typeof postSchema>
|
||||
|
||||
// Now you have both runtime validation and compile-time types
|
||||
```
|
||||
|
||||
### Type Imports
|
||||
|
||||
**Use type imports for types only:**
|
||||
|
||||
```typescript
|
||||
// ✅ Good: Explicit type import
|
||||
import type { Metadata } from 'next'
|
||||
import type { Post } from '@/lib/types/post'
|
||||
|
||||
// ✅ Mixed: Regular and type imports
|
||||
import { getAllPosts } from '@/lib/markdown'
|
||||
import type { Post } from '@/lib/types/post'
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Next.js 16 Specific Patterns
|
||||
|
||||
### Async Server Components
|
||||
|
||||
**Fetch data directly in components:**
|
||||
|
||||
```typescript
|
||||
// app/blog/page.tsx
|
||||
export default async function BlogPage() {
|
||||
// Server-side data fetching (no useEffect needed)
|
||||
const posts = await getAllPosts()
|
||||
|
||||
return (
|
||||
<div>
|
||||
{posts.map(post => (
|
||||
<PostCard key={post.slug} post={post} />
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
```
|
||||
|
||||
### Static Generation
|
||||
|
||||
**Use generateStaticParams for dynamic routes:**
|
||||
|
||||
```typescript
|
||||
// app/blog/[slug]/page.tsx
|
||||
export async function generateStaticParams() {
|
||||
const posts = await getAllPosts()
|
||||
return posts.map(post => ({
|
||||
slug: post.slug.split('/'), // For catch-all routes
|
||||
}))
|
||||
}
|
||||
|
||||
export async function generateMetadata({ params }) {
|
||||
const post = getPostBySlug(params.slug.join('/'))
|
||||
return {
|
||||
title: post.frontmatter.title,
|
||||
description: post.frontmatter.description,
|
||||
}
|
||||
}
|
||||
|
||||
export default async function PostPage({ params }) {
|
||||
const post = getPostBySlug(params.slug.join('/'))
|
||||
return <article>{/* render post */}</article>
|
||||
}
|
||||
```
|
||||
|
||||
### Client Components
|
||||
|
||||
**Minimize 'use client' usage:**
|
||||
|
||||
```typescript
|
||||
// ❌ Unnecessary client component
|
||||
'use client'
|
||||
export function StaticCard({ title }) {
|
||||
return <div>{title}</div>
|
||||
}
|
||||
|
||||
// ✅ Keep as server component (default)
|
||||
export function StaticCard({ title }) {
|
||||
return <div>{title}</div>
|
||||
}
|
||||
|
||||
// ✅ Only use 'use client' when necessary
|
||||
'use client'
|
||||
import { useState } from 'react'
|
||||
|
||||
export function InteractiveCard({ title }) {
|
||||
const [isOpen, setIsOpen] = useState(false)
|
||||
return (
|
||||
<div onClick={() => setIsOpen(!isOpen)}>
|
||||
{title}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
```
|
||||
|
||||
**When to use 'use client':**
|
||||
- Using React hooks (useState, useEffect, etc.)
|
||||
- Using event handlers (onClick, onChange, etc.)
|
||||
- Using browser APIs (window, localStorage, etc.)
|
||||
- Using context consumers
|
||||
|
||||
### Parallel Routes
|
||||
|
||||
**Use for layout composition:**
|
||||
|
||||
```typescript
|
||||
// app/layout.tsx
|
||||
export default function RootLayout({
|
||||
children,
|
||||
breadcrumbs, // From @breadcrumbs parallel route
|
||||
}: {
|
||||
children: React.ReactNode
|
||||
breadcrumbs: React.ReactNode
|
||||
}) {
|
||||
return (
|
||||
<>
|
||||
{breadcrumbs}
|
||||
<main>{children}</main>
|
||||
</>
|
||||
)
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Common Pitfalls
|
||||
|
||||
### 1. Hydration Mismatches
|
||||
|
||||
**Problem:** Theme-dependent content renders differently on server vs client.
|
||||
|
||||
**Solution:** Use mounted state pattern (see Theming section).
|
||||
|
||||
### 2. Image Paths
|
||||
|
||||
**Problem:** Incorrect public asset paths.
|
||||
|
||||
```typescript
|
||||
// ❌ Wrong
|
||||
<Image src="blog/image.jpg" />
|
||||
|
||||
// ✅ Correct
|
||||
<Image src="/blog/image.jpg" /> // Leading slash
|
||||
```
|
||||
|
||||
### 3. Dynamic Route Params
|
||||
|
||||
**Problem:** Forgetting slug should be an array for catch-all routes.
|
||||
|
||||
```typescript
|
||||
// app/blog/[...slug]/page.tsx
|
||||
export async function generateStaticParams() {
|
||||
// ❌ Wrong
|
||||
return posts.map(post => ({ slug: post.slug }))
|
||||
|
||||
// ✅ Correct
|
||||
return posts.map(post => ({ slug: post.slug.split('/') }))
|
||||
}
|
||||
```
|
||||
|
||||
### 4. Over-using Client Components
|
||||
|
||||
**Problem:** Adding 'use client' unnecessarily.
|
||||
|
||||
**Solution:** Keep components as Server Components by default. Only add 'use client' when you need hooks, events, or browser APIs.
|
||||
|
||||
### 5. Date Formats
|
||||
|
||||
**Problem:** Inconsistent date formatting.
|
||||
|
||||
**Solution:** Use consistent ISO format (YYYY-MM-DD) in data, format for display:
|
||||
|
||||
```typescript
|
||||
// In frontmatter
|
||||
date: "2025-01-15"
|
||||
|
||||
// For display
|
||||
formatDate(post.frontmatter.date) // "15 ianuarie 2025" (Romanian)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Reference
|
||||
|
||||
For project-specific architecture and design philosophy, see `CLAUDE.md` at the root of this repository.
|
||||
|
||||
This skill focuses on coding conventions and standards. For architecture patterns, markdown processing, and industrial design aesthetic guidelines, refer to the main documentation.
|
||||
332
CLAUDE.md
Normal file
332
CLAUDE.md
Normal file
@@ -0,0 +1,332 @@
|
||||
# CLAUDE.md
|
||||
|
||||
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
||||
|
||||
## Project Overview
|
||||
|
||||
This is a **Next.js 16** blog/portfolio application built with **TypeScript**, **Tailwind CSS**, and **React 19**. The project uses **App Router** with Static Site Generation (SSG) for blog posts stored as Markdown files.
|
||||
|
||||
**Design Philosophy:** Industrial/SCP-inspired aesthetic with terminal/cyberpunk elements. Sharp edges, thick borders, monospace fonts, darker color palettes (slate/zinc/cyan/emerald tones). No modern Material UI feel - think government documents, classified files, brutal utilitarian design.
|
||||
|
||||
## Development Commands
|
||||
|
||||
```bash
|
||||
# Development server (runs on port 3030)
|
||||
npm run dev
|
||||
|
||||
# Production build
|
||||
npm run build
|
||||
|
||||
# Start production server
|
||||
npm run start
|
||||
|
||||
# Lint code
|
||||
npm run lint
|
||||
|
||||
# Validate all markdown posts (frontmatter, format, tags)
|
||||
npm run validate-posts
|
||||
```
|
||||
|
||||
## Architecture Overview
|
||||
|
||||
### Next.js 16 App Router Structure
|
||||
|
||||
```
|
||||
app/
|
||||
├── @breadcrumbs/ # Parallel route for breadcrumb navigation
|
||||
│ ├── default.tsx # Auto-generated breadcrumbs
|
||||
│ ├── blog/[...slug]/ # Post-specific breadcrumbs with titles
|
||||
│ ├── tags/[tag]/ # Tag-specific breadcrumbs
|
||||
│ └── about/ # Static breadcrumbs
|
||||
├── blog/
|
||||
│ ├── page.tsx # Blog listing with all posts
|
||||
│ └── [...slug]/ # Dynamic post routes (supports nested paths)
|
||||
│ ├── page.tsx # Post rendering with SSG
|
||||
│ └── not-found.tsx # Custom 404 for missing posts
|
||||
├── about/page.tsx
|
||||
├── layout.tsx # Root layout with metadata, fonts, breadcrumbs slot
|
||||
└── page.tsx # Landing page (hero + featured posts)
|
||||
```
|
||||
|
||||
**Key Architectural Patterns:**
|
||||
|
||||
1. **Parallel Routes:** `@breadcrumbs` slot renders dynamic navigation based on current route without prop drilling
|
||||
2. **Catch-all Routes:** `[...slug]` supports nested blog posts (e.g., `/blog/tech/article-name`)
|
||||
3. **Static Generation:** `generateStaticParams()` pre-renders all blog posts at build time
|
||||
4. **Server Components by Default:** All components are RSC unless marked with `'use client'`
|
||||
|
||||
### Markdown System
|
||||
|
||||
```
|
||||
content/blog/ # Markdown files (supports nested directories)
|
||||
├── example.md
|
||||
└── tech/
|
||||
└── article.md
|
||||
|
||||
lib/
|
||||
├── markdown.ts # Core markdown utilities
|
||||
│ ├── getPostBySlug() # Read single post with path sanitization
|
||||
│ ├── getAllPosts() # Get all posts, sorted by date, recursive
|
||||
│ ├── getRelatedPosts() # Find similar posts by tags
|
||||
│ └── validateFrontmatter()
|
||||
├── types/frontmatter.ts # TypeScript interfaces for Post, FrontMatter
|
||||
└── utils.ts # formatDate(), formatRelativeDate(), generateExcerpt()
|
||||
```
|
||||
|
||||
**Frontmatter Schema:**
|
||||
```yaml
|
||||
---
|
||||
title: string # Required
|
||||
description: string # Required
|
||||
date: "YYYY-MM-DD" # Required, ISO format
|
||||
author: string # Required
|
||||
tags: [string, string?, string?] # Max 3 tags
|
||||
image?: string # Optional hero image
|
||||
draft?: boolean # Exclude from listings if true
|
||||
---
|
||||
```
|
||||
|
||||
**Security:** Path sanitization prevents directory traversal attacks. All file reads use `path.resolve()` and validate paths stay within `content/blog/`.
|
||||
|
||||
### Components Organization
|
||||
|
||||
```
|
||||
components/
|
||||
├── blog/
|
||||
│ └── MarkdownRenderer.tsx # Client component for rendering markdown
|
||||
│ # Custom components: images (Next Image),
|
||||
│ # links (external vs internal), code blocks
|
||||
├── layout/
|
||||
│ ├── Breadcrumbs.tsx # Client component, uses usePathname()
|
||||
│ └── BreadcrumbsSchema.tsx # Schema.org structured data for SEO
|
||||
└── [future components]
|
||||
```
|
||||
|
||||
## Coding Standards for Next.js 16
|
||||
|
||||
### File Naming Conventions
|
||||
|
||||
**Files and Directories:**
|
||||
- Use **kebab-case** for all file names: `user-profile.tsx`, `blog-post.tsx`
|
||||
- Special Next.js files: `page.tsx`, `layout.tsx`, `not-found.tsx`, `loading.tsx`
|
||||
|
||||
**Component Names (inside files):**
|
||||
- Use **PascalCase**: `export function UserProfile()`, `export default BlogPost`
|
||||
|
||||
**Variables, Functions, Props:**
|
||||
- Use **camelCase**: `const userSettings = {}`, `function handleSubmit() {}`
|
||||
- Hooks: `useTheme`, `useMarkdown`
|
||||
|
||||
**Constants:**
|
||||
- Use **SCREAMING_SNAKE_CASE**: `const API_BASE_URL = "..."`
|
||||
|
||||
**Why kebab-case for files?**
|
||||
- Cross-platform compatibility (Windows vs Unix)
|
||||
- URL-friendly (file names often map to routes)
|
||||
- Easier to parse and read
|
||||
|
||||
### Theme Management & Reusability
|
||||
|
||||
**Recommended Pattern:** Use `next-themes` library for dark/light mode
|
||||
|
||||
```typescript
|
||||
// Root layout.tsx
|
||||
import { ThemeProvider } from 'next-themes'
|
||||
|
||||
export default function RootLayout({ children }) {
|
||||
return (
|
||||
<html suppressHydrationWarning>
|
||||
<body>
|
||||
<ThemeProvider
|
||||
attribute="class"
|
||||
defaultTheme="dark"
|
||||
enableSystem={false}
|
||||
storageKey="blog-theme"
|
||||
>
|
||||
{children}
|
||||
</ThemeProvider>
|
||||
</body>
|
||||
</html>
|
||||
)
|
||||
}
|
||||
```
|
||||
|
||||
**Client Component for Toggle:**
|
||||
```typescript
|
||||
// components/theme-toggle.tsx
|
||||
'use client'
|
||||
import { useTheme } from 'next-themes'
|
||||
import { useEffect, useState } from 'react'
|
||||
|
||||
export function ThemeToggle() {
|
||||
const { theme, setTheme } = useTheme()
|
||||
const [mounted, setMounted] = useState(false)
|
||||
|
||||
// Prevent hydration mismatch
|
||||
useEffect(() => setMounted(true), [])
|
||||
if (!mounted) return <div>...</div>
|
||||
|
||||
return <button onClick={() => setTheme(theme === 'dark' ? 'light' : 'dark')}>
|
||||
Toggle
|
||||
</button>
|
||||
}
|
||||
```
|
||||
|
||||
**Tailwind Configuration:**
|
||||
```javascript
|
||||
// tailwind.config.js
|
||||
module.exports = {
|
||||
darkMode: 'class', // Use 'class' strategy for next-themes
|
||||
theme: {
|
||||
extend: {
|
||||
colors: {
|
||||
// Define custom colors for consistency
|
||||
'dark-primary': '#18181b',
|
||||
'accent': { DEFAULT: '#164e63', hover: '#155e75' }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**CSS Variables Pattern:**
|
||||
```css
|
||||
/* globals.css */
|
||||
:root {
|
||||
--bg-primary: 255 255 255;
|
||||
--text-primary: 15 23 42;
|
||||
}
|
||||
|
||||
.dark {
|
||||
--bg-primary: 24 24 27;
|
||||
--text-primary: 241 245 249;
|
||||
}
|
||||
|
||||
/* Use in components */
|
||||
.card {
|
||||
@apply bg-[rgb(var(--bg-primary))] text-[rgb(var(--text-primary))];
|
||||
}
|
||||
```
|
||||
|
||||
### Provider Pattern Best Practices
|
||||
|
||||
1. **Server Component Boundary:** Keep `layout.tsx` as Server Component, wrap only `children` with Client Provider
|
||||
2. **Avoid Hydration Mismatches:** Always use `suppressHydrationWarning` on `<html>` tag
|
||||
3. **Client-Only Rendering:** Use `useEffect` + `mounted` state for theme-dependent UI
|
||||
4. **Context Consumption:** Only components using `useTheme()` need `'use client'` directive
|
||||
5. **No Prop Drilling:** Context makes theme accessible anywhere without passing props
|
||||
|
||||
### Next.js 16 Specific Patterns
|
||||
|
||||
**Async Server Components:**
|
||||
```typescript
|
||||
// app/blog/page.tsx
|
||||
export default async function BlogPage() {
|
||||
const posts = await getAllPosts() // Server-side data fetching
|
||||
return <div>{posts.map(...)}</div>
|
||||
}
|
||||
```
|
||||
|
||||
**Static Generation with Dynamic Routes:**
|
||||
```typescript
|
||||
// app/blog/[...slug]/page.tsx
|
||||
export async function generateStaticParams() {
|
||||
const posts = await getAllPosts()
|
||||
return posts.map(post => ({ slug: post.slug.split('/') }))
|
||||
}
|
||||
|
||||
export async function generateMetadata({ params }) {
|
||||
const post = getPostBySlug(params.slug.join('/'))
|
||||
return { title: post.frontmatter.title, ... }
|
||||
}
|
||||
```
|
||||
|
||||
**Parallel Routes for Layout Composition:**
|
||||
```typescript
|
||||
// app/layout.tsx
|
||||
export default function RootLayout({
|
||||
children,
|
||||
breadcrumbs, // From @breadcrumbs parallel route
|
||||
}: {
|
||||
children: React.ReactNode
|
||||
breadcrumbs: React.ReactNode
|
||||
}) {
|
||||
return <>
|
||||
{breadcrumbs}
|
||||
{children}
|
||||
</>
|
||||
}
|
||||
```
|
||||
|
||||
## Project-Specific Patterns
|
||||
|
||||
### Markdown Processing
|
||||
|
||||
- **Always validate paths:** Use `sanitizePath()` to prevent directory traversal
|
||||
- **Draft support:** Posts with `draft: true` are excluded from `getAllPosts()`
|
||||
- **Recursive directories:** Blog posts can be organized in subdirectories (`content/blog/tech/post.md`)
|
||||
- **Reading time:** Auto-calculated at 200 words/minute
|
||||
- **Date handling:** Use Romanian locale (`ro-RO`) for date formatting
|
||||
|
||||
### SEO & Metadata
|
||||
|
||||
- **Every page exports `metadata`:** Use Next.js 16's `Metadata` type
|
||||
- **Dynamic metadata:** Use `generateMetadata()` for blog posts
|
||||
- **Structured data:** Include Schema.org `BreadcrumbList` and `BlogPosting`
|
||||
- **OpenGraph images:** Reference `post.frontmatter.image` for social sharing
|
||||
|
||||
### Styling Guidelines
|
||||
|
||||
**Color Palette:**
|
||||
- Backgrounds: `zinc-900`, `slate-900`, `slate-800`
|
||||
- Accents: `cyan-900`, `emerald-900`, `teal-900`
|
||||
- Text: `slate-100`, `slate-300`, `slate-500`
|
||||
- Borders: `border-2`, `border-4` (thick, sharp)
|
||||
|
||||
**Design Tokens:**
|
||||
- **NO rounded corners:** Use `rounded-none` or omit (default is sharp)
|
||||
- **Monospace fonts:** Apply `font-mono` for terminal aesthetic
|
||||
- **Uppercase labels:** Use `uppercase tracking-wider` for headers
|
||||
- **Border-heavy design:** Thick borders (`border-4`) over shadows
|
||||
- **Classification labels:** Add metadata like "FILE#001", "DOCUMENT LEVEL-1"
|
||||
|
||||
**Typography:**
|
||||
- Primary font: `JetBrains Mono` (monospace)
|
||||
- Headings: `font-mono font-bold uppercase`
|
||||
- Body: `font-mono text-sm`
|
||||
- Code blocks: Sharp borders, dark background, no syntax highlighting (for terminal feel)
|
||||
|
||||
## Available Subagents
|
||||
|
||||
Use these specialized agents via `/spec-implementation-and-review` command:
|
||||
|
||||
- `nextjs-specialist` - Next.js 15/16, App Router, SSG, API routes
|
||||
- `ui-implementer` - UI implementation with shadcn/ui, Tailwind
|
||||
- `ui-css-specialist` - CSS layouts, styling, responsive design
|
||||
- `react-frontend-expert` - React components, hooks, state management
|
||||
- `nodejs-typescript-engineer` - TypeScript, Node.js backend
|
||||
|
||||
## Common Pitfalls
|
||||
|
||||
1. **Hydration Mismatches with Themes:** Always use `suppressHydrationWarning` on `<html>` and check `mounted` state before rendering theme-dependent UI
|
||||
2. **Image Paths:** Use `/` prefix for public assets (`/blog/image.jpg` not `blog/image.jpg`)
|
||||
3. **Dynamic Routes:** Remember to return `slug` as array in `generateStaticParams()` for catch-all routes
|
||||
4. **Client Components:** Minimize `'use client'` usage - only add when using hooks, event handlers, or browser APIs
|
||||
5. **Path Security:** Always use `sanitizePath()` when reading markdown files
|
||||
6. **Date Formats:** Use `YYYY-MM-DD` in frontmatter, convert to Romanian locale for display
|
||||
7. **Port Configuration:** Dev server runs on port **3030** (not default 3000)
|
||||
|
||||
## Type Safety
|
||||
|
||||
- All utilities in `lib/` are fully typed
|
||||
- Frontmatter structure enforced via `FrontMatter` interface
|
||||
- Use `Post` type for blog post objects
|
||||
- Avoid `any` - use `unknown` if type is truly unknown, then narrow
|
||||
|
||||
## Performance Notes
|
||||
|
||||
- **SSG by default:** All blog posts pre-rendered at build time
|
||||
- **Image optimization:** Use Next.js `<Image>` component
|
||||
- **Font optimization:** Google Fonts loaded via `next/font`
|
||||
- **No client-side data fetching:** Markdown loaded server-side only
|
||||
- **Static exports:** Pages are fully static HTML (no server required for hosting)
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Breadcrumbs } from '@/components/layout/Breadcrumbs';
|
||||
import { Breadcrumbs } from '@/components/layout/breadcrumbs';
|
||||
|
||||
export default function AboutBreadcrumb() {
|
||||
return (
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Breadcrumbs } from '@/components/layout/Breadcrumbs';
|
||||
import { Breadcrumbs } from '@/components/layout/breadcrumbs';
|
||||
import { getPostBySlug } from '@/lib/markdown';
|
||||
|
||||
interface BreadcrumbItem {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Breadcrumbs } from '@/components/layout/Breadcrumbs';
|
||||
import { Breadcrumbs } from '@/components/layout/breadcrumbs';
|
||||
|
||||
export default function BlogBreadcrumb() {
|
||||
return (
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use client';
|
||||
|
||||
import { Breadcrumbs } from '@/components/layout/Breadcrumbs';
|
||||
import { Breadcrumbs } from '@/components/layout/breadcrumbs';
|
||||
|
||||
export default function DefaultBreadcrumb() {
|
||||
return <Breadcrumbs />;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Breadcrumbs } from '@/components/layout/Breadcrumbs';
|
||||
import { Breadcrumbs } from '@/components/layout/breadcrumbs';
|
||||
|
||||
export default async function TagBreadcrumb({
|
||||
params,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Breadcrumbs } from '@/components/layout/Breadcrumbs';
|
||||
import { Breadcrumbs } from '@/components/layout/breadcrumbs';
|
||||
|
||||
export default function TagsBreadcrumb() {
|
||||
return (
|
||||
|
||||
180
app/blog/blog-client.tsx
Normal file
180
app/blog/blog-client.tsx
Normal file
@@ -0,0 +1,180 @@
|
||||
'use client'
|
||||
|
||||
import { useMemo, useState } from 'react'
|
||||
import { Post } from '@/lib/types/frontmatter'
|
||||
import { BlogCard } from '@/components/blog/blog-card'
|
||||
import { SearchBar } from '@/components/blog/search-bar'
|
||||
import { SortDropdown } from '@/components/blog/sort-dropdown'
|
||||
import { TagFilter } from '@/components/blog/tag-filter'
|
||||
import { Navbar } from '@/components/blog/navbar'
|
||||
|
||||
interface BlogPageClientProps {
|
||||
posts: Post[]
|
||||
allTags: string[]
|
||||
}
|
||||
|
||||
type SortOption = 'newest' | 'oldest' | 'title'
|
||||
|
||||
export default function BlogPageClient({ posts, allTags }: BlogPageClientProps) {
|
||||
const [searchQuery, setSearchQuery] = useState('')
|
||||
const [selectedTags, setSelectedTags] = useState<string[]>([])
|
||||
const [sortBy, setSortBy] = useState<SortOption>('newest')
|
||||
const [currentPage, setCurrentPage] = useState(1)
|
||||
const postsPerPage = 9
|
||||
|
||||
const filteredAndSortedPosts = useMemo(() => {
|
||||
let result = posts.filter((post) => {
|
||||
const matchesSearch =
|
||||
searchQuery === '' ||
|
||||
post.frontmatter.title.toLowerCase().includes(searchQuery.toLowerCase()) ||
|
||||
post.frontmatter.description.toLowerCase().includes(searchQuery.toLowerCase())
|
||||
|
||||
const matchesTags =
|
||||
selectedTags.length === 0 ||
|
||||
selectedTags.every((tag) => post.frontmatter.tags.includes(tag))
|
||||
|
||||
return matchesSearch && matchesTags
|
||||
})
|
||||
|
||||
result.sort((a, b) => {
|
||||
switch (sortBy) {
|
||||
case 'oldest':
|
||||
return new Date(a.frontmatter.date).getTime() - new Date(b.frontmatter.date).getTime()
|
||||
case 'title':
|
||||
return a.frontmatter.title.localeCompare(b.frontmatter.title)
|
||||
case 'newest':
|
||||
default:
|
||||
return new Date(b.frontmatter.date).getTime() - new Date(a.frontmatter.date).getTime()
|
||||
}
|
||||
})
|
||||
|
||||
return result
|
||||
}, [posts, searchQuery, selectedTags, sortBy])
|
||||
|
||||
const totalPages = Math.ceil(filteredAndSortedPosts.length / postsPerPage)
|
||||
const paginatedPosts = filteredAndSortedPosts.slice(
|
||||
(currentPage - 1) * postsPerPage,
|
||||
currentPage * postsPerPage
|
||||
)
|
||||
|
||||
const toggleTag = (tag: string) => {
|
||||
setSelectedTags((prev) =>
|
||||
prev.includes(tag) ? prev.filter((t) => t !== tag) : [...prev, tag]
|
||||
)
|
||||
setCurrentPage(1)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-zinc-900">
|
||||
<Navbar />
|
||||
|
||||
<div className="max-w-7xl mx-auto px-6 py-12">
|
||||
{/* Header */}
|
||||
<div className="border-l-4 border-cyan-400 pl-6 mb-12">
|
||||
<p className="font-mono text-xs text-zinc-500 uppercase tracking-widest mb-2">
|
||||
DATABASE QUERY // SEARCH RESULTS
|
||||
</p>
|
||||
<h1 className="text-4xl md:text-6xl font-mono font-bold text-zinc-100 uppercase tracking-tight">
|
||||
> BLOG ARCHIVE_
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
{/* Search Bar */}
|
||||
<div className="border-4 border-slate-700 bg-slate-900 p-6 mb-8">
|
||||
<div className="flex flex-col lg:flex-row gap-4">
|
||||
<SearchBar
|
||||
searchQuery={searchQuery}
|
||||
onSearchChange={(value) => {
|
||||
setSearchQuery(value)
|
||||
setCurrentPage(1)
|
||||
}}
|
||||
/>
|
||||
<SortDropdown
|
||||
sortBy={sortBy}
|
||||
onSortChange={setSortBy}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Tag Filters */}
|
||||
<TagFilter
|
||||
allTags={allTags}
|
||||
selectedTags={selectedTags}
|
||||
onToggleTag={toggleTag}
|
||||
onClearTags={() => {
|
||||
setSelectedTags([])
|
||||
setCurrentPage(1)
|
||||
}}
|
||||
/>
|
||||
|
||||
{/* Results Count */}
|
||||
<div className="mb-6">
|
||||
<p className="font-mono text-sm text-zinc-500 uppercase">
|
||||
FOUND {filteredAndSortedPosts.length} {filteredAndSortedPosts.length === 1 ? 'POST' : 'POSTS'}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Blog Grid */}
|
||||
{paginatedPosts.length > 0 ? (
|
||||
<div className="grid gap-8 lg:grid-cols-3 md:grid-cols-2 grid-cols-1 mb-12">
|
||||
{paginatedPosts.map((post, index) => {
|
||||
const hasImage = !!post.frontmatter.image
|
||||
let variant: 'image-top' | 'image-side' | 'text-only'
|
||||
|
||||
if (!hasImage) {
|
||||
variant = 'text-only'
|
||||
} else {
|
||||
variant = index % 3 === 1 ? 'image-side' : 'image-top'
|
||||
}
|
||||
|
||||
return <BlogCard key={post.slug} post={post} variant={variant} />
|
||||
})}
|
||||
</div>
|
||||
) : (
|
||||
<div className="border-4 border-slate-700 bg-slate-900 p-12 text-center">
|
||||
<p className="font-mono text-lg text-zinc-400 uppercase">
|
||||
NO POSTS FOUND // TRY DIFFERENT SEARCH TERMS
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Pagination */}
|
||||
{totalPages > 1 && (
|
||||
<div className="border-4 border-slate-700 bg-slate-900 p-6">
|
||||
<div className="flex items-center justify-between">
|
||||
<button
|
||||
onClick={() => setCurrentPage((p) => Math.max(1, p - 1))}
|
||||
disabled={currentPage === 1}
|
||||
className="px-6 py-3 font-mono text-sm uppercase border-2 border-slate-700 text-zinc-100 disabled:opacity-30 disabled:cursor-not-allowed hover:border-cyan-400 hover:text-cyan-400 transition-colors cursor-pointer"
|
||||
>
|
||||
< PREV
|
||||
</button>
|
||||
<div className="flex items-center gap-2">
|
||||
{Array.from({ length: totalPages }, (_, i) => i + 1).map((page) => (
|
||||
<button
|
||||
key={page}
|
||||
onClick={() => setCurrentPage(page)}
|
||||
className={`w-12 h-12 font-mono text-sm border-2 transition-colors cursor-pointer ${
|
||||
currentPage === page
|
||||
? 'bg-cyan-400 border-cyan-400 text-slate-900'
|
||||
: 'border-slate-700 text-zinc-400 hover:border-cyan-400 hover:text-cyan-400'
|
||||
}`}
|
||||
>
|
||||
{String(page).padStart(2, '0')}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
<button
|
||||
onClick={() => setCurrentPage((p) => Math.min(totalPages, p + 1))}
|
||||
disabled={currentPage === totalPages}
|
||||
className="px-6 py-3 font-mono text-sm uppercase border-2 border-slate-700 text-zinc-100 disabled:opacity-30 disabled:cursor-not-allowed hover:border-cyan-400 hover:text-cyan-400 transition-colors cursor-pointer"
|
||||
>
|
||||
NEXT >
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
10
app/blog/layout.tsx
Normal file
10
app/blog/layout.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import { Metadata } from 'next'
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'Blog',
|
||||
description: 'Toate articolele din blog',
|
||||
}
|
||||
|
||||
export default function BlogLayout({ children }: { children: React.ReactNode }) {
|
||||
return <>{children}</>
|
||||
}
|
||||
@@ -1,95 +1,9 @@
|
||||
import { Metadata } from 'next'
|
||||
import Link from 'next/link'
|
||||
import { getAllPosts } from '@/lib/markdown'
|
||||
import { formatDate } from '@/lib/utils'
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'Blog',
|
||||
description: 'Toate articolele din blog',
|
||||
}
|
||||
|
||||
function PostCard({ post }: { post: any }) {
|
||||
return (
|
||||
<article className="border-b border-gray-200 dark:border-gray-700 pb-8 mb-8 last:border-0">
|
||||
<div className="flex flex-col lg:flex-row gap-6">
|
||||
{post.frontmatter.image && (
|
||||
<div className="lg:w-1/3">
|
||||
<img src={post.frontmatter.image} alt={post.frontmatter.title} className="w-full h-48 lg:h-full object-cover rounded-lg" />
|
||||
</div>
|
||||
)}
|
||||
<div className={post.frontmatter.image ? 'lg:w-2/3' : 'w-full'}>
|
||||
<div className="flex items-center gap-4 text-sm text-gray-500 mb-2">
|
||||
<time dateTime={post.frontmatter.date}>{formatDate(post.frontmatter.date)}</time>
|
||||
<span>•</span>
|
||||
<span>{post.readingTime} min citire</span>
|
||||
<span>•</span>
|
||||
<span>{post.frontmatter.author}</span>
|
||||
</div>
|
||||
<h2 className="text-2xl font-bold mb-3">
|
||||
<Link href={`/blog/${post.slug}`} className="hover:text-primary-600 transition">
|
||||
{post.frontmatter.title}
|
||||
</Link>
|
||||
</h2>
|
||||
<p className="text-gray-600 dark:text-gray-400 mb-4">{post.frontmatter.description}</p>
|
||||
{post.frontmatter.tags && post.frontmatter.tags.length > 0 && (
|
||||
<div className="flex flex-wrap gap-2 mb-4">
|
||||
{post.frontmatter.tags.map((tag: string) => (
|
||||
<span key={tag} className="px-3 py-1 bg-gray-100 dark:bg-gray-800 text-sm rounded-full">
|
||||
#{tag}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
<Link href={`/blog/${post.slug}`} className="inline-flex items-center text-primary-600 hover:text-primary-700 transition">
|
||||
Citește articolul complet
|
||||
<svg className="ml-2 w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 5l7 7-7 7" />
|
||||
</svg>
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
)
|
||||
}
|
||||
|
||||
function BlogFilters({ totalPosts }: { totalPosts: number }) {
|
||||
return (
|
||||
<div className="bg-gray-50 dark:bg-gray-800 rounded-lg p-6 mb-8">
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<h1 className="text-3xl font-bold mb-2">Articole Blog</h1>
|
||||
<p className="text-gray-600 dark:text-gray-400">
|
||||
{totalPosts} {totalPosts === 1 ? 'articol' : 'articole'} publicate
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
import BlogPageClient from './blog-client'
|
||||
|
||||
export default async function BlogPage() {
|
||||
const posts = await getAllPosts()
|
||||
const allTags = Array.from(new Set(posts.flatMap((post) => post.frontmatter.tags))).sort()
|
||||
|
||||
if (posts.length === 0) {
|
||||
return (
|
||||
<div className="text-center py-12">
|
||||
<h1 className="text-3xl font-bold mb-4">Blog</h1>
|
||||
<p className="text-gray-600 dark:text-gray-400 mb-8">Nu există articole publicate încă.</p>
|
||||
<Link href="/" className="inline-block px-6 py-3 bg-primary-600 text-white rounded-lg hover:bg-primary-700 transition">
|
||||
Înapoi la pagina principală
|
||||
</Link>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="max-w-4xl mx-auto">
|
||||
<BlogFilters totalPosts={posts.length} />
|
||||
<div>
|
||||
{posts.map((post) => (
|
||||
<PostCard key={post.slug} post={post} />
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
return <BlogPageClient posts={posts} allTags={allTags} />
|
||||
}
|
||||
|
||||
299
app/globals.css
299
app/globals.css
@@ -1,5 +1,47 @@
|
||||
@import "tailwindcss";
|
||||
|
||||
@theme {
|
||||
--color-*: initial;
|
||||
}
|
||||
|
||||
@variant dark (&:where(.dark, .dark *));
|
||||
|
||||
@layer base {
|
||||
:root {
|
||||
/* Light mode colors */
|
||||
--bg-primary: 241 245 249;
|
||||
--bg-secondary: 226 232 240;
|
||||
--bg-tertiary: 203 213 225;
|
||||
--text-primary: 15 23 42;
|
||||
--text-secondary: 51 65 85;
|
||||
--text-muted: 100 116 139;
|
||||
--border-primary: 203 213 225;
|
||||
--border-subtle: 226 232 240;
|
||||
|
||||
--neon-pink: #8b4a5e;
|
||||
--neon-cyan: #4a7b85;
|
||||
--neon-purple: #6b5583;
|
||||
--neon-magenta: #8b4a7e;
|
||||
}
|
||||
|
||||
.dark {
|
||||
/* Dark mode colors - INDUSTRIAL */
|
||||
--bg-primary: 24 24 27;
|
||||
--bg-secondary: 15 23 42;
|
||||
--bg-tertiary: 30 41 59;
|
||||
--text-primary: 241 245 249;
|
||||
--text-secondary: 203 213 225;
|
||||
--text-muted: 100 116 139;
|
||||
--border-primary: 71 85 105;
|
||||
--border-subtle: 30 41 59;
|
||||
|
||||
--neon-pink: #9b5a6e;
|
||||
--neon-cyan: #5a8b95;
|
||||
--neon-purple: #7b6593;
|
||||
--neon-magenta: #9b5a8e;
|
||||
}
|
||||
}
|
||||
|
||||
@layer utilities {
|
||||
.scrollbar-hide {
|
||||
-ms-overflow-style: none;
|
||||
@@ -11,21 +53,99 @@
|
||||
|
||||
/* Industrial/Terminal aesthetic utilities */
|
||||
.grid-bg {
|
||||
background-image: url('/grid.svg');
|
||||
background-image:
|
||||
linear-gradient(rgba(100, 116, 139, 0.1) 1px, transparent 1px),
|
||||
linear-gradient(90deg, rgba(100, 116, 139, 0.1) 1px, transparent 1px);
|
||||
background-size: 20px 20px;
|
||||
}
|
||||
|
||||
/* Noise texture */
|
||||
.noise-bg {
|
||||
background-image: url('/noise.svg');
|
||||
opacity: 0.03;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
/* Scanline effect */
|
||||
.scanline {
|
||||
background: repeating-linear-gradient(
|
||||
background: linear-gradient(
|
||||
0deg,
|
||||
transparent,
|
||||
transparent 2px,
|
||||
rgba(0, 0, 0, 0.3) 2px,
|
||||
rgba(0, 0, 0, 0.3) 4px
|
||||
transparent 0%,
|
||||
rgba(6, 182, 212, 0.1) 50%,
|
||||
transparent 100%
|
||||
);
|
||||
background-size: 100% 3px;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.scanline::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: linear-gradient(
|
||||
to bottom,
|
||||
transparent 0%,
|
||||
rgba(6, 182, 212, 0.05) 50%,
|
||||
transparent 100%
|
||||
);
|
||||
animation: scanline 8s linear infinite;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
/* CRT screen curvature effect */
|
||||
.crt-effect {
|
||||
animation: flicker 0.15s infinite;
|
||||
}
|
||||
|
||||
/* Glitch text effect */
|
||||
.glitch-text {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.glitch-text::before,
|
||||
.glitch-text::after {
|
||||
content: attr(data-text);
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.glitch-text.active::before {
|
||||
color: #06b6d4;
|
||||
animation: glitch-1 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
|
||||
clip-path: polygon(0 0, 100% 0, 100% 45%, 0 45%);
|
||||
transform: translate(-2px, -2px);
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.glitch-text.active::after {
|
||||
color: #10b981;
|
||||
animation: glitch-2 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
|
||||
clip-path: polygon(0 55%, 100% 55%, 100% 100%, 0 100%);
|
||||
transform: translate(2px, 2px);
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
@keyframes glitch-1 {
|
||||
0%, 100% { clip-path: polygon(0 0, 100% 0, 100% 45%, 0 45%); transform: translate(0); }
|
||||
20% { clip-path: polygon(0 15%, 100% 15%, 100% 65%, 0 65%); }
|
||||
40% { clip-path: polygon(0 30%, 100% 30%, 100% 70%, 0 70%); }
|
||||
60% { clip-path: polygon(0 5%, 100% 5%, 100% 60%, 0 60%); }
|
||||
80% { clip-path: polygon(0 25%, 100% 25%, 100% 40%, 0 40%); }
|
||||
}
|
||||
|
||||
@keyframes glitch-2 {
|
||||
0%, 100% { clip-path: polygon(0 55%, 100% 55%, 100% 100%, 0 100%); transform: translate(0); }
|
||||
20% { clip-path: polygon(0 70%, 100% 70%, 100% 95%, 0 95%); }
|
||||
40% { clip-path: polygon(0 40%, 100% 40%, 100% 85%, 0 85%); }
|
||||
60% { clip-path: polygon(0 60%, 100% 60%, 100% 100%, 0 100%); }
|
||||
80% { clip-path: polygon(0 50%, 100% 50%, 100% 90%, 0 90%); }
|
||||
}
|
||||
|
||||
/* Grayscale filter with instant toggle */
|
||||
@@ -36,4 +156,171 @@
|
||||
.grayscale-0 {
|
||||
filter: grayscale(0%);
|
||||
}
|
||||
|
||||
/* Cyberpunk Glitch Effect for Button */
|
||||
.glitch-btn {
|
||||
position: relative;
|
||||
animation: glitch 300ms cubic-bezier(.25, .46, .45, .94);
|
||||
}
|
||||
|
||||
.glitch-layer {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
opacity: 0.8;
|
||||
clip-path: polygon(0 0, 100% 0, 100% 45%, 0 45%);
|
||||
}
|
||||
|
||||
.glitch-layer:first-of-type {
|
||||
animation: glitch-1 300ms cubic-bezier(.25, .46, .45, .94);
|
||||
color: rgb(6 182 212); /* cyan-500 */
|
||||
transform: translate(-2px, 0);
|
||||
clip-path: polygon(0 0, 100% 0, 100% 35%, 0 35%);
|
||||
}
|
||||
|
||||
.glitch-layer:last-of-type {
|
||||
animation: glitch-2 300ms cubic-bezier(.25, .46, .45, .94);
|
||||
color: rgb(16 185 129); /* emerald-500 */
|
||||
transform: translate(2px, 0);
|
||||
clip-path: polygon(0 65%, 100% 65%, 100% 100%, 0 100%);
|
||||
}
|
||||
|
||||
@keyframes glitch-1 {
|
||||
0%, 100% {
|
||||
transform: translate(0, 0);
|
||||
clip-path: polygon(0 0, 100% 0, 100% 35%, 0 35%);
|
||||
}
|
||||
25% {
|
||||
transform: translate(-3px, 2px);
|
||||
clip-path: polygon(0 10%, 100% 10%, 100% 45%, 0 45%);
|
||||
}
|
||||
50% {
|
||||
transform: translate(3px, -2px);
|
||||
clip-path: polygon(0 20%, 100% 20%, 100% 55%, 0 55%);
|
||||
}
|
||||
75% {
|
||||
transform: translate(-2px, -1px);
|
||||
clip-path: polygon(0 5%, 100% 5%, 100% 40%, 0 40%);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes glitch-2 {
|
||||
0%, 100% {
|
||||
transform: translate(0, 0);
|
||||
clip-path: polygon(0 65%, 100% 65%, 100% 100%, 0 100%);
|
||||
}
|
||||
25% {
|
||||
transform: translate(3px, -2px);
|
||||
clip-path: polygon(0 55%, 100% 55%, 100% 90%, 0 90%);
|
||||
}
|
||||
50% {
|
||||
transform: translate(-3px, 2px);
|
||||
clip-path: polygon(0 45%, 100% 45%, 100% 80%, 0 80%);
|
||||
}
|
||||
75% {
|
||||
transform: translate(2px, 1px);
|
||||
clip-path: polygon(0 60%, 100% 60%, 100% 95%, 0 95%);
|
||||
}
|
||||
}
|
||||
|
||||
/* Border Pulse Animation */
|
||||
.border-pulse {
|
||||
animation: pulse-border 2s ease-in-out infinite;
|
||||
}
|
||||
|
||||
/* Screen Flicker Effect */
|
||||
body.screen-flicker {
|
||||
animation: flicker 150ms ease-in-out;
|
||||
}
|
||||
|
||||
body.screen-flicker::before {
|
||||
content: '';
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: rgba(6, 182, 212, 0.1);
|
||||
pointer-events: none;
|
||||
z-index: 9999;
|
||||
animation: flicker 150ms ease-in-out;
|
||||
}
|
||||
|
||||
/* CRT Noise Texture */
|
||||
@supports (filter: url('#noise')) {
|
||||
.noise-bg {
|
||||
filter: url('#noise');
|
||||
}
|
||||
}
|
||||
|
||||
/* SCP-style subtle flicker hover */
|
||||
@keyframes scp-flicker {
|
||||
0%, 100% {
|
||||
border-color: rgb(71 85 105);
|
||||
box-shadow: 0 0 0 rgba(90, 139, 149, 0);
|
||||
transform: translate(0, 0);
|
||||
}
|
||||
20% {
|
||||
border-color: var(--neon-cyan);
|
||||
box-shadow: 0 0 3px rgba(90, 139, 149, 0.3);
|
||||
transform: translate(-0.5px, 0);
|
||||
}
|
||||
40% {
|
||||
border-color: rgb(71 85 105);
|
||||
box-shadow: 0 0 0 rgba(90, 139, 149, 0);
|
||||
transform: translate(0, 0);
|
||||
}
|
||||
60% {
|
||||
border-color: var(--neon-cyan);
|
||||
box-shadow: 0 0 2px rgba(90, 139, 149, 0.2);
|
||||
transform: translate(0.5px, 0);
|
||||
}
|
||||
}
|
||||
|
||||
.cyber-glitch-hover {
|
||||
transition: all 0.15s ease;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.cyber-glitch-hover:hover {
|
||||
animation: scp-flicker 150ms ease-in-out 3;
|
||||
border-color: var(--neon-cyan) !important;
|
||||
box-shadow: 0 1px 4px rgba(90, 139, 149, 0.15), inset 0 0 8px rgba(90, 139, 149, 0.05);
|
||||
}
|
||||
|
||||
/* Navbar hide on scroll */
|
||||
.navbar-hidden {
|
||||
transform: translateY(-100%);
|
||||
transition: transform 0.3s ease-in-out;
|
||||
}
|
||||
|
||||
.navbar-visible {
|
||||
transform: translateY(0);
|
||||
transition: transform 0.3s ease-in-out;
|
||||
}
|
||||
|
||||
/* Cyberpunk neon glow on focus - 80s style */
|
||||
.cyber-focus:focus {
|
||||
outline: none;
|
||||
box-shadow:
|
||||
0 0 10px var(--neon-cyan),
|
||||
0 0 20px rgba(0, 255, 255, 0.5),
|
||||
inset 0 0 10px rgba(0, 255, 255, 0.1);
|
||||
border-color: var(--neon-cyan);
|
||||
}
|
||||
|
||||
.cyber-focus-pink:focus {
|
||||
outline: none;
|
||||
box-shadow:
|
||||
0 0 10px var(--neon-pink),
|
||||
0 0 20px rgba(255, 0, 128, 0.5),
|
||||
inset 0 0 10px rgba(255, 0, 128, 0.1);
|
||||
border-color: var(--neon-pink);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { Metadata } from 'next'
|
||||
import { JetBrains_Mono } from 'next/font/google'
|
||||
import './globals.css'
|
||||
import { ThemeProvider } from '@/providers/providers'
|
||||
|
||||
const jetbrainsMono = JetBrains_Mono({ subsets: ['latin'], variable: '--font-mono' })
|
||||
|
||||
@@ -33,20 +34,30 @@ export default function RootLayout({
|
||||
children: React.ReactNode
|
||||
}) {
|
||||
return (
|
||||
<html lang="ro" className={jetbrainsMono.variable}>
|
||||
<body className="font-mono bg-zinc-900 text-slate-100">
|
||||
{children}
|
||||
<html lang="ro" suppressHydrationWarning className={jetbrainsMono.variable}>
|
||||
<body className="font-mono bg-zinc-50 text-slate-900 dark:bg-zinc-900 dark:text-slate-100 transition-colors duration-300">
|
||||
<ThemeProvider
|
||||
attribute="class"
|
||||
defaultTheme="dark"
|
||||
enableSystem={false}
|
||||
storageKey="blog-theme"
|
||||
disableTransitionOnChange={false}
|
||||
>
|
||||
<div className="flex flex-col min-h-screen">
|
||||
<div className="flex-1">{children}</div>
|
||||
|
||||
{/* Footer - from worktree-agent-1 */}
|
||||
<footer className="border-t-4 border-slate-800 bg-slate-900">
|
||||
<footer className="mt-auto border-t-4 border-slate-300 dark:border-slate-800 bg-zinc-100 dark:bg-slate-900 transition-colors duration-300">
|
||||
<div className="container mx-auto px-4 py-8">
|
||||
<div className="border-2 border-slate-800 p-6">
|
||||
<p className="text-center text-slate-500 font-mono text-xs uppercase tracking-wider">
|
||||
© 2025 // BLOG & PORTOFOLIU // ALL RIGHTS RESERVED
|
||||
<div className="border-2 border-slate-300 dark:border-slate-800 p-6">
|
||||
<p className="text-center text-slate-500 dark:text-slate-500 font-mono text-xs uppercase tracking-wider">
|
||||
© 2025 <span style={{ color: 'var(--neon-cyan)' }}>//</span> BLOG & <span style={{ color: 'var(--neon-pink)' }}>PORTOFOLIU</span> <span style={{ color: 'var(--neon-cyan)' }}>//</span> ALL RIGHTS RESERVED
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
</ThemeProvider>
|
||||
</body>
|
||||
</html>
|
||||
)
|
||||
|
||||
110
app/page.tsx
110
app/page.tsx
@@ -2,48 +2,50 @@ import Link from 'next/link'
|
||||
import Image from 'next/image'
|
||||
import { getAllPosts } from '@/lib/markdown'
|
||||
import { formatDate } from '@/lib/utils'
|
||||
import { ThemeToggle } from '@/components/theme-toggle'
|
||||
|
||||
export default async function HomePage() {
|
||||
const allPosts = await getAllPosts()
|
||||
const featuredPosts = allPosts.slice(0, 6)
|
||||
|
||||
return (
|
||||
<main className="min-h-screen bg-zinc-900">
|
||||
<main className="min-h-screen bg-zinc-50 dark:bg-zinc-900 transition-colors duration-300">
|
||||
{/* Hero Section - from worktree-agent-2 */}
|
||||
<section className="relative min-h-screen flex items-center justify-center bg-zinc-900 overflow-hidden">
|
||||
<section className="relative min-h-screen flex items-center justify-center bg-zinc-100 dark:bg-zinc-900 overflow-hidden transition-colors duration-300">
|
||||
<div className="absolute inset-0 grid-bg opacity-10"></div>
|
||||
<div className="absolute inset-0 scanline"></div>
|
||||
<div className="absolute inset-0 noise-bg"></div>
|
||||
|
||||
<div className="relative z-10 max-w-5xl mx-auto px-6 w-full">
|
||||
<div className="border-4 border-slate-700 bg-slate-900/80 p-8 md:p-12">
|
||||
<div className="border-4 border-slate-300 dark:border-slate-700 bg-white/80 dark:bg-slate-900/80 p-8 md:p-12 transition-colors duration-300">
|
||||
{/* Logo */}
|
||||
<div className="mb-8 flex items-center justify-between border-b-2 border-slate-800 pb-4">
|
||||
<div className="mb-8 flex items-center justify-between border-b-2 border-slate-300 dark:border-slate-800 pb-4">
|
||||
<div className="flex items-center gap-3">
|
||||
<Image src="/logo.png" alt="Logo" width={32} height={32} className="opacity-80" />
|
||||
<span className="font-mono text-xs text-slate-500 uppercase tracking-widest">TERMINAL:// V2.0</span>
|
||||
</div>
|
||||
<div className="flex gap-4">
|
||||
<Link href="/blog" className="font-mono text-xs text-slate-400 uppercase tracking-wider hover:text-cyan-400">[BLOG]</Link>
|
||||
<Link href="/about" className="font-mono text-xs text-slate-400 uppercase tracking-wider hover:text-cyan-400">[ABOUT]</Link>
|
||||
<div className="flex gap-4 items-center">
|
||||
<Link href="/blog" className="font-mono text-xs text-slate-600 dark:text-slate-400 uppercase tracking-wider hover:text-cyan-600 dark:hover:text-cyan-400">[BLOG]</Link>
|
||||
<Link href="/about" className="font-mono text-xs text-slate-600 dark:text-slate-400 uppercase tracking-wider hover:text-cyan-600 dark:hover:text-cyan-400">[ABOUT]</Link>
|
||||
<ThemeToggle />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="border-l-4 border-cyan-900 pl-6 mb-8">
|
||||
<p className="font-mono text-xs text-slate-500 uppercase tracking-widest mb-2">DOCUMENT LEVEL-1 // CLASSIFIED</p>
|
||||
<h1 className="text-4xl md:text-6xl lg:text-7xl font-mono font-bold text-slate-100 uppercase tracking-tight mb-6">
|
||||
<div className="border-l-4 border-cyan-700 dark:border-cyan-900 pl-6 mb-8">
|
||||
<p className="font-mono text-xs text-slate-500 dark:text-slate-500 uppercase tracking-widest mb-2">DOCUMENT LEVEL-1 // CLASSIFIED</p>
|
||||
<h1 className="text-4xl md:text-6xl lg:text-7xl font-mono font-bold text-slate-900 dark:text-slate-100 uppercase tracking-tight mb-6">
|
||||
BUILD. WRITE.<br/>SHARE.
|
||||
</h1>
|
||||
<p className="text-base md:text-lg lg:text-xl text-slate-400 font-mono leading-relaxed max-w-2xl">
|
||||
<p className="text-base md:text-lg lg:text-xl text-slate-700 dark:text-slate-400 font-mono leading-relaxed max-w-2xl">
|
||||
> Explorează idei despre dezvoltare, design și tehnologie_
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="flex gap-4 flex-wrap mt-12">
|
||||
<Link href="/blog" className="px-6 md:px-8 py-3 md:py-4 bg-cyan-900 text-slate-100 border-2 border-cyan-700 font-mono font-bold uppercase text-xs md:text-sm tracking-wider hover:bg-cyan-800 hover:border-cyan-600 rounded-none">
|
||||
<Link href="/blog" className="px-6 md:px-8 py-3 md:py-4 bg-cyan-700 dark:bg-cyan-900 text-white dark:text-slate-100 border-2 border-cyan-600 dark:border-cyan-700 font-mono font-bold uppercase text-xs md:text-sm tracking-wider hover:bg-cyan-600 dark:hover:bg-cyan-800 hover:border-cyan-500 dark:hover:border-cyan-600 rounded-none transition-colors duration-200">
|
||||
[EXPLOREAZĂ BLOG]
|
||||
</Link>
|
||||
<Link href="/about" className="px-6 md:px-8 py-3 md:py-4 bg-transparent text-slate-300 border-2 border-slate-700 font-mono font-bold uppercase text-xs md:text-sm tracking-wider hover:bg-slate-800 hover:border-slate-600 rounded-none">
|
||||
<Link href="/about" className="px-6 md:px-8 py-3 md:py-4 bg-transparent text-slate-700 dark:text-slate-300 border-2 border-slate-400 dark:border-slate-700 font-mono font-bold uppercase text-xs md:text-sm tracking-wider hover:bg-slate-200 dark:hover:bg-slate-800 hover:border-slate-500 dark:hover:border-slate-600 rounded-none transition-colors duration-200">
|
||||
[DESPRE MINE]
|
||||
</Link>
|
||||
</div>
|
||||
@@ -52,13 +54,13 @@ export default async function HomePage() {
|
||||
</section>
|
||||
|
||||
{/* Featured Posts Grid - from worktree-agent-1 */}
|
||||
<section className="py-24 bg-slate-900 border-t-4 border-slate-800">
|
||||
<section className="py-24 bg-zinc-100 dark:bg-slate-900 border-t-4 border-slate-300 dark:border-slate-800 transition-colors duration-300">
|
||||
<div className="max-w-7xl mx-auto px-6">
|
||||
<div className="border-l-4 border-emerald-900 pl-6 mb-12">
|
||||
<p className="font-mono text-xs text-slate-500 uppercase tracking-widest mb-2">
|
||||
<div className="border-l-4 border-emerald-700 dark:border-emerald-900 pl-6 mb-12">
|
||||
<p className="font-mono text-xs text-slate-500 dark:text-slate-500 uppercase tracking-widest mb-2">
|
||||
ARCHIVE ACCESS // RECENT ENTRIES
|
||||
</p>
|
||||
<h2 className="text-3xl md:text-5xl font-mono font-bold text-slate-100 uppercase tracking-tight">
|
||||
<h2 className="text-3xl md:text-5xl font-mono font-bold text-slate-900 dark:text-slate-100 uppercase tracking-tight">
|
||||
> POSTĂRI RECENTE_
|
||||
</h2>
|
||||
</div>
|
||||
@@ -67,37 +69,37 @@ export default async function HomePage() {
|
||||
{featuredPosts.map((post, index) => (
|
||||
<article
|
||||
key={post.slug}
|
||||
className="group relative bg-slate-900 border-4 border-slate-700 overflow-hidden hover:border-cyan-900"
|
||||
className="group relative bg-white dark:bg-slate-900 border-4 border-slate-300 dark:border-slate-700 overflow-hidden hover:border-cyan-700 dark:hover:border-cyan-900 transition-colors duration-300"
|
||||
>
|
||||
<div className="aspect-video relative overflow-hidden bg-zinc-900">
|
||||
<div className="aspect-video relative overflow-hidden bg-zinc-200 dark:bg-zinc-900">
|
||||
{post.frontmatter.image ? (
|
||||
<Image
|
||||
src={post.frontmatter.image}
|
||||
alt={post.frontmatter.title}
|
||||
fill
|
||||
className="object-cover grayscale group-hover:grayscale-0"
|
||||
className="object-cover grayscale group-hover:grayscale-0 transition-all duration-300"
|
||||
/>
|
||||
) : (
|
||||
<div className="w-full h-full bg-zinc-800 flex items-center justify-center">
|
||||
<span className="font-mono text-6xl text-slate-700">#{String(index + 1).padStart(2, '0')}</span>
|
||||
<div className="w-full h-full bg-zinc-300 dark:bg-zinc-800 flex items-center justify-center">
|
||||
<span className="font-mono text-6xl text-slate-400 dark:text-slate-700">#{String(index + 1).padStart(2, '0')}</span>
|
||||
</div>
|
||||
)}
|
||||
<div className="absolute inset-0 bg-zinc-900/60"></div>
|
||||
<div className="absolute top-0 left-0 right-0 bg-slate-900 border-b-2 border-slate-700 px-4 py-2">
|
||||
<span className="font-mono text-xs text-cyan-400 uppercase tracking-wider">
|
||||
<div className="absolute inset-0 bg-zinc-100/60 dark:bg-zinc-900/60"></div>
|
||||
<div className="absolute top-0 left-0 right-0 bg-white/90 dark:bg-slate-900 border-b-2 border-slate-300 dark:border-slate-700 px-4 py-2">
|
||||
<span className="font-mono text-xs text-cyan-600 dark:text-cyan-400 uppercase tracking-wider">
|
||||
FILE#{String(index + 1).padStart(3, '0')} // {post.frontmatter.category}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="p-6 border-t-4 border-slate-800">
|
||||
<div className="border-l-4 border-emerald-900 pl-4">
|
||||
<h3 className="text-xl font-mono font-bold text-slate-100 mb-3 uppercase tracking-tight">
|
||||
<div className="p-6 border-t-4 border-slate-300 dark:border-slate-800">
|
||||
<div className="border-l-4 border-emerald-700 dark:border-emerald-900 pl-4">
|
||||
<h3 className="text-xl font-mono font-bold text-slate-900 dark:text-slate-100 mb-3 uppercase tracking-tight">
|
||||
{post.frontmatter.title}
|
||||
</h3>
|
||||
<p className="text-slate-400 text-sm leading-relaxed mb-4 font-mono">
|
||||
<p className="text-slate-600 dark:text-slate-400 text-sm leading-relaxed mb-4 font-mono">
|
||||
{post.frontmatter.description}
|
||||
</p>
|
||||
<div className="flex items-center gap-4 text-xs text-slate-500 font-mono mb-4">
|
||||
<div className="flex items-center gap-4 text-xs text-slate-500 dark:text-slate-500 font-mono mb-4">
|
||||
<span>{formatDate(post.frontmatter.date)}</span>
|
||||
<span>//</span>
|
||||
<span>{post.readingTime} MIN</span>
|
||||
@@ -105,7 +107,7 @@ export default async function HomePage() {
|
||||
</div>
|
||||
<Link
|
||||
href={`/blog/${post.slug}`}
|
||||
className="inline-flex items-center text-cyan-400 font-mono text-xs font-bold uppercase tracking-wider hover:text-cyan-300 border-2 border-slate-700 px-4 py-2 hover:border-cyan-900"
|
||||
className="inline-flex items-center text-cyan-600 dark:text-cyan-400 font-mono text-xs font-bold uppercase tracking-wider hover:text-cyan-500 dark:hover:text-cyan-300 border-2 border-slate-400 dark:border-slate-700 px-4 py-2 hover:border-cyan-700 dark:hover:border-cyan-900 transition-colors duration-200"
|
||||
>
|
||||
[ACCESEAZĂ] >>
|
||||
</Link>
|
||||
@@ -118,7 +120,7 @@ export default async function HomePage() {
|
||||
<div className="mt-12 text-center">
|
||||
<Link
|
||||
href="/blog"
|
||||
className="inline-flex items-center px-8 py-4 bg-transparent text-slate-300 border-2 border-slate-700 font-mono font-bold uppercase text-sm tracking-wider hover:bg-slate-800 hover:border-slate-600"
|
||||
className="inline-flex items-center px-8 py-4 bg-transparent text-slate-700 dark:text-slate-300 border-2 border-slate-400 dark:border-slate-700 font-mono font-bold uppercase text-sm tracking-wider hover:bg-slate-200 dark:hover:bg-slate-800 hover:border-slate-500 dark:hover:border-slate-600 transition-colors duration-200"
|
||||
>
|
||||
[VEZI TOATE ARTICOLELE] >>
|
||||
</Link>
|
||||
@@ -128,41 +130,41 @@ export default async function HomePage() {
|
||||
</section>
|
||||
|
||||
{/* Stats Section - from worktree-agent-1 */}
|
||||
<section className="py-24 bg-zinc-900 border-y-4 border-slate-800">
|
||||
<section className="py-24 bg-zinc-50 dark:bg-zinc-900 border-y-4 border-slate-300 dark:border-slate-800 transition-colors duration-300">
|
||||
<div className="max-w-7xl mx-auto px-6">
|
||||
<div className="border-l-4 border-teal-900 pl-6 mb-12">
|
||||
<p className="font-mono text-xs text-slate-500 uppercase tracking-widest mb-2">
|
||||
<div className="border-l-4 border-teal-700 dark:border-teal-900 pl-6 mb-12">
|
||||
<p className="font-mono text-xs text-slate-500 dark:text-slate-500 uppercase tracking-widest mb-2">
|
||||
SYSTEM STATISTICS // DATABASE METRICS
|
||||
</p>
|
||||
<h2 className="text-3xl md:text-5xl font-mono font-bold text-slate-100 uppercase tracking-tight">
|
||||
<h2 className="text-3xl md:text-5xl font-mono font-bold text-slate-900 dark:text-slate-100 uppercase tracking-tight">
|
||||
> METRICI_
|
||||
</h2>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-1 md:grid-cols-3 gap-8">
|
||||
<div className="border-4 border-slate-700 bg-slate-900 p-8 text-center">
|
||||
<div className="text-6xl font-mono font-bold text-cyan-400 mb-4">
|
||||
<div className="border-4 border-slate-300 dark:border-slate-700 bg-white dark:bg-slate-900 p-8 text-center transition-colors duration-300">
|
||||
<div className="text-6xl font-mono font-bold text-cyan-600 dark:text-cyan-400 mb-4">
|
||||
{allPosts.length}+
|
||||
</div>
|
||||
<p className="text-slate-400 font-mono text-sm uppercase tracking-wider border-t-2 border-slate-800 pt-4">
|
||||
<p className="text-slate-600 dark:text-slate-400 font-mono text-sm uppercase tracking-wider border-t-2 border-slate-300 dark:border-slate-800 pt-4">
|
||||
ARTICOLE PUBLICATE
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="border-4 border-slate-700 bg-slate-900 p-8 text-center">
|
||||
<div className="text-6xl font-mono font-bold text-emerald-400 mb-4">
|
||||
<div className="border-4 border-slate-300 dark:border-slate-700 bg-white dark:bg-slate-900 p-8 text-center transition-colors duration-300">
|
||||
<div className="text-6xl font-mono font-bold text-emerald-600 dark:text-emerald-400 mb-4">
|
||||
50K+
|
||||
</div>
|
||||
<p className="text-slate-400 font-mono text-sm uppercase tracking-wider border-t-2 border-slate-800 pt-4">
|
||||
<p className="text-slate-600 dark:text-slate-400 font-mono text-sm uppercase tracking-wider border-t-2 border-slate-300 dark:border-slate-800 pt-4">
|
||||
CITITORI LUNARI
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="border-4 border-slate-700 bg-slate-900 p-8 text-center">
|
||||
<div className="text-6xl font-mono font-bold text-teal-400 mb-4">
|
||||
<div className="border-4 border-slate-300 dark:border-slate-700 bg-white dark:bg-slate-900 p-8 text-center transition-colors duration-300">
|
||||
<div className="text-6xl font-mono font-bold text-teal-600 dark:text-teal-400 mb-4">
|
||||
99%
|
||||
</div>
|
||||
<p className="text-slate-400 font-mono text-sm uppercase tracking-wider border-t-2 border-slate-800 pt-4">
|
||||
<p className="text-slate-600 dark:text-slate-400 font-mono text-sm uppercase tracking-wider border-t-2 border-slate-300 dark:border-slate-800 pt-4">
|
||||
SATISFACȚIE
|
||||
</p>
|
||||
</div>
|
||||
@@ -171,32 +173,32 @@ export default async function HomePage() {
|
||||
</section>
|
||||
|
||||
{/* Newsletter CTA - from worktree-agent-1 */}
|
||||
<section className="py-24 bg-slate-900 border-t-4 border-slate-800">
|
||||
<section className="py-24 bg-zinc-100 dark:bg-slate-900 border-t-4 border-slate-300 dark:border-slate-800 transition-colors duration-300">
|
||||
<div className="max-w-3xl mx-auto px-6">
|
||||
<div className="border-4 border-slate-700 bg-zinc-900 p-12">
|
||||
<p className="font-mono text-xs text-slate-500 uppercase tracking-widest mb-2">
|
||||
<div className="border-4 border-slate-300 dark:border-slate-700 bg-white dark:bg-zinc-900 p-12 transition-colors duration-300">
|
||||
<p className="font-mono text-xs text-slate-500 dark:text-slate-500 uppercase tracking-widest mb-2">
|
||||
NEWSLETTER SUBSCRIPTION
|
||||
</p>
|
||||
<h2 className="text-3xl font-mono font-bold text-slate-100 uppercase mb-4">
|
||||
<h2 className="text-3xl font-mono font-bold text-slate-900 dark:text-slate-100 uppercase mb-4">
|
||||
> RĂMÂI LA CURENT_
|
||||
</h2>
|
||||
<p className="text-slate-400 font-mono text-sm mb-8 border-l-2 border-cyan-900 pl-4">
|
||||
<p className="text-slate-700 dark:text-slate-400 font-mono text-sm mb-8 border-l-2 border-cyan-700 dark:border-cyan-900 pl-4">
|
||||
Primește cele mai noi articole direct în inbox
|
||||
</p>
|
||||
<form className="flex gap-0 flex-col sm:flex-row border-2 border-slate-700">
|
||||
<form className="flex gap-0 flex-col sm:flex-row border-2 border-slate-400 dark:border-slate-700">
|
||||
<input
|
||||
type="email"
|
||||
placeholder="email@exemplu.com"
|
||||
className="flex-1 px-6 py-4 bg-slate-800 text-white font-mono border-b-2 sm:border-b-0 sm:border-r-2 border-slate-700 focus:bg-slate-750 focus:outline-none placeholder:text-slate-600"
|
||||
className="flex-1 px-6 py-4 bg-zinc-100 dark:bg-slate-800 text-slate-900 dark:text-white font-mono border-b-2 sm:border-b-0 sm:border-r-2 border-slate-400 dark:border-slate-700 focus:bg-zinc-200 dark:focus:bg-slate-750 focus:outline-none placeholder:text-slate-400 dark:placeholder:text-slate-600 transition-colors duration-200"
|
||||
/>
|
||||
<button
|
||||
type="submit"
|
||||
className="px-8 py-4 bg-cyan-900 text-slate-100 font-mono font-bold uppercase text-sm tracking-wider hover:bg-cyan-800 whitespace-nowrap border-t-2 sm:border-t-0 sm:border-l-2 border-cyan-700"
|
||||
className="px-8 py-4 bg-cyan-700 dark:bg-cyan-900 text-white dark:text-slate-100 font-mono font-bold uppercase text-sm tracking-wider hover:bg-cyan-600 dark:hover:bg-cyan-800 whitespace-nowrap border-t-2 sm:border-t-0 sm:border-l-2 border-cyan-600 dark:border-cyan-700 transition-colors duration-200"
|
||||
>
|
||||
[ABONEAZĂ-TE]
|
||||
</button>
|
||||
</form>
|
||||
<p className="text-slate-600 font-mono text-xs mt-4 uppercase">
|
||||
<p className="text-slate-500 dark:text-slate-600 font-mono text-xs mt-4 uppercase">
|
||||
// Fără spam. Dezabonare oricând.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
125
components/blog/blog-card.tsx
Normal file
125
components/blog/blog-card.tsx
Normal file
@@ -0,0 +1,125 @@
|
||||
import Link from 'next/link'
|
||||
import Image from 'next/image'
|
||||
import { Post } from '@/lib/types/frontmatter'
|
||||
import { formatDate } from '@/lib/utils'
|
||||
|
||||
interface BlogCardProps {
|
||||
post: Post
|
||||
variant: 'image-top' | 'image-side' | 'text-only'
|
||||
}
|
||||
|
||||
export function BlogCard({ post, variant }: BlogCardProps) {
|
||||
const hasImage = !!post.frontmatter.image
|
||||
|
||||
if (!hasImage || variant === 'text-only') {
|
||||
return (
|
||||
<Link href={`/blog/${post.slug}`} className="block cursor-pointer">
|
||||
<article className="border-4 border-slate-700 bg-slate-900 p-6 h-full cyber-glitch-hover">
|
||||
<div className="border-l-4 pl-4 mb-4" style={{ borderColor: 'var(--neon-pink)' }}>
|
||||
<span className="font-mono text-xs text-zinc-100 uppercase tracking-wider">
|
||||
{post.frontmatter.category} <span style={{ color: 'var(--neon-cyan)' }}>//</span> {formatDate(post.frontmatter.date)}
|
||||
</span>
|
||||
</div>
|
||||
<h3 className="font-mono text-xl font-bold text-zinc-100 uppercase mb-3">
|
||||
{post.frontmatter.title}
|
||||
</h3>
|
||||
<p className="font-mono text-sm text-zinc-400 mb-4 leading-relaxed">
|
||||
{post.frontmatter.description}
|
||||
</p>
|
||||
<div className="flex flex-wrap gap-2 mb-4">
|
||||
{post.frontmatter.tags.map((tag) => (
|
||||
<span key={tag} className="px-3 py-1 bg-zinc-800 border border-slate-700 text-cyan-400 font-mono text-xs uppercase">
|
||||
#{tag}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
<span className="inline-flex items-center font-mono text-xs uppercase text-cyan-400 hover:text-cyan-300 transition-colors">
|
||||
> READ [{post.readingTime}MIN]
|
||||
</span>
|
||||
</article>
|
||||
</Link>
|
||||
)
|
||||
}
|
||||
|
||||
if (variant === 'image-side') {
|
||||
return (
|
||||
<Link href={`/blog/${post.slug}`} className="block cursor-pointer">
|
||||
<article className="border-4 border-slate-700 bg-slate-900 overflow-hidden h-full cyber-glitch-hover">
|
||||
<div className="flex flex-col md:flex-row h-full">
|
||||
<div className="md:w-1/3 relative h-64 md:h-auto bg-zinc-900">
|
||||
<Image
|
||||
src={post.frontmatter.image!}
|
||||
alt={post.frontmatter.title}
|
||||
fill
|
||||
className="object-cover grayscale"
|
||||
/>
|
||||
<div className="absolute inset-0 bg-zinc-900/60" />
|
||||
</div>
|
||||
<div className="md:w-2/3 p-6">
|
||||
<div className="border-l-4 border-cyan-400 pl-4 mb-4">
|
||||
<span className="font-mono text-xs text-zinc-100 uppercase tracking-wider">
|
||||
{post.frontmatter.category} // {formatDate(post.frontmatter.date)}
|
||||
</span>
|
||||
</div>
|
||||
<h3 className="font-mono text-xl font-bold text-zinc-100 uppercase mb-3">
|
||||
{post.frontmatter.title}
|
||||
</h3>
|
||||
<p className="font-mono text-sm text-zinc-400 mb-4 leading-relaxed">
|
||||
{post.frontmatter.description}
|
||||
</p>
|
||||
<div className="flex flex-wrap gap-2 mb-4">
|
||||
{post.frontmatter.tags.map((tag) => (
|
||||
<span key={tag} className="px-3 py-1 bg-zinc-800 border border-slate-700 text-cyan-400 font-mono text-xs uppercase">
|
||||
#{tag}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
<span className="inline-flex items-center font-mono text-xs uppercase text-cyan-400 hover:text-cyan-300 transition-colors">
|
||||
> READ [{post.readingTime}MIN]
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
</Link>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<Link href={`/blog/${post.slug}`} className="block cursor-pointer">
|
||||
<article className="border-4 border-slate-700 bg-slate-900 overflow-hidden transition-all duration-300 cyber-glitch-hover h-full">
|
||||
<div className="relative h-64 bg-zinc-900">
|
||||
<Image
|
||||
src={post.frontmatter.image!}
|
||||
alt={post.frontmatter.title}
|
||||
fill
|
||||
className="object-cover grayscale"
|
||||
/>
|
||||
<div className="absolute inset-0 bg-zinc-900/60" />
|
||||
</div>
|
||||
<div className="p-6">
|
||||
<div className="border-l-4 pl-4 mb-4" style={{ borderColor: 'var(--neon-pink)' }}>
|
||||
<span className="font-mono text-xs text-zinc-100 uppercase tracking-wider">
|
||||
{post.frontmatter.category} <span style={{ color: 'var(--neon-cyan)' }}>//</span> {formatDate(post.frontmatter.date)}
|
||||
</span>
|
||||
</div>
|
||||
<h3 className="font-mono text-xl font-bold text-zinc-100 uppercase mb-3">
|
||||
{post.frontmatter.title}
|
||||
</h3>
|
||||
<p className="font-mono text-sm text-zinc-400 mb-4 leading-relaxed">
|
||||
{post.frontmatter.description}
|
||||
</p>
|
||||
<div className="flex flex-wrap gap-2 mb-4">
|
||||
{post.frontmatter.tags.map((tag) => (
|
||||
<span key={tag} className="px-3 py-1 bg-zinc-800 border border-slate-700 text-cyan-400 font-mono text-xs uppercase">
|
||||
#{tag}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
<span className="inline-flex items-center font-mono text-xs uppercase text-cyan-400 hover:text-cyan-300 transition-colors">
|
||||
> READ [{post.readingTime}MIN]
|
||||
</span>
|
||||
</div>
|
||||
</article>
|
||||
</Link>
|
||||
)
|
||||
}
|
||||
52
components/blog/navbar.tsx
Normal file
52
components/blog/navbar.tsx
Normal file
@@ -0,0 +1,52 @@
|
||||
'use client'
|
||||
|
||||
import { useEffect, useState } from 'react'
|
||||
import Link from 'next/link'
|
||||
import { ThemeToggle } from '@/components/theme-toggle'
|
||||
|
||||
export function Navbar() {
|
||||
const [isVisible, setIsVisible] = useState(true)
|
||||
const [lastScrollY, setLastScrollY] = useState(0)
|
||||
|
||||
useEffect(() => {
|
||||
const handleScroll = () => {
|
||||
const currentScrollY = window.scrollY
|
||||
|
||||
if (currentScrollY < 10) {
|
||||
setIsVisible(true)
|
||||
} else if (currentScrollY > lastScrollY) {
|
||||
setIsVisible(false)
|
||||
} else {
|
||||
setIsVisible(true)
|
||||
}
|
||||
|
||||
setLastScrollY(currentScrollY)
|
||||
}
|
||||
|
||||
window.addEventListener('scroll', handleScroll, { passive: true })
|
||||
return () => window.removeEventListener('scroll', handleScroll)
|
||||
}, [lastScrollY])
|
||||
|
||||
return (
|
||||
<nav className={`border-b-4 border-slate-700 bg-slate-900 dark:bg-zinc-950 sticky top-0 z-50 ${isVisible ? 'navbar-visible' : 'navbar-hidden'}`}>
|
||||
<div className="max-w-7xl mx-auto px-6 py-4">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-8">
|
||||
<Link href="/" className="font-mono text-sm uppercase tracking-wider transition-colors cursor-pointer" style={{ color: 'var(--neon-cyan)' }}>
|
||||
< HOME
|
||||
</Link>
|
||||
<span className="font-mono text-sm text-zinc-100 dark:text-zinc-300 uppercase tracking-wider">
|
||||
// <span style={{ color: 'var(--neon-pink)' }}>BLOG</span> ARCHIVE
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-6">
|
||||
<Link href="/about" className="font-mono text-sm text-zinc-400 dark:text-zinc-500 uppercase tracking-wider hover:text-cyan-400 dark:hover:text-cyan-300 transition-colors cursor-pointer">
|
||||
[ABOUT]
|
||||
</Link>
|
||||
<ThemeToggle />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
)
|
||||
}
|
||||
19
components/blog/search-bar.tsx
Normal file
19
components/blog/search-bar.tsx
Normal file
@@ -0,0 +1,19 @@
|
||||
interface SearchBarProps {
|
||||
searchQuery: string
|
||||
onSearchChange: (value: string) => void
|
||||
}
|
||||
|
||||
export function SearchBar({ searchQuery, onSearchChange }: SearchBarProps) {
|
||||
return (
|
||||
<div className="flex-1 flex items-center border-2 border-slate-700 bg-zinc-900 transition-all focus-within:border-[var(--neon-cyan)] focus-within:shadow-[0_0_10px_var(--neon-cyan),0_0_20px_rgba(0,255,255,0.5),inset_0_0_10px_rgba(0,255,255,0.1)]">
|
||||
<span className="pl-4 pr-2 font-mono text-lg" style={{ color: 'var(--neon-cyan)' }}>></span>
|
||||
<input
|
||||
type="text"
|
||||
placeholder="SEARCH POSTS..."
|
||||
value={searchQuery}
|
||||
onChange={(e) => onSearchChange(e.target.value)}
|
||||
className="flex-1 bg-transparent font-mono text-zinc-100 dark:text-zinc-100 px-2 py-3 focus:outline-none placeholder:text-zinc-600 uppercase text-sm"
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
20
components/blog/sort-dropdown.tsx
Normal file
20
components/blog/sort-dropdown.tsx
Normal file
@@ -0,0 +1,20 @@
|
||||
type SortOption = 'newest' | 'oldest' | 'title'
|
||||
|
||||
interface SortDropdownProps {
|
||||
sortBy: SortOption
|
||||
onSortChange: (value: SortOption) => void
|
||||
}
|
||||
|
||||
export function SortDropdown({ sortBy, onSortChange }: SortDropdownProps) {
|
||||
return (
|
||||
<select
|
||||
value={sortBy}
|
||||
onChange={(e) => onSortChange(e.target.value as SortOption)}
|
||||
className="border-2 border-slate-700 bg-zinc-900 dark:bg-zinc-900 text-zinc-100 dark:text-zinc-100 font-mono px-6 py-3 uppercase text-sm cyber-focus-pink transition-all hover:border-cyan-400 cursor-pointer"
|
||||
>
|
||||
<option value="newest" className="bg-zinc-900 text-zinc-100" style={{ backgroundColor: '#18181b', color: '#f4f4f5' }}>NEWEST FIRST</option>
|
||||
<option value="oldest" className="bg-zinc-900 text-zinc-100" style={{ backgroundColor: '#18181b', color: '#f4f4f5' }}>OLDEST FIRST</option>
|
||||
<option value="title" className="bg-zinc-900 text-zinc-100" style={{ backgroundColor: '#18181b', color: '#f4f4f5' }}>BY TITLE</option>
|
||||
</select>
|
||||
)
|
||||
}
|
||||
41
components/blog/tag-filter.tsx
Normal file
41
components/blog/tag-filter.tsx
Normal file
@@ -0,0 +1,41 @@
|
||||
interface TagFilterProps {
|
||||
allTags: string[]
|
||||
selectedTags: string[]
|
||||
onToggleTag: (tag: string) => void
|
||||
onClearTags: () => void
|
||||
}
|
||||
|
||||
export function TagFilter({ allTags, selectedTags, onToggleTag, onClearTags }: TagFilterProps) {
|
||||
if (allTags.length === 0) return null
|
||||
|
||||
return (
|
||||
<div className="border-4 border-slate-700 bg-slate-900 p-6 mb-12">
|
||||
<p className="font-mono text-xs text-zinc-500 uppercase tracking-widest mb-4">
|
||||
FILTER BY TAG
|
||||
</p>
|
||||
<div className="flex flex-wrap gap-3">
|
||||
{allTags.map((tag) => (
|
||||
<button
|
||||
key={tag}
|
||||
onClick={() => onToggleTag(tag)}
|
||||
className={`px-4 py-2 font-mono text-xs uppercase border-2 transition-colors cursor-pointer ${
|
||||
selectedTags.includes(tag)
|
||||
? 'bg-cyan-400 border-cyan-400 text-slate-900'
|
||||
: 'bg-zinc-900 border-slate-700 text-zinc-400 hover:border-cyan-400 hover:text-cyan-400'
|
||||
}`}
|
||||
>
|
||||
#{tag}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
{selectedTags.length > 0 && (
|
||||
<button
|
||||
onClick={onClearTags}
|
||||
className="mt-4 font-mono text-xs uppercase text-cyan-400 hover:text-cyan-300 transition-colors cursor-pointer"
|
||||
>
|
||||
> CLEAR FILTERS
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
import Link from 'next/link';
|
||||
import { usePathname } from 'next/navigation';
|
||||
import { Fragment } from 'react';
|
||||
import { BreadcrumbsSchema } from './BreadcrumbsSchema';
|
||||
import { BreadcrumbsSchema } from './breadcrumbs-schema';
|
||||
|
||||
interface BreadcrumbItem {
|
||||
label: string;
|
||||
|
||||
70
components/theme-toggle.tsx
Normal file
70
components/theme-toggle.tsx
Normal file
@@ -0,0 +1,70 @@
|
||||
'use client'
|
||||
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useTheme } from 'next-themes'
|
||||
|
||||
export function ThemeToggle() {
|
||||
const [mounted, setMounted] = useState(false)
|
||||
const { theme, setTheme } = useTheme()
|
||||
const [isGlitching, setIsGlitching] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
setMounted(true)
|
||||
}, [])
|
||||
|
||||
const toggleTheme = () => {
|
||||
// Trigger glitch animation
|
||||
setIsGlitching(true)
|
||||
|
||||
// Trigger screen flicker
|
||||
document.body.classList.add('screen-flicker')
|
||||
|
||||
// Toggle theme
|
||||
setTheme(theme === 'dark' ? 'light' : 'dark')
|
||||
|
||||
// Remove effects after animation
|
||||
setTimeout(() => {
|
||||
setIsGlitching(false)
|
||||
document.body.classList.remove('screen-flicker')
|
||||
}, 300)
|
||||
}
|
||||
|
||||
if (!mounted) {
|
||||
return (
|
||||
<button className="font-mono text-xs text-slate-400 uppercase tracking-wider px-3 py-1 border-2 border-slate-700">
|
||||
[...]
|
||||
</button>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<button
|
||||
onClick={toggleTheme}
|
||||
className={`
|
||||
relative font-mono text-xs uppercase tracking-wider
|
||||
px-3 py-1 border-2 transition-all duration-300
|
||||
${theme === 'dark'
|
||||
? 'text-cyan-400 border-cyan-900 hover:border-cyan-700 bg-cyan-950/20'
|
||||
: 'text-emerald-600 border-emerald-700 hover:border-emerald-500 bg-emerald-50/50'
|
||||
}
|
||||
${isGlitching ? 'glitch-btn' : ''}
|
||||
border-pulse overflow-hidden
|
||||
`}
|
||||
aria-label="Toggle theme"
|
||||
>
|
||||
<span className="relative z-10">
|
||||
{theme === 'dark' ? '[DARK MODE]' : '[LIGHT MODE]'}
|
||||
</span>
|
||||
{isGlitching && (
|
||||
<>
|
||||
<span className="glitch-layer" aria-hidden="true">
|
||||
{theme === 'dark' ? '[DARK MODE]' : '[LIGHT MODE]'}
|
||||
</span>
|
||||
<span className="glitch-layer" aria-hidden="true">
|
||||
{theme === 'dark' ? '[DARK MODE]' : '[LIGHT MODE]'}
|
||||
</span>
|
||||
</>
|
||||
)}
|
||||
</button>
|
||||
)
|
||||
}
|
||||
@@ -5,7 +5,7 @@ date: "2025-01-15"
|
||||
author: "Test Author"
|
||||
category: "Tutorial"
|
||||
tags: ["markdown", "test", "demo"]
|
||||
image: "/images/test.jpg"
|
||||
image: "/38636.jpg"
|
||||
draft: false
|
||||
---
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ export function validateFrontmatter(data: any): FrontMatter {
|
||||
}
|
||||
|
||||
export function getPostBySlug(slug: string | string[]): Post | null {
|
||||
const slugArray = Array.isArray(slug) ? slug : [slug];
|
||||
const slugArray = Array.isArray(slug) ? slug : slug.split('/');
|
||||
const sanitized = slugArray.map(s => sanitizePath(s));
|
||||
const fullPath = path.join(POSTS_PATH, ...sanitized) + '.md';
|
||||
|
||||
|
||||
11
package-lock.json
generated
11
package-lock.json
generated
@@ -17,6 +17,7 @@
|
||||
"autoprefixer": "^10.4.21",
|
||||
"gray-matter": "^4.0.3",
|
||||
"next": "^16.0.1",
|
||||
"next-themes": "^0.4.6",
|
||||
"postcss": "^8.5.6",
|
||||
"react": "^19.2.0",
|
||||
"react-dom": "^19.2.0",
|
||||
@@ -2984,6 +2985,16 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/next-themes": {
|
||||
"version": "0.4.6",
|
||||
"resolved": "https://registry.npmjs.org/next-themes/-/next-themes-0.4.6.tgz",
|
||||
"integrity": "sha512-pZvgD5L0IEvX5/9GWyHMf3m8BKiVQwsCMHfoFosXtXBMnaS0ZnIJ9ST4b4NqLVKDEm8QBxoNNGNaBv2JNF6XNA==",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"react": "^16.8 || ^17 || ^18 || ^19 || ^19.0.0-rc",
|
||||
"react-dom": "^16.8 || ^17 || ^18 || ^19 || ^19.0.0-rc"
|
||||
}
|
||||
},
|
||||
"node_modules/next/node_modules/postcss": {
|
||||
"version": "8.4.31",
|
||||
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.31.tgz",
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
"autoprefixer": "^10.4.21",
|
||||
"gray-matter": "^4.0.3",
|
||||
"next": "^16.0.1",
|
||||
"next-themes": "^0.4.6",
|
||||
"postcss": "^8.5.6",
|
||||
"react": "^19.2.0",
|
||||
"react-dom": "^19.2.0",
|
||||
|
||||
8
providers/providers.tsx
Normal file
8
providers/providers.tsx
Normal file
@@ -0,0 +1,8 @@
|
||||
'use client'
|
||||
|
||||
import { ThemeProvider as NextThemesProvider } from 'next-themes'
|
||||
import type { ThemeProviderProps } from 'next-themes'
|
||||
|
||||
export function ThemeProvider({ children, ...props }: ThemeProviderProps) {
|
||||
return <NextThemesProvider {...props}>{children}</NextThemesProvider>
|
||||
}
|
||||
BIN
public/38636.jpg
Normal file
BIN
public/38636.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 MiB |
@@ -1,5 +1,6 @@
|
||||
/** @type {import('tailwindcss').Config} */
|
||||
module.exports = {
|
||||
darkMode: 'class',
|
||||
content: [
|
||||
"./pages/**/*.{js,ts,jsx,tsx,mdx}",
|
||||
"./components/**/*.{js,ts,jsx,tsx,mdx}",
|
||||
@@ -20,6 +21,65 @@ module.exports = {
|
||||
800: '#075985',
|
||||
900: '#0c4a6e',
|
||||
},
|
||||
'dark-primary': '#18181b',
|
||||
'dark-secondary': '#0f172a',
|
||||
'dark-tertiary': '#1e293b',
|
||||
'accent': {
|
||||
DEFAULT: '#164e63',
|
||||
hover: '#155e75',
|
||||
light: '#0e7490',
|
||||
},
|
||||
'accent-emerald': {
|
||||
DEFAULT: '#064e3b',
|
||||
hover: '#065f46',
|
||||
},
|
||||
'accent-teal': {
|
||||
DEFAULT: '#134e4a',
|
||||
hover: '#115e59',
|
||||
},
|
||||
},
|
||||
animation: {
|
||||
'glitch': 'glitch 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) both',
|
||||
'flicker': 'flicker 0.15s infinite',
|
||||
'scanline': 'scanline 8s linear infinite',
|
||||
'noise': 'noise 0.2s infinite',
|
||||
},
|
||||
keyframes: {
|
||||
glitch: {
|
||||
'0%': { transform: 'translate(0)' },
|
||||
'20%': { transform: 'translate(-2px, 2px)' },
|
||||
'40%': { transform: 'translate(-2px, -2px)' },
|
||||
'60%': { transform: 'translate(2px, 2px)' },
|
||||
'80%': { transform: 'translate(2px, -2px)' },
|
||||
'100%': { transform: 'translate(0)' },
|
||||
},
|
||||
flicker: {
|
||||
'0%, 100%': { opacity: '1' },
|
||||
'41.99%': { opacity: '1' },
|
||||
'42%': { opacity: '0' },
|
||||
'43%': { opacity: '0' },
|
||||
'43.01%': { opacity: '1' },
|
||||
'47.99%': { opacity: '1' },
|
||||
'48%': { opacity: '0' },
|
||||
'49%': { opacity: '0' },
|
||||
'49.01%': { opacity: '1' },
|
||||
},
|
||||
scanline: {
|
||||
'0%': { transform: 'translateY(-100%)' },
|
||||
'100%': { transform: 'translateY(100%)' },
|
||||
},
|
||||
noise: {
|
||||
'0%, 100%': { backgroundPosition: '0 0' },
|
||||
'10%': { backgroundPosition: '-5% -10%' },
|
||||
'20%': { backgroundPosition: '-15% 5%' },
|
||||
'30%': { backgroundPosition: '7% -25%' },
|
||||
'40%': { backgroundPosition: '-5% 25%' },
|
||||
'50%': { backgroundPosition: '-15% 10%' },
|
||||
'60%': { backgroundPosition: '15% 0%' },
|
||||
'70%': { backgroundPosition: '0% 15%' },
|
||||
'80%': { backgroundPosition: '3% 35%' },
|
||||
'90%': { backgroundPosition: '-10% 10%' },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user