26 Commits

Author SHA1 Message Date
bd5dd64d5a Update dependency @sentry/nextjs to v7.116.0 2024-05-17 14:01:44 +00:00
Lee
addcc45955 Merge pull request 'Update dependency lucide-react to ^0.376.0' (#8) from renovate/lucide-react-0.x into master
Some checks failed
Deploy App / docker (ubuntu-latest) (push) Failing after 5s
Publish Docker Image / docker (ubuntu-latest) (push) Failing after 47s
Reviewed-on: #8
2024-04-27 09:49:12 +00:00
b5f68477b6 fix ci
Some checks failed
Deploy App / docker (ubuntu-latest) (push) Failing after 3s
Publish Docker Image / docker (ubuntu-latest) (push) Failing after 22s
2024-04-26 22:34:33 +01:00
4e541eaa6d fix ci
Some checks failed
Deploy App / docker (ubuntu-latest) (push) Failing after 7s
Publish Docker Image / docker (ubuntu-latest) (push) Failing after 25s
2024-04-26 22:32:43 +01:00
3ab87a70cb fix ci
Some checks failed
Deploy App / docker (ubuntu-latest) (push) Successful in 1m10s
Publish Docker Image / docker (ubuntu-latest) (push) Failing after 26s
2024-04-26 22:27:01 +01:00
9af304db35 test Sentry tunnel routing
Some checks failed
Deploy App / docker (ubuntu-latest) (push) Successful in 2m5s
Publish Docker Image / docker (ubuntu-latest) (push) Has been cancelled
2024-04-26 22:24:39 +01:00
8d07092dc4 add Sentry
All checks were successful
Deploy App / docker (ubuntu-latest) (push) Successful in 3m36s
Publish Docker Image / docker (ubuntu-latest) (push) Successful in 4m27s
2024-04-26 22:07:02 +01:00
aa510c6bd3 Update dependency lucide-react to ^0.376.0 2024-04-26 17:01:17 +00:00
46ef8ba4a7 add favicon
All checks were successful
Deploy App / docker (ubuntu-latest) (push) Successful in 2m10s
Publish Docker Image / docker (ubuntu-latest) (push) Successful in 1m36s
2024-04-26 06:49:06 +01:00
7087060393 Merge remote-tracking branch 'origin/master'
All checks were successful
Deploy App / docker (ubuntu-latest) (push) Successful in 2m13s
Publish Docker Image / docker (ubuntu-latest) (push) Successful in 1m16s
2024-04-25 18:53:45 +01:00
0bd54c23f9 fix creating posts 2024-04-25 18:53:40 +01:00
Lee
f00bf9499b Add LICENSE 2024-04-24 20:28:29 +00:00
Lee
b8e031b4a9 Merge pull request 'Update nextjs monorepo to v14.2.3' (#6) from renovate/nextjs-monorepo into master
All checks were successful
Deploy App / docker (ubuntu-latest) (push) Successful in 1m34s
Publish Docker Image / docker (ubuntu-latest) (push) Successful in 1m52s
Reviewed-on: #6
2024-04-24 20:18:02 +00:00
9d0f4422eb add info button to the action menu
All checks were successful
Deploy App / docker (ubuntu-latest) (push) Successful in 1m21s
Publish Docker Image / docker (ubuntu-latest) (push) Successful in 1m22s
2024-04-24 19:53:58 +01:00
fd7c0e9d0a Update nextjs monorepo to v14.2.3 2024-04-24 18:01:17 +00:00
71e913092e add auto select to the paste input and added a placeholder to the input
All checks were successful
Deploy App / docker (ubuntu-latest) (push) Successful in 1m3s
Publish Docker Image / docker (ubuntu-latest) (push) Successful in 53s
2024-04-24 18:42:42 +01:00
d50242b96e add comments to the html and use text-xs on the main page
All checks were successful
Deploy App / docker (ubuntu-latest) (push) Successful in 1m4s
Publish Docker Image / docker (ubuntu-latest) (push) Successful in 53s
2024-04-24 18:29:29 +01:00
f185270a5b cleanup and add a raw page
All checks were successful
Deploy App / docker (ubuntu-latest) (push) Successful in 1m4s
2024-04-24 17:46:47 +01:00
a733af62db Merge remote-tracking branch 'origin/master'
All checks were successful
Deploy App / docker (ubuntu-latest) (push) Successful in 1m4s
Publish Docker Image / docker (ubuntu-latest) (push) Successful in 55s
2024-04-24 17:35:30 +01:00
b5f4b39feb change when the action menu buttons are shown 2024-04-24 17:35:25 +01:00
Lee
e5ed38c876 Merge pull request 'Update dependency lucide-react to ^0.373.0' (#5) from renovate/lucide-react-0.x into master
All checks were successful
Deploy App / docker (ubuntu-latest) (push) Successful in 1m54s
Publish Docker Image / docker (ubuntu-latest) (push) Successful in 1m30s
Reviewed-on: #5
2024-04-24 16:20:48 +00:00
54335a1210 Update dependency lucide-react to ^0.373.0 2024-04-24 08:01:10 +00:00
e9f63a369d add time uploaded to the paste
All checks were successful
Deploy App / docker (ubuntu-latest) (push) Successful in 1m4s
Publish Docker Image / docker (ubuntu-latest) (push) Successful in 57s
2024-04-23 21:59:22 +01:00
7b392a4be3 add loading icon when clicking save
All checks were successful
Deploy App / docker (ubuntu-latest) (push) Successful in 1m38s
Publish Docker Image / docker (ubuntu-latest) (push) Successful in 1m32s
2024-04-23 21:35:47 +01:00
b22c5e7e50 Merge remote-tracking branch 'origin/master'
All checks were successful
Deploy App / docker (ubuntu-latest) (push) Successful in 1m56s
Publish Docker Image / docker (ubuntu-latest) (push) Successful in 1m33s
2024-04-23 21:23:24 +01:00
4bb16d287b verify paste length on server 2024-04-23 21:23:18 +01:00
22 changed files with 991 additions and 158 deletions

1
.env
View File

@ -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

View File

@ -37,3 +37,5 @@ jobs:
push: true push: true
context: . context: .
tags: fascinated/paste-frontend:latest tags: fascinated/paste-frontend:latest
secrets: |
"SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}"

3
.gitignore vendored
View File

@ -34,3 +34,6 @@ yarn-error.log*
# typescript # typescript
*.tsbuildinfo *.tsbuildinfo
next-env.d.ts next-env.d.ts
# Sentry Config File
.sentryclirc

View File

@ -22,6 +22,10 @@ WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules COPY --from=deps /app/node_modules ./node_modules
COPY . . 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 # Disable telemetry during build
ENV NEXT_TELEMETRY_DISABLED 1 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/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static 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 USER nextjs
ENV HOSTNAME "0.0.0.0" ENV HOSTNAME "0.0.0.0"

9
LICENSE Normal file
View 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.

View File

@ -1,6 +1,23 @@
import {withSentryConfig} from "@sentry/nextjs";
/** @type {import('next').NextConfig} */ /** @type {import('next').NextConfig} */
const 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,
});

View File

@ -9,16 +9,19 @@
"lint": "next lint" "lint": "next lint"
}, },
"dependencies": { "dependencies": {
"@heroicons/react": "^2.1.3",
"@radix-ui/react-slot": "^1.0.2", "@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-toast": "^1.1.5", "@radix-ui/react-toast": "^1.1.5",
"@radix-ui/react-tooltip": "^1.0.7",
"@sentry/nextjs": "7.116.0",
"@types/react-syntax-highlighter": "^15.5.11", "@types/react-syntax-highlighter": "^15.5.11",
"@vscode/vscode-languagedetection": "^1.0.22", "@vscode/vscode-languagedetection": "^1.0.22",
"class-variance-authority": "^0.7.0", "class-variance-authority": "^0.7.0",
"clsx": "^2.1.0", "clsx": "^2.1.0",
"encoding": "^0.1.13", "encoding": "^0.1.13",
"lucide-react": "^0.372.0", "lucide-react": "^0.376.0",
"moment": "^2.30.1", "moment": "^2.30.1",
"next": "14.2.2", "next": "14.2.3",
"next-themes": "^0.3.0", "next-themes": "^0.3.0",
"react": "^18", "react": "^18",
"react-dom": "^18", "react-dom": "^18",
@ -31,7 +34,7 @@
"@types/react": "^18", "@types/react": "^18",
"@types/react-dom": "^18", "@types/react-dom": "^18",
"eslint": "^8", "eslint": "^8",
"eslint-config-next": "14.2.2", "eslint-config-next": "14.2.3",
"postcss": "^8", "postcss": "^8",
"tailwindcss": "^3.4.1", "tailwindcss": "^3.4.1",
"typescript": "^5" "typescript": "^5"

651
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

BIN
public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

30
sentry.client.config.ts Normal file
View 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
View 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
View 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',
});

