Compare commits
26 Commits
5bad3ee9eb
...
renovate/r
Author | SHA1 | Date | |
---|---|---|---|
40dad1ba41 | |||
addcc45955 | |||
b5f68477b6 | |||
4e541eaa6d | |||
3ab87a70cb | |||
9af304db35 | |||
8d07092dc4 | |||
aa510c6bd3 | |||
46ef8ba4a7 | |||
7087060393 | |||
0bd54c23f9 | |||
f00bf9499b | |||
b8e031b4a9 | |||
9d0f4422eb | |||
fd7c0e9d0a | |||
71e913092e | |||
d50242b96e | |||
f185270a5b | |||
a733af62db | |||
b5f4b39feb | |||
e5ed38c876 | |||
54335a1210 | |||
e9f63a369d | |||
7b392a4be3 | |||
b22c5e7e50 | |||
4bb16d287b |
3
.env
3
.env
@ -1 +1,2 @@
|
||||
NEXT_PUBLIC_API_ENDPOINT=https://paste.fascinated.cc/api
|
||||
NEXT_PUBLIC_API_ENDPOINT=https://paste.fascinated.cc/api
|
||||
NEXT_PUBLIC_SENTRY_DSN=https://8b4191f7359b498e9609dd9237ed53f5@glitchtip.fascinated.cc/4
|
@ -36,4 +36,6 @@ jobs:
|
||||
with:
|
||||
push: true
|
||||
context: .
|
||||
tags: fascinated/paste-frontend:latest
|
||||
tags: fascinated/paste-frontend:latest
|
||||
secrets: |
|
||||
"SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}"
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -34,3 +34,6 @@ yarn-error.log*
|
||||
# typescript
|
||||
*.tsbuildinfo
|
||||
next-env.d.ts
|
||||
|
||||
# Sentry Config File
|
||||
.sentryclirc
|
||||
|
@ -22,6 +22,10 @@ WORKDIR /app
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
COPY . .
|
||||
|
||||
# Pass the Sentry auth token as a build argument
|
||||
ARG SENTRY_AUTH_TOKEN
|
||||
ENV SENTRY_AUTH_TOKEN $SENTRY_AUTH_TOKEN
|
||||
|
||||
# Disable telemetry during build
|
||||
ENV NEXT_TELEMETRY_DISABLED 1
|
||||
|
||||
@ -54,6 +58,9 @@ RUN chown nextjs:nodejs .next
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
||||
|
||||
# Copy the public folder
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/public ./public
|
||||
|
||||
USER nextjs
|
||||
|
||||
ENV HOSTNAME "0.0.0.0"
|
||||
|
9
LICENSE
Normal file
9
LICENSE
Normal file
@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 Liam (Fascinated)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@ -1,6 +1,23 @@
|
||||
import {withSentryConfig} from "@sentry/nextjs";
|
||||
/** @type {import('next').NextConfig} */
|
||||
const nextConfig = {
|
||||
output: "standalone",
|
||||
output: "standalone",
|
||||
};
|
||||
|
||||
export default nextConfig;
|
||||
export default withSentryConfig(nextConfig, {
|
||||
// For all available options, see:
|
||||
// https://github.com/getsentry/sentry-webpack-plugin#options
|
||||
|
||||
silent: true,
|
||||
org: "paste",
|
||||
project: "frontend",
|
||||
url: "https://glitchtip.fascinated.cc/",
|
||||
}, {
|
||||
// For all available options, see:
|
||||
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
|
||||
|
||||
widenClientFileUpload: true,
|
||||
tunnelRoute: "/monitoring",
|
||||
hideSourceMaps: true,
|
||||
disableLogger: true,
|
||||
});
|
@ -9,16 +9,19 @@
|
||||
"lint": "next lint"
|
||||
},
|
||||
"dependencies": {
|
||||
"@heroicons/react": "^2.1.3",
|
||||
"@radix-ui/react-slot": "^1.0.2",
|
||||
"@radix-ui/react-toast": "^1.1.5",
|
||||
"@radix-ui/react-tooltip": "^1.0.7",
|
||||
"@sentry/nextjs": "7.105.0",
|
||||
"@types/react-syntax-highlighter": "^15.5.11",
|
||||
"@vscode/vscode-languagedetection": "^1.0.22",
|
||||
"class-variance-authority": "^0.7.0",
|
||||
"clsx": "^2.1.0",
|
||||
"encoding": "^0.1.13",
|
||||
"lucide-react": "^0.372.0",
|
||||
"lucide-react": "^0.376.0",
|
||||
"moment": "^2.30.1",
|
||||
"next": "14.2.2",
|
||||
"next": "14.2.3",
|
||||
"next-themes": "^0.3.0",
|
||||
"react": "^18",
|
||||
"react-dom": "^18",
|
||||
@ -31,7 +34,7 @@
|
||||
"@types/react": "^18",
|
||||
"@types/react-dom": "^18",
|
||||
"eslint": "^8",
|
||||
"eslint-config-next": "14.2.2",
|
||||
"eslint-config-next": "14.2.3",
|
||||
"postcss": "^8",
|
||||
"tailwindcss": "^3.4.1",
|
||||
"typescript": "^5"
|
||||
|
882
pnpm-lock.yaml
generated
882
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
BIN
public/favicon.ico
Normal file
BIN
public/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 40 KiB |
30
sentry.client.config.ts
Normal file
30
sentry.client.config.ts
Normal file
@ -0,0 +1,30 @@
|
||||
// This file configures the initialization of Sentry on the client.
|
||||
// The config you add here will be used whenever a users loads a page in their browser.
|
||||
// https://docs.sentry.io/platforms/javascript/guides/nextjs/
|
||||
|
||||
import * as Sentry from "@sentry/nextjs";
|
||||
|
||||
Sentry.init({
|
||||
dsn: "https://8b4191f7359b498e9609dd9237ed53f5@glitchtip.fascinated.cc/4",
|
||||
|
||||
// Adjust this value in production, or use tracesSampler for greater control
|
||||
tracesSampleRate: 1,
|
||||
|
||||
// Setting this option to true will print useful information to the console while you're setting up Sentry.
|
||||
debug: false,
|
||||
|
||||
replaysOnErrorSampleRate: 1.0,
|
||||
|
||||
// This sets the sample rate to be 10%. You may want this to be 100% while
|
||||
// in development and sample at a lower rate in production
|
||||
replaysSessionSampleRate: 0.1,
|
||||
|
||||
// You can remove this option if you're not planning to use the Sentry Session Replay feature:
|
||||
integrations: [
|
||||
Sentry.replayIntegration({
|
||||
// Additional Replay configuration goes in here, for example:
|
||||
maskAllText: true,
|
||||
blockAllMedia: true,
|
||||
}),
|
||||
],
|
||||
});
|
16
sentry.edge.config.ts
Normal file
16
sentry.edge.config.ts
Normal file
@ -0,0 +1,16 @@
|
||||
// This file configures the initialization of Sentry for edge features (middleware, edge routes, and so on).
|
||||
// The config you add here will be used whenever one of the edge features is loaded.
|
||||
// Note that this config is unrelated to the Vercel Edge Runtime and is also required when running locally.
|
||||
// https://docs.sentry.io/platforms/javascript/guides/nextjs/
|
||||
|
||||
import * as Sentry from "@sentry/nextjs";
|
||||
|
||||
Sentry.init({
|
||||
dsn: "https://8b4191f7359b498e9609dd9237ed53f5@glitchtip.fascinated.cc/4",
|
||||
|
||||
// Adjust this value in production, or use tracesSampler for greater control
|
||||
tracesSampleRate: 1,
|
||||
|
||||
// Setting this option to true will print useful information to the console while you're setting up Sentry.
|
||||
debug: false,
|
||||
});
|
19
sentry.server.config.ts
Normal file
19
sentry.server.config.ts
Normal file
@ -0,0 +1,19 @@
|
||||
// This file configures the initialization of Sentry on the server.
|
||||
// The config you add here will be used whenever the server handles a request.
|
||||
// https://docs.sentry.io/platforms/javascript/guides/nextjs/
|
||||
|
||||
import * as Sentry from "@sentry/nextjs";
|
||||
|
||||
Sentry.init({
|
||||
dsn: "https://8b4191f7359b498e9609dd9237ed53f5@glitchtip.fascinated.cc/4",
|
||||
|
||||
// Adjust this value in production, or use tracesSampler for greater control
|
||||
tracesSampleRate: 1,
|
||||
|
||||
// Setting this option to true will print useful information to the console while you're setting up Sentry.
|
||||
debug: false,
|
||||
|
||||
// uncomment the line below to enable Spotlight (https://spotlightjs.com)
|
||||
// spotlight: process.env.NODE_ENV === 'development',
|
||||
|
||||
});
|
@ -1,88 +1,57 @@
|
||||
import { cache, ReactElement } from "react";
|
||||
import React, { ReactElement } from "react";
|
||||
import { ActionMenu } from "@/app/components/action-menu";
|
||||
import { Metadata } from "next";
|
||||
import moment from "moment";
|
||||
import { notFound } from "next/navigation";
|
||||
import { CodeBlock } from "@/app/components/code-block";
|
||||
import { detectLanguage } from "@/app/common/lang-detection/detection";
|
||||
|
||||
type PasteProps = {
|
||||
params: {
|
||||
id: string;
|
||||
};
|
||||
};
|
||||
|
||||
type Paste = {
|
||||
/**
|
||||
* The paste content.
|
||||
*/
|
||||
content: string;
|
||||
|
||||
/**
|
||||
* The date the paste was created.
|
||||
*/
|
||||
created: number;
|
||||
|
||||
/**
|
||||
* The detected language of the paste.
|
||||
*/
|
||||
language: string;
|
||||
};
|
||||
|
||||
const getPaste = cache(async (id: string) => {
|
||||
const response: Response = await fetch(
|
||||
`${process.env.NEXT_PUBLIC_API_ENDPOINT}/${id}`,
|
||||
{
|
||||
next: {
|
||||
revalidate: 300, // Keep this response cached for 5 minutes
|
||||
},
|
||||
},
|
||||
);
|
||||
const json = await response.json();
|
||||
|
||||
if (json.code && json.message) {
|
||||
return undefined;
|
||||
}
|
||||
return {
|
||||
content: json.content,
|
||||
created: json.created,
|
||||
language: await detectLanguage(json.content),
|
||||
};
|
||||
}) as (id: string) => Promise<Paste | undefined>;
|
||||
import { Button } from "@/app/components/ui/button";
|
||||
import Link from "next/link";
|
||||
import {
|
||||
generatePasteMetadata,
|
||||
getPaste,
|
||||
type Paste,
|
||||
} from "@/app/common/pastes";
|
||||
import { PastePageProps } from "@/app/types/paste-page";
|
||||
|
||||
export async function generateMetadata({
|
||||
params: { id },
|
||||
}: PasteProps): Promise<Metadata> {
|
||||
const data: Paste | undefined = await getPaste(id);
|
||||
if (data == undefined) {
|
||||
return {
|
||||
description: "Not found",
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
title: `Paste - ${id}.${data.language}`,
|
||||
description: `Created: ${moment(data.created)}\n\nClick to view the paste.`,
|
||||
};
|
||||
}: PastePageProps): Promise<Metadata> {
|
||||
return generatePasteMetadata(id);
|
||||
}
|
||||
|
||||
export default async function Paste({
|
||||
params: { id },
|
||||
}: PasteProps): Promise<ReactElement> {
|
||||
}: PastePageProps): Promise<ReactElement> {
|
||||
const data: Paste | undefined = await getPaste(id);
|
||||
|
||||
if (data == undefined) {
|
||||
return notFound();
|
||||
}
|
||||
|
||||
const created = moment(data.created)
|
||||
.format("MMMM Do YYYY, h:mm:ss a")
|
||||
.toString();
|
||||
|
||||
return (
|
||||
<div className="relative">
|
||||
<div className="absolute top-0 right-0 flex flex-col items-end mx-3 mt-2">
|
||||
<ActionMenu />
|
||||
<div className="relative h-full">
|
||||
{/* Action Menu */}
|
||||
<ActionMenu>
|
||||
<Link href={"/"}>
|
||||
<Button>New</Button>
|
||||
</Link>
|
||||
<Link href={`/raw/${id}`}>
|
||||
<Button>Raw</Button>
|
||||
</Link>
|
||||
</ActionMenu>
|
||||
|
||||
{/* Paste Details */}
|
||||
<div className="absolute right-0 bottom-0 text-right p-1.5">
|
||||
<p>{data.language}</p>
|
||||
<p>{created}</p>
|
||||
</div>
|
||||
|
||||
<div className="p-1 hljs !bg-transparent text-sm">
|
||||
{/* Paste Content */}
|
||||
<div className="p-1 !bg-transparent text-sm">
|
||||
<CodeBlock code={data.content} language={data.language} />
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1,13 +1,15 @@
|
||||
"use client";
|
||||
|
||||
import { ReactElement, useState } from "react";
|
||||
import { ReactElement, useEffect, useState } from "react";
|
||||
import { ActionMenu } from "@/app/components/action-menu";
|
||||
import { Button } from "@/app/components/ui/button";
|
||||
import { useToast } from "@/app/components/ui/use-toast";
|
||||
import { ArrowPathIcon } from "@heroicons/react/16/solid";
|
||||
|
||||
export default function Home(): ReactElement {
|
||||
const { toast } = useToast();
|
||||
const [value, setValue] = useState("");
|
||||
const [creating, setCreating] = useState(false);
|
||||
|
||||
/**
|
||||
* Uploads the paste to the server.
|
||||
@ -15,52 +17,73 @@ export default function Home(): ReactElement {
|
||||
async function createPaste() {
|
||||
// Ignore empty pastes, we don't want to save them
|
||||
if (!value || value.length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Limit the paste size to 400,000 characters
|
||||
if (value.length > 400_000) {
|
||||
toast({
|
||||
title: "Paste",
|
||||
description: "Pastes can't be longer than 400,000 characters",
|
||||
description: "Paste is empty",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
setCreating(true);
|
||||
// Upload the paste to the server
|
||||
const response = await fetch(
|
||||
`${process.env.NEXT_PUBLIC_API_ENDPOINT}/upload`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Content-Type": "text/plain",
|
||||
},
|
||||
body: value,
|
||||
},
|
||||
);
|
||||
|
||||
// Redirect to the new paste
|
||||
const data = await response.json();
|
||||
|
||||
if (!response.ok) {
|
||||
toast({
|
||||
title: "Paste",
|
||||
description: data.message,
|
||||
});
|
||||
setCreating(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// Redirect to the new paste
|
||||
window.location.href = `/${data.id}`;
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
document.getElementById("paste-input")?.focus();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="p-3 h-screen w-screen relative">
|
||||
<div className="flex gap-2 h-full w-full text-sm">
|
||||
<div className="flex gap-2 h-full w-full text-xs">
|
||||
{/* > */}
|
||||
<p className="hidden md:block">></p>
|
||||
|
||||
{/* Input */}
|
||||
<textarea
|
||||
onInput={(event) => {
|
||||
setValue((event.target as HTMLTextAreaElement).value);
|
||||
}}
|
||||
id="paste-input"
|
||||
className="w-full h-full bg-background outline-none resize-none"
|
||||
placeholder="Paste your code here..."
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="absolute top-0 right-0 mx-3 mt-2">
|
||||
<ActionMenu>
|
||||
<Button onClick={() => createPaste()}>Save</Button>
|
||||
</ActionMenu>
|
||||
</div>
|
||||
{/* Action Menu */}
|
||||
<ActionMenu>
|
||||
<Button onClick={() => createPaste()} className="flex gap-1">
|
||||
{creating && (
|
||||
<div className="animate-spin">
|
||||
<ArrowPathIcon width={16} height={16} />
|
||||
</div>
|
||||
)}
|
||||
Save
|
||||
</Button>
|
||||
</ActionMenu>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
47
src/app/(pages)/raw/[id]/page.tsx
Normal file
47
src/app/(pages)/raw/[id]/page.tsx
Normal file
@ -0,0 +1,47 @@
|
||||
import React, { ReactElement } from "react";
|
||||
import { ActionMenu } from "@/app/components/action-menu";
|
||||
import { Metadata } from "next";
|
||||
import { notFound } from "next/navigation";
|
||||
import { Button } from "@/app/components/ui/button";
|
||||
import Link from "next/link";
|
||||
import {
|
||||
generatePasteMetadata,
|
||||
getPaste,
|
||||
type Paste,
|
||||
} from "@/app/common/pastes";
|
||||
import { PastePageProps } from "@/app/types/paste-page";
|
||||
|
||||
export async function generateMetadata({
|
||||
params: { id },
|
||||
}: PastePageProps): Promise<Metadata> {
|
||||
return generatePasteMetadata(id);
|
||||
}
|
||||
|
||||
export default async function Paste({
|
||||
params: { id },
|
||||
}: PastePageProps): Promise<ReactElement> {
|
||||
const data: Paste | undefined = await getPaste(id);
|
||||
|
||||
if (data == undefined) {
|
||||
return notFound();
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="relative h-full">
|
||||
{/* Action Menu */}
|
||||
<ActionMenu>
|
||||
<Link href={"/"}>
|
||||
<Button>New</Button>
|
||||
</Link>
|
||||
<Link href={`/${id}`}>
|
||||
<Button>Formated</Button>
|
||||
</Link>
|
||||
</ActionMenu>
|
||||
|
||||
{/* Paste Content */}
|
||||
<div className="p-1 hljs !bg-transparent text-sm">
|
||||
<code>{data.content}</code>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
63
src/app/common/pastes.ts
Normal file
63
src/app/common/pastes.ts
Normal file
@ -0,0 +1,63 @@
|
||||
import { cache } from "react";
|
||||
import { detectLanguage } from "@/app/common/lang-detection/detection";
|
||||
import { Metadata } from "next";
|
||||
|
||||
export type Paste = {
|
||||
/**
|
||||
* The paste content.
|
||||
*/
|
||||
content: string;
|
||||
|
||||
/**
|
||||
* The date the paste was created.
|
||||
*/
|
||||
created: string;
|
||||
|
||||
/**
|
||||
* The detected language of the paste.
|
||||
*/
|
||||
language: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Fetches a paste from the API.
|
||||
*/
|
||||
export const getPaste = cache(async (id: string) => {
|
||||
const response: Response = await fetch(
|
||||
`${process.env.NEXT_PUBLIC_API_ENDPOINT}/${id}`,
|
||||
{
|
||||
next: {
|
||||
revalidate: 300, // Keep this response cached for 5 minutes
|
||||
},
|
||||
},
|
||||
);
|
||||
const json = await response.json();
|
||||
|
||||
if (json.code && json.message) {
|
||||
return undefined;
|
||||
}
|
||||
return {
|
||||
content: json.content,
|
||||
created: json.created,
|
||||
language: await detectLanguage(json.content),
|
||||
};
|
||||
}) as (id: string) => Promise<Paste | undefined>;
|
||||
|
||||
/**
|
||||
* Generates metadata for a paste.
|
||||
*
|
||||
* @param id The ID of the paste.
|
||||
*/
|
||||
export async function generatePasteMetadata(id: string): Promise<Metadata> {
|
||||
const data: Paste | undefined = await getPaste(id);
|
||||
if (data == undefined) {
|
||||
return {
|
||||
description: "Not found",
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
title: `Paste - ${id}.${data.language}`,
|
||||
description: `Click to view the paste.`,
|
||||
};
|
||||
}
|
@ -1,6 +1,12 @@
|
||||
import React from "react";
|
||||
import { Button } from "@/app/components/ui/button";
|
||||
import Link from "next/link";
|
||||
import { Button } from "@/app/components/ui/button";
|
||||
import { HeartIcon, InformationCircleIcon } from "@heroicons/react/24/outline";
|
||||
import {
|
||||
Tooltip,
|
||||
TooltipContent,
|
||||
TooltipTrigger,
|
||||
} from "@/app/components/ui/tooltip";
|
||||
|
||||
type ActionMenuProps = {
|
||||
children?: React.ReactNode;
|
||||
@ -8,11 +14,32 @@ type ActionMenuProps = {
|
||||
|
||||
export function ActionMenu({ children }: ActionMenuProps) {
|
||||
return (
|
||||
<div className="flex items-center bg-secondary rounded-md p-2 gap-2">
|
||||
{children}
|
||||
<Link href={"/"}>
|
||||
<Button>New</Button>
|
||||
</Link>
|
||||
<div className="absolute top-0 right-0 flex flex-col items-end mx-3 mt-2">
|
||||
<div className="flex items-center bg-secondary rounded-md p-2 gap-2">
|
||||
{children}
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<Link href={"https://git.fascinated.cc/Paste"} target="_blank">
|
||||
<Button>
|
||||
<InformationCircleIcon width={24} height={24} />
|
||||
</Button>
|
||||
</Link>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent className="flex flex-col gap-2">
|
||||
<div>
|
||||
<p className="font-semibold">This project is open source!</p>
|
||||
|
||||
<div className="flex gap-1.5 items-center">
|
||||
<p>Made with</p>
|
||||
<HeartIcon width={16} height={16} color="#e31b23" />
|
||||
<p>by Fascinated</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p>Click to view the Source Code</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ export function CodeBlock({ code, language }: CodeBlockProps): ReactElement {
|
||||
<SyntaxHighlighter
|
||||
className="!bg-transparent text-xs"
|
||||
style={atomOneDark}
|
||||
language={language}
|
||||
language={language == "text" ? "plaintext" : language}
|
||||
showLineNumbers
|
||||
codeTagProps={{
|
||||
style: {
|
||||
|
30
src/app/components/ui/tooltip.tsx
Normal file
30
src/app/components/ui/tooltip.tsx
Normal file
@ -0,0 +1,30 @@
|
||||
"use client";
|
||||
|
||||
import * as React from "react";
|
||||
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
||||
|
||||
import { cn } from "@/app/common/utils";
|
||||
|
||||
const TooltipProvider = TooltipPrimitive.Provider;
|
||||
|
||||
const Tooltip = TooltipPrimitive.Root;
|
||||
|
||||
const TooltipTrigger = TooltipPrimitive.Trigger;
|
||||
|
||||
const TooltipContent = React.forwardRef<
|
||||
React.ElementRef<typeof TooltipPrimitive.Content>,
|
||||
React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>
|
||||
>(({ className, sideOffset = 4, ...props }, ref) => (
|
||||
<TooltipPrimitive.Content
|
||||
ref={ref}
|
||||
sideOffset={sideOffset}
|
||||
className={cn(
|
||||
"z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
));
|
||||
TooltipContent.displayName = TooltipPrimitive.Content.displayName;
|
||||
|
||||
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };
|
19
src/app/global-error.jsx
Normal file
19
src/app/global-error.jsx
Normal file
@ -0,0 +1,19 @@
|
||||
"use client";
|
||||
|
||||
import * as Sentry from "@sentry/nextjs";
|
||||
import Error from "next/error";
|
||||
import { useEffect } from "react";
|
||||
|
||||
export default function GlobalError({ error }) {
|
||||
useEffect(() => {
|
||||
Sentry.captureException(error);
|
||||
}, [error]);
|
||||
|
||||
return (
|
||||
<html>
|
||||
<body>
|
||||
<Error />
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
@ -4,6 +4,8 @@ import { ThemeProvider } from "@/app/components/theme-provider";
|
||||
import { ReactNode } from "react";
|
||||
import { jetbrainsMono } from "@/app/common/font/font";
|
||||
import { Toaster } from "@/app/components/ui/toaster";
|
||||
import { cn } from "@/app/common/utils";
|
||||
import { TooltipProvider } from "@/app/components/ui/tooltip";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Paste",
|
||||
@ -17,16 +19,18 @@ export default function RootLayout({
|
||||
}>) {
|
||||
return (
|
||||
<html lang="en">
|
||||
<body className={jetbrainsMono.className}>
|
||||
<Toaster />
|
||||
<ThemeProvider
|
||||
attribute="class"
|
||||
defaultTheme="dark"
|
||||
enableSystem
|
||||
disableTransitionOnChange
|
||||
>
|
||||
{children}
|
||||
</ThemeProvider>
|
||||
<body className={cn(jetbrainsMono.className, "w-screen h-screen")}>
|
||||
<TooltipProvider>
|
||||
<Toaster />
|
||||
<ThemeProvider
|
||||
attribute="class"
|
||||
defaultTheme="dark"
|
||||
enableSystem
|
||||
disableTransitionOnChange
|
||||
>
|
||||
{children}
|
||||
</ThemeProvider>
|
||||
</TooltipProvider>
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
|
5
src/app/types/paste-page.ts
Normal file
5
src/app/types/paste-page.ts
Normal file
@ -0,0 +1,5 @@
|
||||
export type PastePageProps = {
|
||||
params: {
|
||||
id: string;
|
||||
};
|
||||
};
|
Reference in New Issue
Block a user