Update code
This commit is contained in:
@@ -0,0 +1,330 @@
|
||||
'use client';
|
||||
|
||||
import {
|
||||
CalendarDays,
|
||||
Copy,
|
||||
Download,
|
||||
Eye,
|
||||
FileText,
|
||||
Plus,
|
||||
} from 'lucide-react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
|
||||
import Prism from 'prismjs';
|
||||
import 'prismjs/components/prism-bash';
|
||||
import 'prismjs/components/prism-javascript';
|
||||
import 'prismjs/components/prism-json';
|
||||
import 'prismjs/components/prism-python';
|
||||
import 'prismjs/components/prism-typescript';
|
||||
import 'prismjs/themes/prism-tomorrow.css';
|
||||
|
||||
import 'prismjs/plugins/line-numbers/prism-line-numbers.css';
|
||||
import 'prismjs/plugins/line-numbers/prism-line-numbers.js';
|
||||
|
||||
/** ---------- Loader animé (spinner + skeletons) ---------- */
|
||||
function LoadingPaste() {
|
||||
return (
|
||||
<div className="relative w-screen h-screen bg-[#0e0f13] text-white flex overflow-hidden">
|
||||
{/* Zone code (skeleton lignes) */}
|
||||
<div className="flex-1 h-full font-mono text-sm">
|
||||
<div className="h-full overflow-auto pt-6 pb-6 px-6">
|
||||
<div className="mb-4 flex items-center gap-2">
|
||||
<div
|
||||
className="h-5 w-5 rounded-full border-2 border-white/30 border-t-transparent animate-spin"
|
||||
aria-hidden
|
||||
/>
|
||||
<span className="text-white/70 text-sm">Chargement du paste…</span>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
{Array.from({ length: 28 }).map((_, i) => (
|
||||
<div
|
||||
key={i}
|
||||
className={`h-3 rounded bg-white/10 animate-pulse ${i % 3 === 0 ? 'w-5/6' : i % 3 === 1 ? 'w-11/12' : 'w-3/4'}`}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Sidebar (skeleton cartes + boutons) */}
|
||||
<div
|
||||
className="
|
||||
absolute top-4 right-4 w-[300px] rounded-2xl p-5 text-sm
|
||||
backdrop-blur-xl shadow-2xl
|
||||
bg-[linear-gradient(to_bottom_right,#1a2035,#101522)]
|
||||
ring-1 ring-white/10 mr-4
|
||||
"
|
||||
>
|
||||
<div className="mb-4">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="h-6 w-24 bg-white/10 rounded animate-pulse" />
|
||||
<div className="h-7 w-20 rounded-full bg-green-600/60 animate-pulse" />
|
||||
</div>
|
||||
<div className="h-4 w-40 bg-white/10 rounded mt-2 animate-pulse" />
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-2 gap-3 text-neutral-300">
|
||||
<div className="flex items-center gap-2 rounded-lg px-3 py-2 bg-[#151b2e] ring-1 ring-white/15">
|
||||
<div className="h-4 w-4 rounded bg-white/10 animate-pulse" />
|
||||
<div className="flex-1 space-y-1">
|
||||
<div className="h-3 w-10 bg-white/10 rounded animate-pulse" />
|
||||
<div className="h-3 w-12 bg-white/20 rounded animate-pulse" />
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center gap-2 rounded-lg px-3 py-2 bg-[#151b2e] ring-1 ring-white/15">
|
||||
<div className="h-4 w-4 rounded bg-white/10 animate-pulse" />
|
||||
<div className="flex-1 space-y-1">
|
||||
<div className="h-3 w-12 bg-white/10 rounded animate-pulse" />
|
||||
<div className="h-3 w-16 bg-white/20 rounded animate-pulse" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="h-px bg-white/10 my-4" />
|
||||
|
||||
<div className="grid grid-cols-4 gap-2">
|
||||
{Array.from({ length: 4 }).map((_, i) => (
|
||||
<div key={i} className="h-9 rounded-lg bg-[#151b2e] ring-1 ring-white/10 animate-pulse" />
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="mt-3 h-3 w-16 mx-auto bg-green-400/50 rounded animate-pulse" />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
/** -------------------------------------------------------- */
|
||||
|
||||
export default function PastePage({ params }: { params: { id: string } }) {
|
||||
const [paste, setPaste] = useState<any | null>(null);
|
||||
const [error, setError] = useState('');
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [language, setLanguage] = useState<string>('language-javascript');
|
||||
const [copied, setCopied] = useState(false);
|
||||
|
||||
const codeRef = useRef<HTMLPreElement | null>(null);
|
||||
const router = useRouter();
|
||||
|
||||
const fetchPaste = async (pwd?: string) => {
|
||||
setLoading(true);
|
||||
const res = await fetch(`/api/paste/${params.id}`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ password: pwd || '' }),
|
||||
});
|
||||
|
||||
if (res.status === 403) {
|
||||
setError('Invalid password.');
|
||||
setLoading(false);
|
||||
return;
|
||||
}
|
||||
if (res.status === 404) {
|
||||
setError('Paste not found or expired.');
|
||||
setLoading(false);
|
||||
return;
|
||||
}
|
||||
|
||||
const data = await res.json();
|
||||
setPaste(data);
|
||||
|
||||
if (data.content.includes('function') || data.content.includes('const')) {
|
||||
setLanguage('language-javascript');
|
||||
} else if (data.content.includes('import') || data.content.includes('export')) {
|
||||
setLanguage('language-typescript');
|
||||
} else if (data.content.includes('{') && data.content.includes('}')) {
|
||||
setLanguage('language-json');
|
||||
} else {
|
||||
setLanguage('language-bash');
|
||||
}
|
||||
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
fetchPaste();
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (paste?.content) {
|
||||
Prism.highlightAll();
|
||||
}
|
||||
}, [paste]);
|
||||
|
||||
// 👉 Remplace l'ancien message "Loading..." par le loader animé
|
||||
if (loading) return <LoadingPaste />;
|
||||
|
||||
if (error || (paste?.protected && !paste?.content)) {
|
||||
return (
|
||||
<div className="h-screen w-screen bg-[#0e0f13] flex items-center justify-center text-white">
|
||||
<form
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
fetchPaste((e.currentTarget as any).password.value);
|
||||
}}
|
||||
className="
|
||||
w-full max-w-sm rounded-2xl p-6 space-y-4
|
||||
backdrop-blur-xl shadow-2xl
|
||||
bg-[linear-gradient(to_bottom_right,rgba(20,24,38,0.9),rgba(14,16,24,0.9))]
|
||||
ring-1 ring-white/10
|
||||
"
|
||||
>
|
||||
<h2 className="text-xl font-bold">
|
||||
<span className="text-red-400">🔒 Protected Paste</span>
|
||||
</h2>
|
||||
{error && <p className="text-red-500 text-sm">{error}</p>}
|
||||
|
||||
<input
|
||||
name="password"
|
||||
type="password"
|
||||
placeholder="Enter password"
|
||||
className="
|
||||
w-full rounded-xl bg-[#0f1320]/60 text-white placeholder:text-neutral-500
|
||||
px-3 py-2 outline-none
|
||||
ring-1 ring-white/10 focus:ring-2 focus:ring-blue-500/50
|
||||
"
|
||||
/>
|
||||
|
||||
<button
|
||||
type="submit"
|
||||
className="
|
||||
w-full inline-flex items-center justify-center gap-2 rounded-xl py-2 text-sm font-medium
|
||||
bg-gradient-to-b from-[#1b2135] to-[#141a2a] text-white ring-1 ring-white/10
|
||||
hover:from-[#232a41] hover:to-[#161d2f]
|
||||
focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-400/60
|
||||
"
|
||||
>
|
||||
View Paste
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="relative w-screen h-screen bg-[#0e0f13] text-white flex overflow-hidden">
|
||||
<div className="flex-1 h-full font-mono text-sm">
|
||||
<pre
|
||||
ref={codeRef}
|
||||
className="h-full overflow-auto pt-6 pb-6 px-6 line-numbers"
|
||||
>
|
||||
<code className={`${language} whitespace-pre-wrap break-words`}>
|
||||
{paste.content}
|
||||
</code>
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<div
|
||||
className="
|
||||
absolute top-4 right-4 w-[300px] rounded-2xl p-5 text-sm
|
||||
backdrop-blur-xl shadow-2xl
|
||||
bg-[linear-gradient(to_bottom_right,#1a2035,#101522)]
|
||||
ring-1 ring-white/10 mr-4
|
||||
"
|
||||
>
|
||||
<div className="mb-4">
|
||||
<div className="flex items-center justify-between">
|
||||
<h2 className="text-lg font-bold tracking-tight">
|
||||
Alt<span className="text-blue-400">Bin</span>
|
||||
</h2>
|
||||
<button
|
||||
onClick={() => router.push('/')}
|
||||
className="
|
||||
cursor-pointer inline-flex items-center gap-1 rounded-full px-3 py-1 text-xs font-semibold
|
||||
bg-green-600 text-white shadow-sm
|
||||
hover:bg-green-500 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-green-400/60
|
||||
"
|
||||
>
|
||||
<Plus size={14} />
|
||||
CREATE
|
||||
</button>
|
||||
</div>
|
||||
{paste.title && (
|
||||
<h1
|
||||
className="text-sm font-semibold text-blue-300 truncate mt-1"
|
||||
title={paste.title}
|
||||
>
|
||||
{paste.title}
|
||||
</h1>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-2 gap-3 text-neutral-300">
|
||||
<div className="flex items-center gap-2 rounded-lg px-3 py-2 bg-[#151b2e] ring-1 ring-white/15">
|
||||
<Eye size={16} />
|
||||
<div className="leading-tight">
|
||||
<div className="text-xs text-neutral-400">Views</div>
|
||||
<div className="text-sm font-medium text-white">{paste.views}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center gap-2 rounded-lg px-3 py-2 bg-[#151b2e] ring-1 ring-white/15">
|
||||
<CalendarDays size={16} />
|
||||
<div className="leading-tight">
|
||||
<div className="text-xs text-neutral-400">Created</div>
|
||||
<div className="text-sm font-medium text-white">
|
||||
{new Date(paste.createdAt).toLocaleDateString()}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="h-px bg-white/10 my-4" />
|
||||
|
||||
<div className="grid grid-cols-4 gap-2">
|
||||
<button
|
||||
onClick={async () => {
|
||||
await navigator.clipboard.writeText(paste.content);
|
||||
setCopied(true);
|
||||
setTimeout(() => setCopied(false), 1200);
|
||||
}}
|
||||
className="cursor-pointer inline-flex items-center justify-center rounded-lg p-2 bg-[#151b2e] ring-1 ring-white/10 hover:bg-[#1e253d] hover:ring-blue-400/30"
|
||||
title="Copy"
|
||||
>
|
||||
<Copy size={18} />
|
||||
</button>
|
||||
|
||||
<button
|
||||
onClick={() => window.open(`/api/${params.id}?raw=1`, '_blank')}
|
||||
className="cursor-pointer inline-flex items-center justify-center rounded-lg p-2 bg-[#151b2e] ring-1 ring-white/10 hover:bg-[#1e253d] hover:ring-blue-400/30"
|
||||
title="Raw"
|
||||
>
|
||||
<FileText size={18} />
|
||||
</button>
|
||||
|
||||
<button
|
||||
onClick={() => {
|
||||
const blob = new Blob([paste.content], { type: 'text/plain' });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = `${params.id}.txt`;
|
||||
a.click();
|
||||
URL.revokeObjectURL(url);
|
||||
}}
|
||||
className="cursor-pointer inline-flex items-center justify-center rounded-lg p-2 bg-[#151b2e] ring-1 ring-white/10 hover:bg-[#1e253d] hover:ring-blue-400/30"
|
||||
title="Download"
|
||||
>
|
||||
<Download size={18} />
|
||||
</button>
|
||||
|
||||
<button
|
||||
onClick={() => router.push('/')}
|
||||
className="cursor-pointer inline-flex items-center justify-center rounded-lg p-2 bg-[#151b2e] ring-1 ring-white/10 hover:bg-[#1e253d] hover:ring-blue-400/30"
|
||||
title="New paste"
|
||||
>
|
||||
<Plus size={18} />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div
|
||||
className={`mt-3 text-center text-xs transition-opacity ${
|
||||
copied ? 'opacity-100 text-green-400' : 'opacity-0'
|
||||
}`}
|
||||
>
|
||||
Copied!
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
"use client";
|
||||
|
||||
import { Player } from "@lordicon/react";
|
||||
import { motion } from "framer-motion";
|
||||
import { ArrowLeft } from "lucide-react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { forwardRef, useEffect, useRef, useState } from "react";
|
||||
|
||||
// URLs d’icônes Lordicon
|
||||
const icons = {
|
||||
simplicity: "https://cdn.lordicon.com/tsrgicte.json", // simplicité
|
||||
shield: "https://cdn.lordicon.com/sjoccsdj.json", // sécurité
|
||||
community: "https://cdn.lordicon.com/ubpgwkmy.json", // communauté / open source
|
||||
github: "https://cdn.lordicon.com/jjxzcivr.json", // GitHub
|
||||
discord: "https://cdn.lordicon.com/zvnxzuwv.json", // Discord
|
||||
};
|
||||
|
||||
// Wrapper pour Lordicon
|
||||
const LordIcon = forwardRef(function LordIcon(
|
||||
{ url, size = 30, colorize = "#3b82f6" }: { url: string; size?: number; colorize?: string },
|
||||
ref: any
|
||||
) {
|
||||
const [iconData, setIconData] = useState<any>(null);
|
||||
|
||||
useEffect(() => {
|
||||
fetch(url).then((res) => res.json()).then(setIconData);
|
||||
}, [url]);
|
||||
|
||||
if (!iconData) return null;
|
||||
return <Player ref={ref} icon={iconData} size={size} colorize={colorize} />;
|
||||
});
|
||||
|
||||
// Carte Feature
|
||||
function FeatureCard({
|
||||
title,
|
||||
desc,
|
||||
icon,
|
||||
}: {
|
||||
title: string;
|
||||
desc: string;
|
||||
icon: string;
|
||||
}) {
|
||||
const iconRef = useRef<any>(null);
|
||||
|
||||
return (
|
||||
<motion.div
|
||||
whileHover={{ scale: 1.03 }}
|
||||
className="rounded-2xl bg-[#11131c] border border-white/10 p-6 shadow-lg hover:border-blue-500/40 transition-colors"
|
||||
onMouseEnter={() => iconRef.current?.playFromBeginning()}
|
||||
onMouseLeave={() => iconRef.current?.goToFirstFrame()}
|
||||
>
|
||||
<div className="flex items-center gap-3 mb-3">
|
||||
<div className="p-2 rounded-xl bg-blue-500/20 text-blue-400">
|
||||
<LordIcon ref={iconRef} url={icon} size={32} />
|
||||
</div>
|
||||
<h3 className="text-lg font-semibold">{title}</h3>
|
||||
</div>
|
||||
<p className="text-neutral-400 text-sm leading-relaxed">{desc}</p>
|
||||
</motion.div>
|
||||
);
|
||||
}
|
||||
|
||||
// Bouton Contact
|
||||
function ContactButton({
|
||||
href,
|
||||
icon,
|
||||
text,
|
||||
gradient,
|
||||
shadow,
|
||||
color = "#fff",
|
||||
}: {
|
||||
href: string;
|
||||
icon: string;
|
||||
text: string;
|
||||
gradient: string;
|
||||
shadow: string;
|
||||
color?: string;
|
||||
}) {
|
||||
const iconRef = useRef<any>(null);
|
||||
|
||||
return (
|
||||
<motion.a
|
||||
whileHover={{ scale: 1.05 }}
|
||||
whileTap={{ scale: 0.97 }}
|
||||
href={href}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className={`cursor-pointer inline-flex items-center gap-2 px-6 py-3 rounded-xl text-base font-medium text-white ${gradient} ${shadow} transition-all duration-300 focus:outline-none focus:ring-2 focus:ring-blue-400/60`}
|
||||
onMouseEnter={() => iconRef.current?.playFromBeginning()}
|
||||
onMouseLeave={() => iconRef.current?.goToFirstFrame()}
|
||||
>
|
||||
<LordIcon ref={iconRef} url={icon} size={32} colorize={color} />
|
||||
<span>{text}</span>
|
||||
</motion.a>
|
||||
);
|
||||
}
|
||||
|
||||
export default function AboutPage() {
|
||||
const router = useRouter();
|
||||
|
||||
const features = [
|
||||
{
|
||||
title: "Simplicity",
|
||||
desc: "Create a paste in seconds, distraction-free.",
|
||||
icon: icons.simplicity,
|
||||
},
|
||||
{
|
||||
title: "Security",
|
||||
desc: "Protect your posts with a password or limited number of views.",
|
||||
icon: icons.shield,
|
||||
},
|
||||
{
|
||||
title: "Open Source",
|
||||
desc: "Contribute to the project and improve the platform.",
|
||||
icon: icons.community,
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<div className="p-8 relative min-h-screen bg-[#0e0f13] text-white">
|
||||
{/* Navbar */}
|
||||
<div className="flex justify-between items-center mb-12 max-w-6xl mx-auto">
|
||||
<motion.button
|
||||
whileHover={{ scale: 1.05 }}
|
||||
whileTap={{ scale: 0.97 }}
|
||||
onClick={() => router.back()}
|
||||
className="cursor-pointer inline-flex items-center gap-2 px-5 py-2 rounded-xl text-sm font-medium
|
||||
text-white bg-gradient-to-r from-blue-600 to-blue-500 shadow-lg shadow-blue-500/30
|
||||
hover:shadow-blue-500/50 transition-all duration-300 focus:outline-none focus:ring-2 focus:ring-blue-400/60"
|
||||
>
|
||||
<ArrowLeft size={18} className="text-blue-200" />
|
||||
Back
|
||||
</motion.button>
|
||||
|
||||
<h1 className="text-lg font-bold text-neutral-300">AltBin</h1>
|
||||
</div>
|
||||
|
||||
{/* Features */}
|
||||
<div className="grid grid-cols-1 sm:grid-cols-3 gap-6 max-w-6xl mx-auto">
|
||||
{features.map((f, i) => (
|
||||
<FeatureCard key={i} title={f.title} desc={f.desc} icon={f.icon} />
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* Contact */}
|
||||
<div className="mt-20 max-w-2xl mx-auto text-center">
|
||||
<h2 className="text-xl md:text-2xl font-bold mb-4">Contact</h2>
|
||||
<p className="text-neutral-400 mb-8">
|
||||
Any <span className="text-blue-400">questions</span> or{" "}
|
||||
<span className="text-blue-400">suggestions</span>?
|
||||
Join the community or check out the source code
|
||||
</p>
|
||||
|
||||
<div className="flex justify-center gap-4 flex-wrap">
|
||||
<ContactButton
|
||||
href="https://discord.gg/ton-serveur"
|
||||
icon={icons.discord}
|
||||
text="Join Discord"
|
||||
gradient="bg-gradient-to-r from-indigo-600 to-indigo-500"
|
||||
shadow="shadow-lg shadow-indigo-500/30 hover:shadow-indigo-500/50"
|
||||
/>
|
||||
<ContactButton
|
||||
href="https://github.com/UltraLionfr/altbin.dev"
|
||||
icon={icons.github}
|
||||
text="GitHub"
|
||||
gradient="bg-gradient-to-r from-gray-800 to-gray-700"
|
||||
shadow="shadow-lg shadow-black/30 hover:shadow-blue-500/40"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import NextAuth, { NextAuthOptions } from 'next-auth';
|
||||
import DiscordProvider from 'next-auth/providers/discord';
|
||||
|
||||
export const authOptions: NextAuthOptions = {
|
||||
providers: [
|
||||
DiscordProvider({
|
||||
clientId: process.env.DISCORD_CLIENT_ID!,
|
||||
clientSecret: process.env.DISCORD_CLIENT_SECRET!,
|
||||
}),
|
||||
],
|
||||
callbacks: {
|
||||
async session({ session, token }) {
|
||||
if (session.user && token.sub) {
|
||||
session.user.id = token.sub;
|
||||
} else {
|
||||
session.user.id = '';
|
||||
}
|
||||
return session;
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
const handler = NextAuth(authOptions);
|
||||
|
||||
export { handler as GET, handler as POST };
|
||||
@@ -0,0 +1,30 @@
|
||||
import { prisma } from '@/lib/prisma';
|
||||
|
||||
interface Props {
|
||||
params: { id: string };
|
||||
}
|
||||
|
||||
export default async function PastePage({ params }: Props) {
|
||||
const paste = await prisma.paste.findUnique({
|
||||
where: { id: params.id },
|
||||
select: { title: true, content: true, createdAt: true, views: true },
|
||||
});
|
||||
|
||||
if (!paste) return <div>Paste not found</div>;
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-[#0e0f13] text-white p-6">
|
||||
<h1 className="text-3xl font-bold text-blue-400 mb-4">
|
||||
{paste.title || 'Untitled'}
|
||||
</h1>
|
||||
|
||||
<pre className="bg-[#11131c] p-6 rounded-xl whitespace-pre-wrap overflow-auto text-sm border border-white/10 shadow-lg">
|
||||
{paste.content}
|
||||
</pre>
|
||||
|
||||
<p className="mt-4 text-xs text-neutral-400">
|
||||
Views: {paste.views} · Created at: {new Date(paste.createdAt).toLocaleString()}
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
import { prisma } from '@/lib/prisma';
|
||||
import bcrypt from 'bcryptjs';
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
|
||||
export const dynamic = 'force-dynamic';
|
||||
export const revalidate = 0;
|
||||
|
||||
export async function POST(
|
||||
request: NextRequest,
|
||||
context: { params: { id: string } }
|
||||
) {
|
||||
const { params } = context;
|
||||
const pasteId = params.id;
|
||||
|
||||
const { password = '' } = await request.json();
|
||||
|
||||
if (!pasteId) {
|
||||
return NextResponse.json({ error: 'Invalid ID' }, { status: 400 });
|
||||
}
|
||||
|
||||
const paste = await prisma.paste.findUnique({ where: { id: pasteId } });
|
||||
if (!paste) {
|
||||
return NextResponse.json({ error: 'Not found' }, { status: 404 });
|
||||
}
|
||||
|
||||
if (paste.maxViews !== null && paste.views >= paste.maxViews) {
|
||||
await prisma.paste.delete({ where: { id: paste.id } });
|
||||
return NextResponse.json({ error: 'Max views exceeded' }, { status: 404 });
|
||||
}
|
||||
|
||||
if (paste.password) {
|
||||
const valid = await bcrypt.compare(password, paste.password);
|
||||
if (!valid) {
|
||||
return NextResponse.json({ error: 'Invalid password' }, { status: 403 });
|
||||
}
|
||||
}
|
||||
|
||||
const updated = await prisma.paste.update({
|
||||
where: { id: paste.id },
|
||||
data: { views: { increment: 1 } },
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
content: true,
|
||||
createdAt: true,
|
||||
views: true,
|
||||
maxViews: true,
|
||||
password: true,
|
||||
},
|
||||
});
|
||||
|
||||
const payload = {
|
||||
id: updated.id,
|
||||
title: updated.title,
|
||||
content: updated.content,
|
||||
createdAt: updated.createdAt,
|
||||
views: updated.views,
|
||||
protected: !!updated.password,
|
||||
};
|
||||
|
||||
if (updated.maxViews !== null && updated.views >= updated.maxViews) {
|
||||
prisma.paste.delete({ where: { id: updated.id } }).catch(() => {});
|
||||
}
|
||||
|
||||
return NextResponse.json(payload, {
|
||||
headers: { 'Cache-Control': 'no-store' },
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
import { prisma } from '@/lib/prisma';
|
||||
import bcrypt from 'bcryptjs';
|
||||
import { getServerSession } from 'next-auth';
|
||||
import { NextResponse } from 'next/server';
|
||||
import { authOptions } from '../auth/[...nextauth]/route';
|
||||
|
||||
import { customAlphabet } from 'nanoid';
|
||||
const nanoid = customAlphabet('abcdefghijklmnopqrstuvwxyz0123456789', 7);
|
||||
|
||||
export async function POST(req: Request) {
|
||||
const body = await req.json();
|
||||
const session = await getServerSession(authOptions);
|
||||
|
||||
let hashedPassword = null;
|
||||
if (body.password) {
|
||||
hashedPassword = await bcrypt.hash(body.password, 10);
|
||||
}
|
||||
|
||||
const paste = await prisma.paste.create({
|
||||
data: {
|
||||
id: nanoid(),
|
||||
title: body.title || null,
|
||||
content: body.content,
|
||||
password: hashedPassword,
|
||||
maxViews: body.maxViews ? parseInt(body.maxViews, 10) : null,
|
||||
createdBy: session?.user?.id ?? null,
|
||||
size: Buffer.byteLength(body.content, 'utf8'),
|
||||
},
|
||||
});
|
||||
|
||||
return NextResponse.json(paste);
|
||||
}
|
||||
|
||||
export async function DELETE(req: Request) {
|
||||
const session = await getServerSession(authOptions);
|
||||
if (!session?.user?.id) {
|
||||
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
||||
}
|
||||
|
||||
const { searchParams } = new URL(req.url);
|
||||
const id = searchParams.get("id");
|
||||
|
||||
if (!id) {
|
||||
return NextResponse.json({ error: "Missing id" }, { status: 400 });
|
||||
}
|
||||
|
||||
try {
|
||||
const paste = await prisma.paste.findUnique({ where: { id } });
|
||||
|
||||
if (!paste || paste.createdBy !== session.user.id) {
|
||||
return NextResponse.json({ error: "Not found" }, { status: 404 });
|
||||
}
|
||||
|
||||
await prisma.paste.delete({ where: { id } });
|
||||
|
||||
return NextResponse.json({ success: true });
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return NextResponse.json({ error: "Server error" }, { status: 500 });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import { getDashboardStats } from '@/lib/stats';
|
||||
import { getServerSession } from 'next-auth';
|
||||
import { NextResponse } from 'next/server';
|
||||
import { authOptions } from '../auth/[...nextauth]/route';
|
||||
|
||||
export async function GET() {
|
||||
const session = await getServerSession(authOptions);
|
||||
const stats = await getDashboardStats(session?.user?.id);
|
||||
return NextResponse.json(stats);
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
import { authOptions } from '@/app/api/auth/[...nextauth]/route';
|
||||
import { prisma } from '@/lib/prisma';
|
||||
import { getServerSession } from 'next-auth';
|
||||
import { NextResponse } from 'next/server';
|
||||
|
||||
export async function GET(req: Request) {
|
||||
const session = await getServerSession(authOptions);
|
||||
if (!session?.user?.id) {
|
||||
return NextResponse.json([], { status: 401 });
|
||||
}
|
||||
|
||||
const { searchParams } = new URL(req.url);
|
||||
|
||||
const page = parseInt(searchParams.get('page') || '1', 10);
|
||||
const perPage = parseInt(searchParams.get('perPage') || '10', 10);
|
||||
const skip = (page - 1) * perPage;
|
||||
|
||||
const search = searchParams.get('q') || '';
|
||||
|
||||
const filter = {
|
||||
createdBy: session.user.id,
|
||||
...(search
|
||||
? {
|
||||
title: {
|
||||
contains: search,
|
||||
mode: 'insensitive',
|
||||
},
|
||||
}
|
||||
: {}),
|
||||
};
|
||||
|
||||
const [pastes, total] = await Promise.all([
|
||||
prisma.paste.findMany({
|
||||
where: filter,
|
||||
orderBy: { createdAt: 'desc' },
|
||||
skip,
|
||||
take: perPage,
|
||||
}),
|
||||
prisma.paste.count({
|
||||
where: filter,
|
||||
}),
|
||||
]);
|
||||
|
||||
return NextResponse.json({ pastes, total });
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import type { Metadata } from 'next';
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'AltBin - Dashboard',
|
||||
};
|
||||
|
||||
export default function DashboardLayout({ children }: { children: React.ReactNode }) {
|
||||
return <>{children}</>;
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
"use client";
|
||||
|
||||
import { useSession } from "next-auth/react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useEffect, useState } from "react";
|
||||
import { toast } from "react-hot-toast";
|
||||
|
||||
import Header from "@/components/dashboard/Header";
|
||||
import LoadingDashboard from "@/components/dashboard/LoadingDashboard";
|
||||
import Pagination from "@/components/dashboard/Pagination";
|
||||
import PasteCard from "@/components/dashboard/PasteCard";
|
||||
import SearchBar from "@/components/dashboard/SearchBar";
|
||||
import Sidebar from "@/components/dashboard/Sidebar";
|
||||
import StatCard from "@/components/dashboard/StatCard";
|
||||
import ConfirmDeleteModal from "@/components/modals/ConfirmDeleteModal";
|
||||
|
||||
import { formatBytes } from "@/lib/format-bytes";
|
||||
|
||||
const PER_PAGE = 6;
|
||||
|
||||
const dashboardIcons = {
|
||||
clipboard: "https://cdn.lordicon.com/gvtjlyjf.json",
|
||||
views: "https://cdn.lordicon.com/dicvhxpz.json",
|
||||
calendar: "https://cdn.lordicon.com/uphbloed.json",
|
||||
code: "https://cdn.lordicon.com/xqdfobxg.json",
|
||||
storage: "https://cdn.lordicon.com/kikjlzqr.json",
|
||||
chart: "https://cdn.lordicon.com/abwrkdvl.json",
|
||||
flame: "https://cdn.lordicon.com/thtrcqvk.json",
|
||||
file: "https://cdn.lordicon.com/fikcyfpp.json",
|
||||
paste: "https://cdn.lordicon.com/hmpomorl.json",
|
||||
};
|
||||
|
||||
export default function DashboardPage() {
|
||||
const { data: session, status } = useSession();
|
||||
const router = useRouter();
|
||||
|
||||
const [searchTerm, setSearchTerm] = useState("");
|
||||
const [stats, setStats] = useState<any>(null);
|
||||
const [pastes, setPastes] = useState<any[]>([]);
|
||||
const [page, setPage] = useState(1);
|
||||
const [totalPastes, setTotalPastes] = useState(0);
|
||||
const [deleteId, setDeleteId] = useState<string | null>(null);
|
||||
|
||||
const handleDelete = async (id: string) => {
|
||||
const res = await fetch(`/api/paste?id=${id}`, { method: "DELETE" });
|
||||
if (res.ok) {
|
||||
setPastes((prev) => prev.filter((p) => p.id !== id));
|
||||
setTotalPastes((prev) => prev - 1);
|
||||
toast.success("Paste deleted successfully 🚀");
|
||||
} else {
|
||||
toast.error("Failed to delete paste ❌");
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (status === "unauthenticated") router.push("/");
|
||||
}, [status, router]);
|
||||
|
||||
useEffect(() => {
|
||||
if (status === "authenticated") {
|
||||
const fetchStats = async () => {
|
||||
const res = await fetch("/api/stats");
|
||||
if (res.ok) setStats(await res.json());
|
||||
};
|
||||
|
||||
const fetchPastes = async () => {
|
||||
const res = await fetch(
|
||||
`/api/user-pastes?page=${page}&perPage=${PER_PAGE}&q=${encodeURIComponent(searchTerm)}`
|
||||
);
|
||||
if (!res.ok) return setPastes([]);
|
||||
try {
|
||||
const data = await res.json();
|
||||
setPastes(data.pastes ?? []);
|
||||
setTotalPastes(data.total ?? 0);
|
||||
} catch {
|
||||
setPastes([]);
|
||||
setTotalPastes(0);
|
||||
}
|
||||
};
|
||||
|
||||
fetchStats();
|
||||
fetchPastes();
|
||||
}
|
||||
}, [status, page, searchTerm]);
|
||||
|
||||
if (status === "loading" || !stats) return <LoadingDashboard />;
|
||||
|
||||
const totalPages = Math.ceil(totalPastes / PER_PAGE);
|
||||
|
||||
return (
|
||||
<div className="flex h-screen bg-[#0d1117]">
|
||||
<Sidebar />
|
||||
|
||||
<main className="flex-1 p-8 overflow-y-auto">
|
||||
<Header user={session?.user?.name} />
|
||||
|
||||
{/* Stats */}
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-6 mb-10">
|
||||
{[
|
||||
{ label: "Total Pastes", value: stats.totalPastes, icon: dashboardIcons.clipboard },
|
||||
{ label: "Total Views", value: stats.totalViews, icon: dashboardIcons.views },
|
||||
{ label: "Last 30 Days", value: stats.recentPastes, icon: dashboardIcons.calendar },
|
||||
{ label: "API Usage", value: stats.apiUsage, icon: dashboardIcons.code },
|
||||
{ label: "Storage Used", value: formatBytes(stats.storageUsed), icon: dashboardIcons.storage },
|
||||
{ label: "Avg Views", value: stats.avgViews, icon: dashboardIcons.chart },
|
||||
{ label: "Most Viewed", value: stats.mostViewed, icon: dashboardIcons.flame },
|
||||
{ label: "Avg Paste Size", value: formatBytes(stats.avgSize), icon: dashboardIcons.file },
|
||||
].map((stat, i) => (
|
||||
<StatCard key={i} label={stat.label} value={stat.value} icon={stat.icon} />
|
||||
))}
|
||||
</div>
|
||||
|
||||
<SearchBar value={searchTerm} onChange={(v) => { setSearchTerm(v); setPage(1); }} />
|
||||
|
||||
{/* Pastes */}
|
||||
<h2 className="text-lg font-semibold text-white mb-4">Your Pastes</h2>
|
||||
{pastes.length === 0 ? (
|
||||
<div className="text-sm text-neutral-400">No pastes found.</div>
|
||||
) : (
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
{pastes.map((paste) => (
|
||||
<PasteCard
|
||||
key={paste.id}
|
||||
paste={paste}
|
||||
onDelete={setDeleteId}
|
||||
pasteIconUrl={dashboardIcons.paste}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<Pagination totalPages={totalPages} currentPage={page} onPageChange={setPage} />
|
||||
|
||||
<ConfirmDeleteModal
|
||||
open={!!deleteId}
|
||||
onOpenChange={(open) => !open && setDeleteId(null)}
|
||||
onConfirm={() => { if (deleteId) { handleDelete(deleteId); setDeleteId(null); } }}
|
||||
/>
|
||||
</main>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 25 KiB |
+18
-38
@@ -1,42 +1,22 @@
|
||||
:root {
|
||||
--background: #ffffff;
|
||||
--foreground: #171717;
|
||||
@import "tailwindcss";
|
||||
|
||||
.hljs,
|
||||
code[class*="language-"],
|
||||
pre[class*="language-"] {
|
||||
background: transparent !important;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:root {
|
||||
--background: #0a0a0a;
|
||||
--foreground: #ededed;
|
||||
}
|
||||
}
|
||||
|
||||
html,
|
||||
body {
|
||||
max-width: 100vw;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
body {
|
||||
color: var(--foreground);
|
||||
background: var(--background);
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
a {
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
html {
|
||||
color-scheme: dark;
|
||||
/* ➡️ Hors du @layer */
|
||||
code[class*="language-"],
|
||||
pre[class*="language-"] {
|
||||
white-space: pre-wrap !important;
|
||||
word-break: break-word !important;
|
||||
}
|
||||
|
||||
@layer utilities {
|
||||
.neon-border {
|
||||
box-shadow:
|
||||
0 0 0 1.5px oklch(0.65 0.2 250 / 0.5),
|
||||
0 0 10px oklch(0.65 0.2 250 / 0.2);
|
||||
}
|
||||
}
|
||||
|
||||
+42
-22
@@ -1,32 +1,52 @@
|
||||
import type { Metadata } from "next";
|
||||
import { Geist, Geist_Mono } from "next/font/google";
|
||||
import "./globals.css";
|
||||
import AuthProvider from '@/components/SessionProvider';
|
||||
import ToasterProvider from '@/components/ui/ToasterProvider';
|
||||
import { ReactNode } from 'react';
|
||||
import './globals.css';
|
||||
|
||||
const geistSans = Geist({
|
||||
variable: "--font-geist-sans",
|
||||
subsets: ["latin"],
|
||||
});
|
||||
|
||||
const geistMono = Geist_Mono({
|
||||
variable: "--font-geist-mono",
|
||||
subsets: ["latin"],
|
||||
});
|
||||
import type { Metadata, Viewport } from "next";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Create Next App",
|
||||
description: "Generated by create next app",
|
||||
title: "AltBin - Modern text and code sharing",
|
||||
description:
|
||||
"AltBin is a fast and modern pastebin for sharing text and code snippets with ease. Secure, minimal, and developer-friendly.",
|
||||
metadataBase: new URL("https://altbin.dev"),
|
||||
openGraph: {
|
||||
title: "AltBin - Modern text and code sharing",
|
||||
description:
|
||||
"Easily share text and code snippets with AltBin. A sleek and secure pastebin for developers.",
|
||||
url: "https://altbin.dev",
|
||||
siteName: "AltBin",
|
||||
images: ["/og-image.png"],
|
||||
locale: "en_US",
|
||||
type: "website",
|
||||
},
|
||||
twitter: {
|
||||
card: "summary_large_image",
|
||||
title: "AltBin - Modern text and code sharing",
|
||||
description:
|
||||
"Share and manage text/code snippets effortlessly with AltBin. Secure and developer-friendly.",
|
||||
images: ["/og-image.png"],
|
||||
creator: "@AltBinApp",
|
||||
},
|
||||
icons: {
|
||||
icon: "/favicon.png",
|
||||
shortcut: "/favicon.png",
|
||||
},
|
||||
};
|
||||
|
||||
export default function RootLayout({
|
||||
children,
|
||||
}: Readonly<{
|
||||
children: React.ReactNode;
|
||||
}>) {
|
||||
export const viewport: Viewport = {
|
||||
themeColor: "#0f172a",
|
||||
};
|
||||
|
||||
export default function RootLayout({ children }: { children: ReactNode }) {
|
||||
return (
|
||||
<html lang="en">
|
||||
<body className={`${geistSans.variable} ${geistMono.variable}`}>
|
||||
{children}
|
||||
<body className="bg-[#0a0a0f] text-neutral-100 font-mono">
|
||||
<AuthProvider>
|
||||
<ToasterProvider />
|
||||
{children}
|
||||
</AuthProvider>
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
'use client';
|
||||
|
||||
import { motion } from 'framer-motion';
|
||||
import { Plus } from 'lucide-react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
|
||||
export default function NotFoundPage() {
|
||||
const router = useRouter();
|
||||
|
||||
return (
|
||||
<div
|
||||
className="min-h-screen flex items-center justify-center px-4"
|
||||
style={{
|
||||
background:
|
||||
'radial-gradient(circle at 20% 30%, #0a0a0f, transparent 60%), radial-gradient(circle at 80% 70%, rgba(147,197,253,0.1), transparent 60%), #0a0a0f',
|
||||
}}
|
||||
>
|
||||
<motion.div
|
||||
initial={{ opacity: 0, scale: 0.9, y: 20 }}
|
||||
animate={{ opacity: 1, scale: 1, y: 0 }}
|
||||
transition={{ duration: 0.5, ease: 'easeOut' }}
|
||||
className="text-center bg-[#11131c]/90 backdrop-blur-xl rounded-3xl px-12 py-16 shadow-2xl border border-white/10 max-w-xl"
|
||||
>
|
||||
<h1 className="text-7xl font-extrabold tracking-tight mb-6">
|
||||
<span className="text-blue-400">404</span>
|
||||
</h1>
|
||||
|
||||
<h2 className="text-3xl font-semibold mb-4 text-neutral-100">
|
||||
Page Not Found
|
||||
</h2>
|
||||
|
||||
<p className="text-base text-neutral-400 mb-10 leading-relaxed">
|
||||
The paste you're looking for might have been deleted, expired, or the
|
||||
URL is incorrect.
|
||||
</p>
|
||||
|
||||
<motion.button
|
||||
whileHover={{ scale: 1.05 }}
|
||||
whileTap={{ scale: 0.97 }}
|
||||
onClick={() => router.push('/')}
|
||||
className="cursor-pointer group inline-flex items-center gap-2 px-6 py-3 rounded-xl text-base font-medium
|
||||
text-white bg-gradient-to-r from-blue-600 to-blue-500 shadow-lg shadow-blue-500/30
|
||||
hover:shadow-blue-500/50 transition-all duration-300 focus:outline-none focus:ring-2 focus:ring-blue-400/60"
|
||||
>
|
||||
<Plus
|
||||
size={20}
|
||||
className="text-blue-200 group-hover:rotate-90 transition-transform duration-300"
|
||||
/>
|
||||
<span>Create New Paste</span>
|
||||
</motion.button>
|
||||
</motion.div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,167 +0,0 @@
|
||||
.page {
|
||||
--gray-rgb: 0, 0, 0;
|
||||
--gray-alpha-200: rgba(var(--gray-rgb), 0.08);
|
||||
--gray-alpha-100: rgba(var(--gray-rgb), 0.05);
|
||||
|
||||
--button-primary-hover: #383838;
|
||||
--button-secondary-hover: #f2f2f2;
|
||||
|
||||
display: grid;
|
||||
grid-template-rows: 20px 1fr 20px;
|
||||
align-items: center;
|
||||
justify-items: center;
|
||||
min-height: 100svh;
|
||||
padding: 80px;
|
||||
gap: 64px;
|
||||
font-family: var(--font-geist-sans);
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.page {
|
||||
--gray-rgb: 255, 255, 255;
|
||||
--gray-alpha-200: rgba(var(--gray-rgb), 0.145);
|
||||
--gray-alpha-100: rgba(var(--gray-rgb), 0.06);
|
||||
|
||||
--button-primary-hover: #ccc;
|
||||
--button-secondary-hover: #1a1a1a;
|
||||
}
|
||||
}
|
||||
|
||||
.main {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 32px;
|
||||
grid-row-start: 2;
|
||||
}
|
||||
|
||||
.main ol {
|
||||
font-family: var(--font-geist-mono);
|
||||
padding-left: 0;
|
||||
margin: 0;
|
||||
font-size: 14px;
|
||||
line-height: 24px;
|
||||
letter-spacing: -0.01em;
|
||||
list-style-position: inside;
|
||||
}
|
||||
|
||||
.main li:not(:last-of-type) {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.main code {
|
||||
font-family: inherit;
|
||||
background: var(--gray-alpha-100);
|
||||
padding: 2px 4px;
|
||||
border-radius: 4px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.ctas {
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.ctas a {
|
||||
appearance: none;
|
||||
border-radius: 128px;
|
||||
height: 48px;
|
||||
padding: 0 20px;
|
||||
border: 1px solid transparent;
|
||||
transition:
|
||||
background 0.2s,
|
||||
color 0.2s,
|
||||
border-color 0.2s;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 16px;
|
||||
line-height: 20px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
a.primary {
|
||||
background: var(--foreground);
|
||||
color: var(--background);
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
a.secondary {
|
||||
border-color: var(--gray-alpha-200);
|
||||
min-width: 158px;
|
||||
}
|
||||
|
||||
.footer {
|
||||
grid-row-start: 3;
|
||||
display: flex;
|
||||
gap: 24px;
|
||||
}
|
||||
|
||||
.footer a {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.footer img {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* Enable hover only on non-touch devices */
|
||||
@media (hover: hover) and (pointer: fine) {
|
||||
a.primary:hover {
|
||||
background: var(--button-primary-hover);
|
||||
border-color: transparent;
|
||||
}
|
||||
|
||||
a.secondary:hover {
|
||||
background: var(--button-secondary-hover);
|
||||
border-color: transparent;
|
||||
}
|
||||
|
||||
.footer a:hover {
|
||||
text-decoration: underline;
|
||||
text-underline-offset: 4px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
.page {
|
||||
padding: 32px;
|
||||
padding-bottom: 80px;
|
||||
}
|
||||
|
||||
.main {
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.main ol {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.ctas {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.ctas a {
|
||||
font-size: 14px;
|
||||
height: 40px;
|
||||
padding: 0 16px;
|
||||
}
|
||||
|
||||
a.secondary {
|
||||
min-width: auto;
|
||||
}
|
||||
|
||||
.footer {
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.logo {
|
||||
filter: invert();
|
||||
}
|
||||
}
|
||||
+6
-90
@@ -1,95 +1,11 @@
|
||||
import Image from "next/image";
|
||||
import styles from "./page.module.css";
|
||||
'use client';
|
||||
|
||||
export default function Home() {
|
||||
import PasteForm from '@/components/PasteForm';
|
||||
|
||||
export default function HomePage() {
|
||||
return (
|
||||
<div className={styles.page}>
|
||||
<main className={styles.main}>
|
||||
<Image
|
||||
className={styles.logo}
|
||||
src="/next.svg"
|
||||
alt="Next.js logo"
|
||||
width={180}
|
||||
height={38}
|
||||
priority
|
||||
/>
|
||||
<ol>
|
||||
<li>
|
||||
Get started by editing <code>app/page.tsx</code>.
|
||||
</li>
|
||||
<li>Save and see your changes instantly.</li>
|
||||
</ol>
|
||||
|
||||
<div className={styles.ctas}>
|
||||
<a
|
||||
className={styles.primary}
|
||||
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<Image
|
||||
className={styles.logo}
|
||||
src="/vercel.svg"
|
||||
alt="Vercel logomark"
|
||||
width={20}
|
||||
height={20}
|
||||
/>
|
||||
Deploy now
|
||||
</a>
|
||||
<a
|
||||
href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className={styles.secondary}
|
||||
>
|
||||
Read our docs
|
||||
</a>
|
||||
</div>
|
||||
</main>
|
||||
<footer className={styles.footer}>
|
||||
<a
|
||||
href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<Image
|
||||
aria-hidden
|
||||
src="/file.svg"
|
||||
alt="File icon"
|
||||
width={16}
|
||||
height={16}
|
||||
/>
|
||||
Learn
|
||||
</a>
|
||||
<a
|
||||
href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<Image
|
||||
aria-hidden
|
||||
src="/window.svg"
|
||||
alt="Window icon"
|
||||
width={16}
|
||||
height={16}
|
||||
/>
|
||||
Examples
|
||||
</a>
|
||||
<a
|
||||
href="https://nextjs.org?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<Image
|
||||
aria-hidden
|
||||
src="/globe.svg"
|
||||
alt="Globe icon"
|
||||
width={16}
|
||||
height={16}
|
||||
/>
|
||||
Go to nextjs.org →
|
||||
</a>
|
||||
</footer>
|
||||
<div className="relative min-h-screen">
|
||||
<PasteForm />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
export async function fetchPastes() {
|
||||
const res = await fetch('/api/paste');
|
||||
return await res.json();
|
||||
}
|
||||
Reference in New Issue
Block a user