View File

@ -1,88 +1,57 @@
import { cache, ReactElement } from "react"; import React, { ReactElement } from "react";
import { ActionMenu } from "@/app/components/action-menu"; import { ActionMenu } from "@/app/components/action-menu";
import { Metadata } from "next"; import { Metadata } from "next";
import moment from "moment"; import moment from "moment";
import { notFound } from "next/navigation"; import { notFound } from "next/navigation";
import { CodeBlock } from "@/app/components/code-block"; import { CodeBlock } from "@/app/components/code-block";
import { detectLanguage } from "@/app/common/lang-detection/detection"; import { Button } from "@/app/components/ui/button";
import Link from "next/link";
type PasteProps = { import {
params: { generatePasteMetadata,
id: string; getPaste,
}; type Paste,
}; } from "@/app/common/pastes";
import { PastePageProps } from "@/app/types/paste-page";
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>;
export async function generateMetadata({ export async function generateMetadata({
params: { id }, params: { id },
}: PasteProps): Promise<Metadata> { }: PastePageProps): Promise<Metadata> {
const data: Paste | undefined = await getPaste(id); return generatePasteMetadata(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.`,
};
} }
export default async function Paste({ export default async function Paste({
params: { id }, params: { id },
}: PasteProps): Promise<ReactElement> { }: PastePageProps): Promise<ReactElement> {
const data: Paste | undefined = await getPaste(id); const data: Paste | undefined = await getPaste(id);
if (data == undefined) { if (data == undefined) {
return notFound(); return notFound();
} }
const created = moment(data.created)
.format("MMMM Do YYYY, h:mm:ss a")
.toString();
return ( return (
<div className="relative"> <div className="relative h-full">
<div className="absolute top-0 right-0 flex flex-col items-end mx-3 mt-2"> {/* Action Menu */}
<ActionMenu /> <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>{data.language}</p>
<p>{created}</p>
</div> </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} /> <CodeBlock code={data.content} language={data.language} />
</div> </div>
</div> </div>

View File

@ -1,13 +1,15 @@
"use client"; "use client";
import { ReactElement, useState } from "react"; import { ReactElement, useEffect, useState } from "react";
import { ActionMenu } from "@/app/components/action-menu"; import { ActionMenu } from "@/app/components/action-menu";
import { Button } from "@/app/components/ui/button"; import { Button } from "@/app/components/ui/button";
import { useToast } from "@/app/components/ui/use-toast"; import { useToast } from "@/app/components/ui/use-toast";
import { ArrowPathIcon } from "@heroicons/react/16/solid";
export default function Home(): ReactElement { export default function Home(): ReactElement {
const { toast } = useToast(); const { toast } = useToast();
const [value, setValue] = useState(""); const [value, setValue] = useState("");
const [creating, setCreating] = useState(false);
/** /**
* Uploads the paste to the server. * Uploads the paste to the server.
@ -15,52 +17,73 @@ export default function Home(): ReactElement {
async function createPaste() { async function createPaste() {
// Ignore empty pastes, we don't want to save them // Ignore empty pastes, we don't want to save them
if (!value || value.length == 0) { if (!value || value.length == 0) {
return;
}
// Limit the paste size to 400,000 characters
if (value.length > 400_000) {
toast({ toast({
title: "Paste", title: "Paste",
description: "Pastes can't be longer than 400,000 characters", description: "Paste is empty",
}); });
return; return;
} }
setCreating(true);
// Upload the paste to the server // Upload the paste to the server
const response = await fetch( const response = await fetch(
`${process.env.NEXT_PUBLIC_API_ENDPOINT}/upload`, `${process.env.NEXT_PUBLIC_API_ENDPOINT}/upload`,
{ {
method: "POST", method: "POST",
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "text/plain",
}, },
body: value, body: value,
}, },
); );
// Redirect to the new paste
const data = await response.json(); 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}`; window.location.href = `/${data.id}`;
} }
useEffect(() => {
document.getElementById("paste-input")?.focus();
}, []);
return ( return (
<div className="p-3 h-screen w-screen relative"> <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">&gt;</p> <p className="hidden md:block">&gt;</p>
{/* Input */}
<textarea <textarea
onInput={(event) => { onInput={(event) => {
setValue((event.target as HTMLTextAreaElement).value); setValue((event.target as HTMLTextAreaElement).value);
}} }}
id="paste-input"
className="w-full h-full bg-background outline-none resize-none" className="w-full h-full bg-background outline-none resize-none"
placeholder="Paste your code here..."
/> />
</div> </div>
<div className="absolute top-0 right-0 mx-3 mt-2"> {/* Action Menu */}
<ActionMenu> <ActionMenu>
<Button onClick={() => createPaste()}>Save</Button> <Button onClick={() => createPaste()} className="flex gap-1">
</ActionMenu> {creating && (
<div className="animate-spin">
<ArrowPathIcon width={16} height={16} />
</div> </div>
)}
Save
</Button>
</ActionMenu>
</div> </div>
); );
} }

View 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
View 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.`,
};
}

View File

@ -1,6 +1,12 @@
import React from "react"; import React from "react";
import { Button } from "@/app/components/ui/button";
import Link from "next/link"; 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 = { type ActionMenuProps = {
children?: React.ReactNode; children?: React.ReactNode;
@ -8,11 +14,32 @@ type ActionMenuProps = {
export function ActionMenu({ children }: ActionMenuProps) { export function ActionMenu({ children }: ActionMenuProps) {
return ( return (
<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"> <div className="flex items-center bg-secondary rounded-md p-2 gap-2">
{children} {children}
<Link href={"/"}> <Tooltip>
<Button>New</Button> <TooltipTrigger asChild>
<Link href={"https://git.fascinated.cc/Paste"} target="_blank">
<Button>
<InformationCircleIcon width={24} height={24} />
</Button>
</Link> </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> </div>
); );
} }

View File

@ -20,7 +20,7 @@ export function CodeBlock({ code, language }: CodeBlockProps): ReactElement {
<SyntaxHighlighter <SyntaxHighlighter
className="!bg-transparent text-xs" className="!bg-transparent text-xs"
style={atomOneDark} style={atomOneDark}
language={language} language={language == "text" ? "plaintext" : language}
showLineNumbers showLineNumbers
codeTagProps={{ codeTagProps={{
style: { style: {

View 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
View 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>
);
}

View File

@ -4,6 +4,8 @@ import { ThemeProvider } from "@/app/components/theme-provider";
import { ReactNode } from "react"; import { ReactNode } from "react";
import { jetbrainsMono } from "@/app/common/font/font"; import { jetbrainsMono } from "@/app/common/font/font";
import { Toaster } from "@/app/components/ui/toaster"; import { Toaster } from "@/app/components/ui/toaster";
import { cn } from "@/app/common/utils";
import { TooltipProvider } from "@/app/components/ui/tooltip";
export const metadata: Metadata = { export const metadata: Metadata = {
title: "Paste", title: "Paste",
@ -17,7 +19,8 @@ export default function RootLayout({
}>) { }>) {
return ( return (
<html lang="en"> <html lang="en">
<body className={jetbrainsMono.className}> <body className={cn(jetbrainsMono.className, "w-screen h-screen")}>
<TooltipProvider>
<Toaster /> <Toaster />
<ThemeProvider <ThemeProvider
attribute="class" attribute="class"
@ -27,6 +30,7 @@ export default function RootLayout({
> >
{children} {children}
</ThemeProvider> </ThemeProvider>
</TooltipProvider>
</body> </body>
</html> </html>
); );

View File

@ -0,0 +1,5 @@
export type PastePageProps = {
params: {
id: string;
};
};