diff --git a/app/(domain)/[domain]/blog/[slug]/opengraph-image.tsx b/app/(domain)/[domain]/blog/[slug]/opengraph-image.tsx index 42ab23c..d4efe8b 100644 --- a/app/(domain)/[domain]/blog/[slug]/opengraph-image.tsx +++ b/app/(domain)/[domain]/blog/[slug]/opengraph-image.tsx @@ -1,31 +1,30 @@ /* eslint-disable @next/next/no-img-element */ -import prisma from "@/lib/edgedb"; -import { truncate } from "@/lib/utils"; -import { ImageResponse } from "next/og"; +import prisma from '@/lib/edgedb'; +import { truncate } from '@/lib/utils'; +import { ImageResponse } from 'next/og'; - -export const runtime = "edge"; +export const runtime = 'edge'; type PostOGResponse = { - title: string; - description: string; - image: string; - authorName: string; - authorImage: string; -} + title: string; + description: string; + image: string; + authorName: string; + authorImage: string; +}; export default async function PostOG({ - params, + params, }: { - params: { domain: string; slug: string }; + params: { domain: string; slug: string }; }) { - const domain = decodeURIComponent(params.domain); - const slug = decodeURIComponent(params.slug); + const domain = decodeURIComponent(params.domain); + const slug = decodeURIComponent(params.slug); - const subdomain = domain.endsWith(`.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`) - ? domain.replace(`.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`, "") - : null; + const subdomain = domain.endsWith(`.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`) + ? domain.replace(`.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`, '') + : null; - const response = await prisma.$queryRaw` + const response = await prisma.$queryRaw` SELECT blog.title, blog.description, blog.image, "user".firstname as "authorName", "user".avatar as "authorImage" FROM "blog" AS blog @@ -38,58 +37,55 @@ export default async function PostOG({ ) AND blog.slug = ${slug} LIMIT 1; - ` - ; - + `; + console.log('response ====>', response); - console.log("response ====>", response) + const data = (response as PostOGResponse[])[0]; - const data = (response as PostOGResponse[])[0]; + if (!data) { + return new Response('Not found', { status: 404 }); + } - if (!data) { - return new Response("Not found", { status: 404 }); - } - - const clashData = await fetch( - new URL("@/styles/CalSans-SemiBold.otf", import.meta.url), - ).then((res) => res.arrayBuffer()); + const clashData = await fetch( + new URL('@/styles/CalSans-SemiBold.otf', import.meta.url) + ).then((res) => res.arrayBuffer()); - return new ImageResponse( - ( -
-
-

- {data.title} -

-

- {truncate(data.description, 120)} -

-
- {data.authorName} -

by {data.authorName}

-
- {data.title} -
-
- ), + return new ImageResponse( + ( +
+
+

+ {data.title} +

+

+ {truncate(data.description, 120)} +

+
+ {data.authorName} +

by {data.authorName}

+
+ {data.title} +
+
+ ), + { + width: 1200, + height: 600, + fonts: [ { - width: 1200, - height: 600, - fonts: [ - { - name: "Clash", - data: clashData, - }, - ], - emoji: "blobmoji", + name: 'Clash', + data: clashData, }, - ); + ], + emoji: 'blobmoji', + } + ); } diff --git a/app/(domain)/[domain]/blog/[slug]/page.tsx b/app/(domain)/[domain]/blog/[slug]/page.tsx index 78a9019..f5955fa 100644 --- a/app/(domain)/[domain]/blog/[slug]/page.tsx +++ b/app/(domain)/[domain]/blog/[slug]/page.tsx @@ -1,176 +1,186 @@ -import BlurImage from "@/components/blur-image"; -import BlogCard from "@/components/domain/blog-card"; -import MDX from "@/components/mdx"; -import { TracingBeam } from "@/components/ui/tracing-beam"; -import { TrackAnalytics } from "@/lib/analytics"; -import prisma from "@/lib/db"; -import { getBlogData, getSiteData } from "@/lib/fetchers"; -import { placeholderBlurhash, toDateString } from "@/lib/utils"; -import Link from "next/link"; -import { notFound } from "next/navigation"; +import BlurImage from '@/components/blur-image'; +import BlogCard from '@/components/domain/blog-card'; +import MDX from '@/components/mdx'; +import { TracingBeam } from '@/components/ui/tracing-beam'; +import { TrackAnalytics } from '@/lib/analytics'; +import prisma from '@/lib/db'; +import { getBlogData, getSiteData } from '@/lib/fetchers'; +import { placeholderBlurhash, toDateString } from '@/lib/utils'; +import Link from 'next/link'; +import { notFound } from 'next/navigation'; import readingTime from 'reading-time'; -export const dynamic = 'force-dynamic' +export const dynamic = 'force-dynamic'; +export async function generateMetadata({ + params, +}: { + params: { domain: string; slug: string }; +}) { + const domain = decodeURIComponent(params.domain); + const slug = decodeURIComponent(params.slug); -export async function generateMetadata({ params }: { params: { domain: string; slug: string } }) { - const domain = decodeURIComponent(params.domain); - const slug = decodeURIComponent(params.slug); + const [data, siteData] = await Promise.all([ + getBlogData(domain, slug), + getSiteData(domain), + ]); + if (!data || !siteData) { + return null; + } + const { title, description } = data; - const [data, siteData] = await Promise.all([ - getBlogData(domain, slug), - getSiteData(domain), - ]); - if (!data || !siteData) { - return null; - } - const { title, description } = data; - - return { - title, - description, - openGraph: { - title, - description, - }, - twitter: { - card: "summary_large_image", - title, - description, - creator: "@" + siteData?.twitterid || "abhishektwts", - }, - }; + return { + title, + description, + openGraph: { + title, + description, + }, + twitter: { + card: 'summary_large_image', + title, + description, + creator: '@' + siteData?.twitterid || 'abhishektwts', + }, + }; } export async function generateStaticParams() { - const allPosts = await prisma.blog.findMany({ + const allPosts = await prisma.blog.findMany({ + select: { + slug: true, + site: { select: { - slug: true, - site: { - select: { - subdomain: true, - customDomain: true, - }, - }, + subdomain: true, + customDomain: true, }, - // where: { - // slug: "none" - // } - }); + }, + }, + // where: { + // slug: "none" + // } + }); - const allPaths = allPosts - .flatMap(({ site, slug }) => [ - site?.subdomain && { - domain: `${site.subdomain}.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`, - slug, - }, - site?.customDomain && { - domain: site.customDomain, - slug, - }, - ]) - .filter(Boolean); + const allPaths = allPosts + .flatMap(({ site, slug }) => [ + site?.subdomain && { + domain: `${site.subdomain}.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`, + slug, + }, + site?.customDomain && { + domain: site.customDomain, + slug, + }, + ]) + .filter(Boolean); - return allPaths; + return allPaths; } -export default async function SitePostPage({ params }: { params: { domain: string; slug: string } }) { - const domain = decodeURIComponent(params.domain); - const slug = decodeURIComponent(params.slug); - const data = await getBlogData(domain, slug); - const sitedata = await getSiteData(domain) +export default async function SitePostPage({ + params, +}: { + params: { domain: string; slug: string }; +}) { + const domain = decodeURIComponent(params.domain); + const slug = decodeURIComponent(params.slug); + const data = await getBlogData(domain, slug); + const sitedata = await getSiteData(domain); - if (!data || !sitedata) { - notFound(); - } + if (!data || !sitedata) { + notFound(); + } - const readingstats = readingTime(data.content || ""); + const readingstats = readingTime(data.content || ''); + try { + TrackAnalytics('blog', { + path: `➡️${data.title}`, + blogId: data?.id || '', + }); + } catch (error) { + console.log(error); + } - try { - TrackAnalytics("blog", { - path: `➡️${data.title}`, - blogId: data?.id || "", - }); - } catch (error) { - console.log(error); - } - - return ( - <> -
-
- -
-
-

- {data.title} -

-

- {toDateString(data.createdAt)} | {readingstats.text} -

-

- {data.description} -

-
- -
- -
- {data.site?.name} -
-
- -
-
- - - + return ( + <> +
+
+ +
+
+

+ {data.title} +

+

+ {toDateString(data.createdAt)} | {readingstats.text} +

+

+ {data.description} +

+
+ +
+ +
+ {data.site?.name}
- {data.adjacentPosts.length > 0 && ( -
- - )} - {data.adjacentPosts && ( -
- {data.adjacentPosts.map((data: any, index: number) => ( - - ))} -
- )} - - ); +
+ +
+
+ + + +
+ {data.adjacentPosts.length > 0 && ( +
+ + )} + {data.adjacentPosts && ( +
+ {data.adjacentPosts.map((data: any, index: number) => ( + + ))} +
+ )} + + ); } diff --git a/app/(domain)/[domain]/blog/layout.tsx b/app/(domain)/[domain]/blog/layout.tsx index f40e3e1..f7042f2 100644 --- a/app/(domain)/[domain]/blog/layout.tsx +++ b/app/(domain)/[domain]/blog/layout.tsx @@ -1,104 +1,103 @@ - -import { getSiteData } from "@/lib/fetchers"; -import { fontMapper } from "@/styles/fonts"; -import { Metadata } from "next"; -import Image from "next/image"; -import Link from "next/link"; -import { notFound, redirect } from "next/navigation"; -import { ReactNode } from "react"; +import { getSiteData } from '@/lib/fetchers'; +import { fontMapper } from '@/styles/fonts'; +import { Metadata } from 'next'; +import Image from 'next/image'; +import Link from 'next/link'; +import { notFound, redirect } from 'next/navigation'; +import { ReactNode } from 'react'; export async function generateMetadata({ - params, + params, }: { - params: { domain: string }; + params: { domain: string }; }): Promise { - const domain = decodeURIComponent(params.domain); - const data = await getSiteData(domain); - if (!data) { - return null; - } - const { - name: title, - description, - image, - logo, - } = data as { - name: string; - description: string; - image: string; - logo: string; - }; + const domain = decodeURIComponent(params.domain); + const data = await getSiteData(domain); + if (!data) { + return null; + } + const { + name: title, + description, + image, + logo, + } = data as { + name: string; + description: string; + image: string; + logo: string; + }; - return { - title, - description, - openGraph: { - title, - description, - images: [image], - }, - twitter: { - card: "summary_large_image", - title, - description, - images: [image], - creator: "@vercel", - }, - icons: [logo], - metadataBase: new URL(`https://${domain}`), - // Optional: Set canonical URL to custom domain if it exists - // ...(params.domain.endsWith(`.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`) && - // data.customDomain && { - // alternates: { - // canonical: `https://${data.customDomain}`, - // }, - // }), - }; + return { + title, + description, + openGraph: { + title, + description, + images: [image], + }, + twitter: { + card: 'summary_large_image', + title, + description, + images: [image], + creator: '@vercel', + }, + icons: [logo], + metadataBase: new URL(`https://${domain}`), + // Optional: Set canonical URL to custom domain if it exists + // ...(params.domain.endsWith(`.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`) && + // data.customDomain && { + // alternates: { + // canonical: `https://${data.customDomain}`, + // }, + // }), + }; } export default async function SiteLayout({ - params, - children, + params, + children, }: { - params: { domain: string }; - children: ReactNode; + params: { domain: string }; + children: ReactNode; }) { - const domain = decodeURIComponent(params.domain); - const data = await getSiteData(domain); + const domain = decodeURIComponent(params.domain); + const data = await getSiteData(domain); - if (!data) { - notFound(); - } + if (!data) { + notFound(); + } - // Optional: Redirect to custom domain if it exists - if ( - domain.endsWith(`.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`) && - data.customDomain && - process.env.REDIRECT_TO_CUSTOM_DOMAIN_IF_EXISTS === "true" - ) { - return redirect(`https://${data.customDomain}`); - } + // Optional: Redirect to custom domain if it exists + if ( + domain.endsWith(`.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`) && + data.customDomain && + process.env.REDIRECT_TO_CUSTOM_DOMAIN_IF_EXISTS === 'true' + ) { + return redirect(`https://${data.customDomain}`); + } - return ( -
-
-
- -
- {data.name -
- - {data.name} - - -
+ return ( +
+
+
+ +
+ {data.name
-
{children}
+ + {data.name} + +
- ); +
+
{children}
+
+ ); } diff --git a/app/(domain)/[domain]/blog/page.tsx b/app/(domain)/[domain]/blog/page.tsx index 3c49e86..d06623f 100644 --- a/app/(domain)/[domain]/blog/page.tsx +++ b/app/(domain)/[domain]/blog/page.tsx @@ -1,140 +1,139 @@ - -import BlurImage from "@/components/blur-image"; -import BlogCard from "@/components/domain/blog-card"; -import prisma from "@/lib/db"; -import { getBlogsForSite, getSiteData } from "@/lib/fetchers"; -import { placeholderBlurhash, toDateString } from "@/lib/utils"; -import Image from "next/image"; -import Link from "next/link"; -import { notFound } from "next/navigation"; +import BlurImage from '@/components/blur-image'; +import BlogCard from '@/components/domain/blog-card'; +import prisma from '@/lib/db'; +import { getBlogsForSite, getSiteData } from '@/lib/fetchers'; +import { placeholderBlurhash, toDateString } from '@/lib/utils'; +import Image from 'next/image'; +import Link from 'next/link'; +import { notFound } from 'next/navigation'; export async function generateStaticParams() { - const allSites = await prisma.site.findMany({ - select: { - subdomain: true, - customDomain: true, - }, - // feel free to remove this filter if you want to generate paths for all sites - // where: { - // subdomain: "demo", - // }, - }); + const allSites = await prisma.site.findMany({ + select: { + subdomain: true, + customDomain: true, + }, + // feel free to remove this filter if you want to generate paths for all sites + // where: { + // subdomain: "demo", + // }, + }); - const allPaths = allSites - .flatMap(({ subdomain, customDomain }) => [ - subdomain && { - domain: `${subdomain}.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`, - }, - customDomain && { - domain: customDomain, - }, - ]) - .filter(Boolean); + const allPaths = allSites + .flatMap(({ subdomain, customDomain }) => [ + subdomain && { + domain: `${subdomain}.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`, + }, + customDomain && { + domain: customDomain, + }, + ]) + .filter(Boolean); - return allPaths; + return allPaths; } export default async function SiteHomePage({ - params, + params, }: { - params: { domain: string }; + params: { domain: string }; }) { - const domain = decodeURIComponent(params.domain); - const [data, posts] = await Promise.all([ - getSiteData(domain), - getBlogsForSite(domain), - ]); - - if (!data) { - notFound(); - } + const domain = decodeURIComponent(params.domain); + const [data, posts] = await Promise.all([ + getSiteData(domain), + getBlogsForSite(domain), + ]); - return ( - <> -
- {posts.length > 0 ? ( -
- -
- -
-
-

- {posts[0].title} -

-

- {posts[0].description} -

-
-
- {data.user?.avatar ? ( - - ) : ( -
- ? -
- )} -
-

- {data.user?.firstname} {" "} {data.user?.lastname} -

-
-

- {toDateString(posts[0].createdAt)} -

-
-
- -
- ) : ( -
- missing post - missing post -

- No posts yet. -

-
- )} -
+ if (!data) { + notFound(); + } - {posts.length > 1 && ( -
-

- More stories -

-
- {posts.slice(1).map((metadata: any, index: number) => ( - - ))} -
+ return ( + <> +
+ {posts.length > 0 ? ( +
+ +
+ +
+
+

+ {posts[0].title} +

+

+ {posts[0].description} +

+
+
+ {data.user?.avatar ? ( + + ) : ( +
+ ? +
+ )} +
+

+ {data.user?.firstname} {data.user?.lastname} +

+
+

+ {toDateString(posts[0].createdAt)} +

- )} - - ); +
+ +
+ ) : ( +
+ missing post + missing post +

+ No posts yet. +

+
+ )} +
+ + {posts.length > 1 && ( +
+

+ More stories +

+
+ {posts.slice(1).map((metadata: any, index: number) => ( + + ))} +
+
+ )} + + ); } diff --git a/app/(domain)/[domain]/layout.tsx b/app/(domain)/[domain]/layout.tsx index 4119ee2..b9beb06 100644 --- a/app/(domain)/[domain]/layout.tsx +++ b/app/(domain)/[domain]/layout.tsx @@ -1,88 +1,89 @@ -import { ReactNode } from "react"; +import { ReactNode } from 'react'; // import CTA from "@/components/cta"; // import ReportAbuse from "@/components/report-abuse"; -import { getSiteData } from "@/lib/fetchers"; -import { fontMapper } from "@/styles/fonts"; -import { Metadata } from "next"; -import { notFound, redirect } from "next/navigation"; -export const dynamic = 'force-dynamic' +import { getSiteData } from '@/lib/fetchers'; +import { fontMapper } from '@/styles/fonts'; +import { Metadata } from 'next'; +import { notFound, redirect } from 'next/navigation'; +export const dynamic = 'force-dynamic'; export async function generateMetadata({ - params, + params, }: { - params: { domain: string }; + params: { domain: string }; }): Promise { - const domain = decodeURIComponent(params.domain); - const data = await getSiteData(domain); - if (!data) { - return null; - } - const { - name: title, - description, - image, - logo, - } = data as { - name: string; - description: string; - image: string; - logo: string; - }; - // Todo: To make sure that when user create thier site the user profile logo is used .... - return { - title, - description, - openGraph: { - title, - description, - images: [image], + const domain = decodeURIComponent(params.domain); + const data = await getSiteData(domain); + if (!data) { + return null; + } + const { + name: title, + description, + image, + logo, + } = data as { + name: string; + description: string; + image: string; + logo: string; + }; + // Todo: To make sure that when user create thier site the user profile logo is used .... + return { + title, + description, + openGraph: { + title, + description, + images: [image], + }, + twitter: { + card: 'summary_large_image', + title, + description, + images: [image], + creator: data.twitterid || '@abhishekkushwaha', + }, + icons: [logo], + metadataBase: new URL(`https://${domain}`), + // Optional: Set canonical URL to custom domain if it exists + ...(params.domain.endsWith(`.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`) && + data.customDomain && { + alternates: { + canonical: `https://${data.customDomain}`, }, - twitter: { - card: "summary_large_image", - title, - description, - images: [image], - creator: data.twitterid || "@abhishekkushwaha", - }, - icons: [logo], - metadataBase: new URL(`https://${domain}`), - // Optional: Set canonical URL to custom domain if it exists - ...(params.domain.endsWith(`.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`) && - data.customDomain && { - alternates: { - canonical: `https://${data.customDomain}`, - }, - }), - }; + }), + }; } export default async function HostedPortfolioLayout({ - params, - children, + params, + children, }: { - params: { domain: string }; - children: ReactNode; + params: { domain: string }; + children: ReactNode; }) { - const domain = decodeURIComponent(params.domain); - const [data] = await Promise.all([ - getSiteData(domain), - ]); - if (!data) { - notFound(); - } + const domain = decodeURIComponent(params.domain); + const [data] = await Promise.all([getSiteData(domain)]); + if (!data) { + notFound(); + } - // Optional: Redirect to custom domain if it exists - if ( - domain.endsWith(`.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`) && - data.customDomain && - process.env.REDIRECT_TO_CUSTOM_DOMAIN_IF_EXISTS === "true" - ) { - return redirect(`https://${data.customDomain}`); - } + // Optional: Redirect to custom domain if it exists + if ( + domain.endsWith(`.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`) && + data.customDomain && + process.env.REDIRECT_TO_CUSTOM_DOMAIN_IF_EXISTS === 'true' + ) { + return redirect(`https://${data.customDomain}`); + } - return ( -
- {children} -
- ); + return ( +
+ {children} +
+ ); } diff --git a/app/(domain)/[domain]/page.tsx b/app/(domain)/[domain]/page.tsx index 20149d0..c0e12f1 100644 --- a/app/(domain)/[domain]/page.tsx +++ b/app/(domain)/[domain]/page.tsx @@ -1,54 +1,53 @@ - -import DefaultTheme from "@/components/themes/DefaultTheme"; -import prisma from "@/lib/db"; -import { getSiteAbout, getSiteData } from "@/lib/fetchers"; -import { notFound } from "next/navigation"; -export const dynamic = 'force-dynamic' +import DefaultTheme from '@/components/themes/DefaultTheme'; +import prisma from '@/lib/db'; +import { getSiteAbout, getSiteData } from '@/lib/fetchers'; +import { notFound } from 'next/navigation'; +export const dynamic = 'force-dynamic'; export async function generateStaticParams() { - const allSites = await prisma.site.findMany({ - select: { - subdomain: true, - customDomain: true, - }, - // feel free to remove this filter if you want to generate paths for all sites - // where: { - // subdomain: "demo", - // }, - }); + const allSites = await prisma.site.findMany({ + select: { + subdomain: true, + customDomain: true, + }, + // feel free to remove this filter if you want to generate paths for all sites + // where: { + // subdomain: "demo", + // }, + }); - const allPaths = allSites - .flatMap(({ subdomain, customDomain }) => [ - subdomain && { - domain: `${subdomain}.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`, - }, - customDomain && { - domain: customDomain, - }, - ]) - .filter(Boolean); + const allPaths = allSites + .flatMap(({ subdomain, customDomain }) => [ + subdomain && { + domain: `${subdomain}.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`, + }, + customDomain && { + domain: customDomain, + }, + ]) + .filter(Boolean); - return allPaths; + return allPaths; } export default async function SiteHomePage({ - params, + params, }: { - params: { domain: string }; + params: { domain: string }; }) { - const domain = decodeURIComponent(params.domain); - const [data, aboutdata] = await Promise.all([ - getSiteData(domain), - getSiteAbout(domain) - ]); + const domain = decodeURIComponent(params.domain); + const [data, aboutdata] = await Promise.all([ + getSiteData(domain), + getSiteAbout(domain), + ]); - if (!data) { - notFound(); - } - return ( - <> - {/* {data.theme} */} - - - ); + if (!data) { + notFound(); + } + return ( + <> + {/* {data.theme} */} + + + ); } diff --git a/app/ClerkProvider.tsx b/app/ClerkProvider.tsx index 6347c00..67cd79c 100644 --- a/app/ClerkProvider.tsx +++ b/app/ClerkProvider.tsx @@ -1,13 +1,9 @@ -import { ClerkProvider } from '@clerk/nextjs' +import { ClerkProvider } from '@clerk/nextjs'; export default function RootLayout({ - children, + children, }: { - children: React.ReactNode + children: React.ReactNode; }) { - return ( - - {children} - - ) -} \ No newline at end of file + return {children}; +} diff --git a/app/NextUIProvider.tsx b/app/NextUIProvider.tsx index 418b8ba..a01e771 100644 --- a/app/NextUIProvider.tsx +++ b/app/NextUIProvider.tsx @@ -1,36 +1,36 @@ // app/providers.tsx -'use client' +'use client'; import { ClerkProvider } from '@clerk/nextjs'; import { dark } from '@clerk/themes'; import { NextUIProvider } from '@nextui-org/react'; import { useRouter } from 'next/navigation'; import NextNProgress from 'nextjs-progressbar'; -import { Toaster } from "sonner"; +import { Toaster } from 'sonner'; import { ThemeProvider } from './ThemeProvider'; export function Providers({ children }: { children: React.ReactNode }) { - const router = useRouter(); - return ( - - - - - - - {children} - - - - ) -} \ No newline at end of file + const router = useRouter(); + return ( + + + + + + + {children} + + + + ); +} diff --git a/app/ThemeProvider.tsx b/app/ThemeProvider.tsx index 4b40449..1f84abd 100644 --- a/app/ThemeProvider.tsx +++ b/app/ThemeProvider.tsx @@ -1,10 +1,8 @@ -"use client"; +'use client'; -import { ThemeProvider as NextThemesProvider } from "next-themes"; -import { type ThemeProviderProps } from "next-themes/dist/types"; +import { ThemeProvider as NextThemesProvider } from 'next-themes'; +import { type ThemeProviderProps } from 'next-themes/dist/types'; export function ThemeProvider({ children, ...props }: ThemeProviderProps) { - return - {children} - + return {children}; } diff --git a/app/api/domain/[slug]/verify/route.ts b/app/api/domain/[slug]/verify/route.ts index 681b8cc..ef70a45 100644 --- a/app/api/domain/[slug]/verify/route.ts +++ b/app/api/domain/[slug]/verify/route.ts @@ -1,48 +1,48 @@ import { - getConfigResponse, - getDomainResponse, - verifyDomain, -} from "@/lib/domains"; -import { DomainVerificationStatusProps } from "@/lib/types"; -import { NextResponse } from "next/server"; + getConfigResponse, + getDomainResponse, + verifyDomain, +} from '@/lib/domains'; +import { DomainVerificationStatusProps } from '@/lib/types'; +import { NextResponse } from 'next/server'; export async function GET( - _req: Request, - { params }: { params: { slug: string } }, + _req: Request, + { params }: { params: { slug: string } } ) { - const domain = decodeURIComponent(params.slug); - let status: DomainVerificationStatusProps = "Valid Configuration"; + const domain = decodeURIComponent(params.slug); + let status: DomainVerificationStatusProps = 'Valid Configuration'; - const [domainJson, configJson] = await Promise.all([ - getDomainResponse(domain), - getConfigResponse(domain), - ]); + const [domainJson, configJson] = await Promise.all([ + getDomainResponse(domain), + getConfigResponse(domain), + ]); - if (domainJson?.error?.code === "not_found") { - // domain not found on Vercel project - status = "Domain Not Found"; + if (domainJson?.error?.code === 'not_found') { + // domain not found on Vercel project + status = 'Domain Not Found'; - // unknown error - } else if (domainJson.error) { - status = "Unknown Error"; + // unknown error + } else if (domainJson.error) { + status = 'Unknown Error'; - // if domain is not verified, we try to verify now - } else if (!domainJson.verified) { - status = "Pending Verification"; - const verificationJson = await verifyDomain(domain); + // if domain is not verified, we try to verify now + } else if (!domainJson.verified) { + status = 'Pending Verification'; + const verificationJson = await verifyDomain(domain); - // domain was just verified - if (verificationJson && verificationJson.verified) { - status = "Valid Configuration"; - } - } else if (configJson.misconfigured) { - status = "Invalid Configuration"; - } else { - status = "Valid Configuration"; + // domain was just verified + if (verificationJson?.verified) { + status = 'Valid Configuration'; } + } else if (configJson.misconfigured) { + status = 'Invalid Configuration'; + } else { + status = 'Valid Configuration'; + } - return NextResponse.json({ - status, - domainJson, - }); + return NextResponse.json({ + status, + domainJson, + }); } diff --git a/app/api/feedback/route.ts b/app/api/feedback/route.ts index 178b61f..ad5cd14 100644 --- a/app/api/feedback/route.ts +++ b/app/api/feedback/route.ts @@ -1,28 +1,25 @@ -import prisma from "@/lib/db"; -import { auth } from "@clerk/nextjs"; +import prisma from '@/lib/db'; +import { auth } from '@clerk/nextjs'; -export const dynamic = 'force-dynamic' +export const dynamic = 'force-dynamic'; async function handler(request: Request) { - if (request.method === "POST") { - - const userID = await auth() - const { feedback } = await request.json(); - const postfeedback = await prisma.feedback.create({ - data: { - feedback: feedback, - feedback_type: "other" as string, - user_id: userID.userId!, - }, - }); - return Response.json({ ok: "ok" }); - } else { - return Response.json({ - error: "Method not allowed", - }) - } + if (request.method === 'POST') { + const userID = await auth(); + const { feedback } = await request.json(); + const postfeedback = await prisma.feedback.create({ + data: { + feedback: feedback, + feedback_type: 'other' as string, + user_id: userID.userId!, + }, + }); + return Response.json({ ok: 'ok' }); + } else { + return Response.json({ + error: 'Method not allowed', + }); + } } - - export const GET = handler; export const POST = handler; diff --git a/app/api/generate/route.ts b/app/api/generate/route.ts index e4186e3..a9e7591 100644 --- a/app/api/generate/route.ts +++ b/app/api/generate/route.ts @@ -1,84 +1,82 @@ -import { Ratelimit } from "@upstash/ratelimit"; +import { Ratelimit } from '@upstash/ratelimit'; import { Redis } from '@upstash/redis'; -import { OpenAIStream, StreamingTextResponse } from "ai"; -import { Configuration, OpenAIApi } from "openai-edge"; - +import { OpenAIStream, StreamingTextResponse } from 'ai'; +import { Configuration, OpenAIApi } from 'openai-edge'; const redis = new Redis({ - url: process.env.UPSTASH_REDIS_REST_URL!, - token: process.env.UPSTASH_REDIS_REST_TOKEN!, -}) - + url: process.env.UPSTASH_REDIS_REST_URL!, + token: process.env.UPSTASH_REDIS_REST_TOKEN!, +}); const config = new Configuration({ - apiKey: process.env.OPENAI_API_KEY, + apiKey: process.env.OPENAI_API_KEY, }); const openai = new OpenAIApi(config); -export const runtime = "edge"; +export const runtime = 'edge'; export async function POST(req: Request): Promise { - if ( - process.env.NODE_ENV != "development" && - process.env.KV_REST_API_URL && - process.env.KV_REST_API_TOKEN - ) { - const ip = req.headers.get("x-forwarded-for"); - const ratelimit = new Ratelimit({ - redis: redis, - limiter: Ratelimit.slidingWindow(50, "1 d"), - }); + if ( + process.env.NODE_ENV != 'development' && + process.env.KV_REST_API_URL && + process.env.KV_REST_API_TOKEN + ) { + const ip = req.headers.get('x-forwarded-for'); + const ratelimit = new Ratelimit({ + redis: redis, + limiter: Ratelimit.slidingWindow(50, '1 d'), + }); - const { success, limit, reset, remaining } = await ratelimit.limit( - `platforms_ratelimit_${ip}`, - ); + const { success, limit, reset, remaining } = await ratelimit.limit( + `platforms_ratelimit_${ip}` + ); - if (!success) { - return new Response("You have reached your request limit for the day.", { - status: 429, - headers: { - "X-RateLimit-Limit": limit.toString(), - "X-RateLimit-Remaining": remaining.toString(), - "X-RateLimit-Reset": reset.toString(), - }, - }); - } + if (!success) { + return new Response('You have reached your request limit for the day.', { + status: 429, + headers: { + 'X-RateLimit-Limit': limit.toString(), + 'X-RateLimit-Remaining': remaining.toString(), + 'X-RateLimit-Reset': reset.toString(), + }, + }); } + } - let { prompt: content } = await req.json(); + let { prompt: content } = await req.json(); - // remove trailing slash, - // slice the content from the end to prioritize later characters - content = content.replace(/\/$/, "").slice(-5000); + // remove trailing slash, + // slice the content from the end to prioritize later characters + content = content.replace(/\/$/, '').slice(-5000); - const response = await openai.createChatCompletion({ - model: "gpt-3.5-turbo", - messages: [ - { - role: "system", - content: - "You are an AI writing assistant that continues existing text based on context from prior text. " + - "Give more weight/priority to the later characters than the beginning ones. " + - "Limit your response to no more than 200 characters, but make sure to construct complete sentences.", - // we're disabling markdown for now until we can figure out a way to stream markdown text with proper formatting: https://github.com/steven-tey/novel/discussions/7 - // "Use Markdown formatting when appropriate.", - }, - { - role: "user", - content, - }, - ], - temperature: 0.7, - top_p: 1, - frequency_penalty: 0, - presence_penalty: 0, - stream: true, - n: 1, - }); + const response = await openai.createChatCompletion({ + model: 'gpt-3.5-turbo', + messages: [ + { + role: 'system', + content: + 'You are an AI writing assistant that continues existing text based on context from prior text. ' + + 'Give more weight/priority to the later characters than the beginning ones. ' + + 'Limit your response to no more than 200 characters, but make sure to construct complete sentences.', + // we're disabling markdown for now until we can figure out a way to stream markdown text with proper formatting: https://github.com/steven-tey/novel/discussions/7 + // "Use Markdown formatting when appropriate.", + }, + { + role: 'user', + content, + }, + ], + temperature: 0.7, + top_p: 1, + frequency_penalty: 0, + presence_penalty: 0, + stream: true, + n: 1, + }); - // Convert the response into a friendly text-stream - const stream = OpenAIStream(response); + // Convert the response into a friendly text-stream + const stream = OpenAIStream(response); - // Respond with the stream - return new StreamingTextResponse(stream); + // Respond with the stream + return new StreamingTextResponse(stream); } diff --git a/app/api/ping/route.ts b/app/api/ping/route.ts index 09018d1..ca0c381 100644 --- a/app/api/ping/route.ts +++ b/app/api/ping/route.ts @@ -1,9 +1,9 @@ -import { NextResponse } from "next/server"; +import { NextResponse } from 'next/server'; export async function GET(request: Request) { - return NextResponse.json({ - "message": 'pong! welcome to dresume.me', - "status": 200, - "data": null, - }) + return NextResponse.json({ + message: 'pong! welcome to dresume.me', + status: 200, + data: null, + }); } diff --git a/app/api/portfolio/route.ts b/app/api/portfolio/route.ts index 3194146..9a80107 100644 --- a/app/api/portfolio/route.ts +++ b/app/api/portfolio/route.ts @@ -1,31 +1,31 @@ - -import prisma from "@/lib/db"; +import prisma from '@/lib/db'; import { NextResponse } from 'next/server'; async function handler(request: Request) { - const payload = await request.json(); - - try { - const sites = await prisma.site.findMany({ - where: { - user: { - id: payload.userId as string, - }, - }, - orderBy: { - createdAt: "asc", - } - }); + const payload = await request.json(); - return NextResponse.json({ - sites: sites, - status: "success" - }, { status: 200 }); - } catch (error: any) { - return NextResponse.json({ error: error }, { status: 500 }); - } + try { + const sites = await prisma.site.findMany({ + where: { + user: { + id: payload.userId as string, + }, + }, + orderBy: { + createdAt: 'asc', + }, + }); + return NextResponse.json( + { + sites: sites, + status: 'success', + }, + { status: 200 } + ); + } catch (error: any) { + return NextResponse.json({ error: error }, { status: 500 }); + } } - -export const POST = handler; \ No newline at end of file +export const POST = handler; diff --git a/app/api/resume/route.ts b/app/api/resume/route.ts index af26ce9..57ab15b 100644 --- a/app/api/resume/route.ts +++ b/app/api/resume/route.ts @@ -1,32 +1,31 @@ -import prisma from "@/lib/db"; -import { auth } from "@clerk/nextjs"; +import prisma from '@/lib/db'; +import { auth } from '@clerk/nextjs'; export const dynamic = 'force-dynamic'; async function handler(request: Request) { - if (request.method === "POST") { - try { - const userID = auth(); - if (!userID) return Response.json({ status: "Not Authorised" }); - const { ...data } = await request.json(); - await prisma.resume.create({ - data: { - ...data, - user_id: userID.userId!, - }, - }); - return Response.json({ status: "ok! resume created created" }); - } - catch (err) { - console.error({ error: err }) - return Response.json({ error: err }); - } - } else { - return Response.json({ - error: "Method not allowed", - }) + if (request.method === 'POST') { + try { + const userID = auth(); + if (!userID) return Response.json({ status: 'Not Authorised' }); + const { ...data } = await request.json(); + await prisma.resume.create({ + data: { + ...data, + user_id: userID.userId!, + }, + }); + return Response.json({ status: 'ok! resume created created' }); + } catch (err) { + console.error({ error: err }); + return Response.json({ error: err }); } + } else { + return Response.json({ + error: 'Method not allowed', + }); + } } export const GET = handler; -export const POST = handler; \ No newline at end of file +export const POST = handler; diff --git a/app/api/track/route.ts b/app/api/track/route.ts index 5950a66..fe49224 100644 --- a/app/api/track/route.ts +++ b/app/api/track/route.ts @@ -1,107 +1,104 @@ -import prisma from "@/lib/db"; -import { NextRequest } from "next/server"; +import prisma from '@/lib/db'; +import { NextRequest } from 'next/server'; import UAParser from 'ua-parser-js'; async function handler(request: NextRequest) { - const userAgent = request.headers.get('user-agent') ?? ''; - const uaParser = new UAParser(); - uaParser.setUA(userAgent); - const os = uaParser.getOS().name; - const v = uaParser.getEngine().name; - const browser = uaParser.getBrowser().name; - const ip = request.ip || request.headers.get('X-Forwarded-For'); - const ipinfo = await fetch(`https://ipinfo.io/${ip}/json`).then((res) => res.json()); + const userAgent = request.headers.get('user-agent') ?? ''; + const uaParser = new UAParser(); + uaParser.setUA(userAgent); + const os = uaParser.getOS().name; + const v = uaParser.getEngine().name; + const browser = uaParser.getBrowser().name; + const ip = request.ip || request.headers.get('X-Forwarded-For'); + const ipinfo = await fetch(`https://ipinfo.io/${ip}/json`).then((res) => + res.json() + ); - if (request.method === "GET") { - try { - return Response.json({ - status: "ok! lookup created", - ip: ip, - ipinfo: ipinfo, - os: os, - browser: browser, - v: { - type: v, - viewport: { - messae: "hjdklqehlk" - } - } - }); - } - catch (err) { - console.error({ error: err }) - return Response.json({ error: err }); - } - } else if (request.method === "POST") { - - const payload = await request.json(); - const { namespace, event } = payload - - - const pcThreshold = 1024; - const tabletThreshold = 768; + if (request.method === 'GET') { + try { + return Response.json({ + status: 'ok! lookup created', + ip: ip, + ipinfo: ipinfo, + os: os, + browser: browser, + v: { + type: v, + viewport: { + messae: 'hjdklqehlk', + }, + }, + }); + } catch (err) { + console.error({ error: err }); + return Response.json({ error: err }); + } + } else if (request.method === 'POST') { + const payload = await request.json(); + const { namespace, event } = payload; - let device; + const pcThreshold = 1024; + const tabletThreshold = 768; - if (event.event.width < tabletThreshold) { - device = "mobile"; - } else if (event.event.width < pcThreshold) { - device = "tablet"; - } else { - device = "pc"; - } + let device; + if (event.event.width < tabletThreshold) { + device = 'mobile'; + } else if (event.event.width < pcThreshold) { + device = 'tablet'; + } else { + device = 'pc'; + } - try { - const response = await prisma.analytics.create({ - data: { - type: namespace, - os: os, - browser: browser, - device, - location: `${ipinfo.city}, ${ipinfo.region}, ${ipinfo.country}`, - path: event.path, - siteId: event.event.siteId || null, - blogId: event.event.blogId || null, - } - }) + try { + const response = await prisma.analytics.create({ + data: { + type: namespace, + os: os, + browser: browser, + device, + location: `${ipinfo.city}, ${ipinfo.region}, ${ipinfo.country}`, + path: event.path, + siteId: event.event.siteId || null, + blogId: event.event.blogId || null, + }, + }); - if (event.event.siteId) { - await prisma.site.update({ - where: { - id: event.event.siteId - }, - data: { - totalviews: { - increment: 1 - } - } - }) - } + if (event.event.siteId) { + await prisma.site.update({ + where: { + id: event.event.siteId, + }, + data: { + totalviews: { + increment: 1, + }, + }, + }); + } - if (event.event.blogId) { - await prisma.blog.update({ - where: { - id: event.event.blogId - }, - data: { - totalviews: { - increment: 1 - } - } - }) - } + if (event.event.blogId) { + await prisma.blog.update({ + where: { + id: event.event.blogId, + }, + data: { + totalviews: { + increment: 1, + }, + }, + }); + } - return Response.json({ status: "tracked " }); - } catch (error) { - console.error({ error: error }) - return Response.json({ error: error }); - } - } else { - return Response.json({ error: "Method not allowed" }, { status: 405 }); + return Response.json({ status: 'tracked ' }); + } catch (error) { + console.error({ error: error }); + return Response.json({ error: error }); } + } else { + return Response.json({ error: 'Method not allowed' }, { status: 405 }); + } } - export const GET = handler; -export const POST = handler; \ No newline at end of file +export const POST = handler; diff --git a/app/api/upload/route.ts b/app/api/upload/route.ts index ec4b41e..895bf3d 100644 --- a/app/api/upload/route.ts +++ b/app/api/upload/route.ts @@ -1,37 +1,41 @@ -import { NextResponse } from "next/server"; -import { UTApi } from "uploadthing/server"; -export const runtime = "edge"; +import { NextResponse } from 'next/server'; +import { UTApi } from 'uploadthing/server'; +export const runtime = 'edge'; const utapi = new UTApi(); export async function POST(req: Request) { - if (!process.env.UPLOADTHING_SECRET) { - return new Response( - "Missing UPLOADTHING_SECRET. Don't forget to add that to your .env file.", - { - status: 401, - }, - ); - } - - // console.log(req.body) + if (!process.env.UPLOADTHING_SECRET) { + return new Response( + "Missing UPLOADTHING_SECRET. Don't forget to add that to your .env file.", + { + status: 401, + } + ); + } - const file = req.body || ""; - const filename = req.headers.get("x-vercel-filename") || "file.txt"; - const contentType = req.headers.get("content-type") || "text/plain"; - const fileType = `.${contentType.split("/")[1]}`; + // console.log(req.body) - // construct final filename based on content-type if not provided - const finalName = filename.includes(fileType) - ? filename - : `${filename}${fileType}`; + const file = req.body || ''; + const filename = req.headers.get('x-vercel-filename') || 'file.txt'; + const contentType = req.headers.get('content-type') || 'text/plain'; + const fileType = `.${contentType.split('/')[1]}`; - const fileData = await new Response(file).arrayBuffer(); + // construct final filename based on content-type if not provided + const finalName = filename.includes(fileType) + ? filename + : `${filename}${fileType}`; + const fileData = await new Response(file).arrayBuffer(); - const upload = await utapi.uploadFiles(new File([new Uint8Array(fileData)], finalName)); - return NextResponse.json({ - url: upload.data?.url - }, { - status: 200, - }); + const upload = await utapi.uploadFiles( + new File([new Uint8Array(fileData)], finalName) + ); + return NextResponse.json( + { + url: upload.data?.url, + }, + { + status: 200, + } + ); } diff --git a/app/api/uploadthing/core.ts b/app/api/uploadthing/core.ts index 3f1e7b3..1b76ae5 100644 --- a/app/api/uploadthing/core.ts +++ b/app/api/uploadthing/core.ts @@ -1,5 +1,5 @@ -import { auth } from "@clerk/nextjs/server"; -import { createUploadthing, type FileRouter } from "uploadthing/next"; +import { auth } from '@clerk/nextjs/server'; +import { createUploadthing, type FileRouter } from 'uploadthing/next'; const f = createUploadthing(); @@ -7,28 +7,28 @@ const f = createUploadthing(); // FileRouter for your app, can contain multiple FileRoutes export const ourFileRouter = { - // Define as many FileRoutes as you like, each with a unique routeSlug - imageUploader: f({ image: { maxFileSize: "64MB" } }) - // Set permissions and file types for this FileRoute - .middleware(async ({ req }) => { - // This code runs on your server before upload - const user = await auth(); - - // If you throw, the user will not be able to upload - if (!user) throw new Error("Unauthorized"); - - // Whatever is returned here is accessible in onUploadComplete as `metadata` - return { userId: user.userId }; - }) - .onUploadComplete(async ({ metadata, file }) => { - // This code RUNS ON YOUR SERVER after upload - // console.log("Upload complete for userId:", metadata.userId); - - // console.log("file url", file.url); - - // !!! Whatever is returned here is sent to the clientside `onClientUploadComplete` callback - return { uploadedBy: metadata.userId }; - }), + // Define as many FileRoutes as you like, each with a unique routeSlug + imageUploader: f({ image: { maxFileSize: '64MB' } }) + // Set permissions and file types for this FileRoute + .middleware(async ({ req }) => { + // This code runs on your server before upload + const user = await auth(); + + // If you throw, the user will not be able to upload + if (!user) throw new Error('Unauthorized'); + + // Whatever is returned here is accessible in onUploadComplete as `metadata` + return { userId: user.userId }; + }) + .onUploadComplete(async ({ metadata, file }) => { + // This code RUNS ON YOUR SERVER after upload + // console.log("Upload complete for userId:", metadata.userId); + + // console.log("file url", file.url); + + // !!! Whatever is returned here is sent to the clientside `onClientUploadComplete` callback + return { uploadedBy: metadata.userId }; + }), } satisfies FileRouter; -export type OurFileRouter = typeof ourFileRouter; \ No newline at end of file +export type OurFileRouter = typeof ourFileRouter; diff --git a/app/api/uploadthing/route.ts b/app/api/uploadthing/route.ts index cb3ddf6..56cb516 100644 --- a/app/api/uploadthing/route.ts +++ b/app/api/uploadthing/route.ts @@ -1,8 +1,8 @@ -import { createNextRouteHandler } from "uploadthing/next"; +import { createNextRouteHandler } from 'uploadthing/next'; -import { ourFileRouter } from "./core"; +import { ourFileRouter } from './core'; // Export routes for Next App Router export const { GET, POST } = createNextRouteHandler({ - router: ourFileRouter, -}); \ No newline at end of file + router: ourFileRouter, +}); diff --git a/app/api/user/certificate/route.ts b/app/api/user/certificate/route.ts index 0137da7..1fa7e49 100644 --- a/app/api/user/certificate/route.ts +++ b/app/api/user/certificate/route.ts @@ -1,32 +1,31 @@ -import prisma from "@/lib/db"; -import { auth } from "@clerk/nextjs"; +import prisma from '@/lib/db'; +import { auth } from '@clerk/nextjs'; export const dynamic = 'force-dynamic'; async function handler(request: Request) { - if (request.method === "POST") { - try { - const userID = auth(); - if (!userID) return Response.json({ status: "Not Authorised" }); - const { ...data } = await request.json(); - await prisma.userCertificate.create({ - data: { - ...data, - user_id: userID.userId!, - }, - }); - return Response.json({ status: "ok! certificate created created" }); - } - catch (err) { - console.error({ error: err }) - return Response.json({ error: err }); - } - } else { - return Response.json({ - error: "Method not allowed", - }) + if (request.method === 'POST') { + try { + const userID = auth(); + if (!userID) return Response.json({ status: 'Not Authorised' }); + const { ...data } = await request.json(); + await prisma.userCertificate.create({ + data: { + ...data, + user_id: userID.userId!, + }, + }); + return Response.json({ status: 'ok! certificate created created' }); + } catch (err) { + console.error({ error: err }); + return Response.json({ error: err }); } + } else { + return Response.json({ + error: 'Method not allowed', + }); + } } export const GET = handler; -export const POST = handler; \ No newline at end of file +export const POST = handler; diff --git a/app/api/user/project/route.ts b/app/api/user/project/route.ts index 6e7dde1..072482a 100644 --- a/app/api/user/project/route.ts +++ b/app/api/user/project/route.ts @@ -1,32 +1,31 @@ -import prisma from "@/lib/db"; -import { auth } from "@clerk/nextjs"; +import prisma from '@/lib/db'; +import { auth } from '@clerk/nextjs'; export const dynamic = 'force-dynamic'; async function handler(request: Request) { - if (request.method === "POST") { - try { - const userID = auth(); - if (!userID) return Response.json({ status: "Not Authorised" }); - const { ...data } = await request.json(); - await prisma.projects.create({ - data: { - ...data, - user_id: userID.userId!, - }, - }); - return Response.json({ status: "ok! created" }); - } - catch (err) { - console.error({ error: err }) - return Response.json({ error: err }); - } - } else { - return Response.json({ - error: "Method not allowed", - }) + if (request.method === 'POST') { + try { + const userID = auth(); + if (!userID) return Response.json({ status: 'Not Authorised' }); + const { ...data } = await request.json(); + await prisma.projects.create({ + data: { + ...data, + user_id: userID.userId!, + }, + }); + return Response.json({ status: 'ok! created' }); + } catch (err) { + console.error({ error: err }); + return Response.json({ error: err }); } + } else { + return Response.json({ + error: 'Method not allowed', + }); + } } export const GET = handler; -export const POST = handler; \ No newline at end of file +export const POST = handler; diff --git a/app/api/webhook/user/route.ts b/app/api/webhook/user/route.ts index 84c53b8..e46500d 100644 --- a/app/api/webhook/user/route.ts +++ b/app/api/webhook/user/route.ts @@ -1,77 +1,79 @@ -import prisma from "@/lib/db"; -import { IncomingHttpHeaders } from "http"; -import { headers } from "next/headers"; -import { NextResponse } from "next/server"; -import { Webhook, WebhookRequiredHeaders } from "svix"; +import prisma from '@/lib/db'; +import { IncomingHttpHeaders } from 'http'; +import { headers } from 'next/headers'; +import { NextResponse } from 'next/server'; +import { Webhook, WebhookRequiredHeaders } from 'svix'; -const webhookSecret = process.env.CLERK_WEBHOOK_SIGNING_KEY || ""; +const webhookSecret = process.env.CLERK_WEBHOOK_SIGNING_KEY || ''; async function handler(request: Request) { - const payload = await request.json(); - const headersList = headers(); - const heads = { - "svix-id": headersList.get("svix-id"), - "svix-timestamp": headersList.get("svix-timestamp"), - "svix-signature": headersList.get("svix-signature"), - }; - const wh = new Webhook(webhookSecret); - let evt: Event | null = null; + const payload = await request.json(); + const headersList = headers(); + const heads = { + 'svix-id': headersList.get('svix-id'), + 'svix-timestamp': headersList.get('svix-timestamp'), + 'svix-signature': headersList.get('svix-signature'), + }; + const wh = new Webhook(webhookSecret); + let evt: Event | null = null; - try { - evt = wh.verify( - JSON.stringify(payload), - heads as IncomingHttpHeaders & WebhookRequiredHeaders - ) as Event; - } catch (err) { - console.error((err as Error).message); - return NextResponse.json({}, { status: 400 }); - } + try { + evt = wh.verify( + JSON.stringify(payload), + heads as IncomingHttpHeaders & WebhookRequiredHeaders + ) as Event; + } catch (err) { + console.error((err as Error).message); + return NextResponse.json({}, { status: 400 }); + } - const eventType: EventType = evt.type; - if (eventType === "user.created" || eventType === "user.updated") { + const eventType: EventType = evt.type; + if (eventType === 'user.created' || eventType === 'user.updated') { + const { + id, + username, + email_addresses, + first_name, + last_name, + profile_image_url, + ...attributes + } = evt.data; - const { id, - username, - email_addresses, - first_name, - last_name, - profile_image_url, - ...attributes - } = evt.data; + await prisma.user.upsert({ + where: { id: id as string }, + create: { + id: id as string, + username: username as string, + email: email_addresses[0].email_address as string, + firstname: (first_name as string) || '', + lastname: (last_name as string) || '', + avatar: profile_image_url, + attributes: attributes, + }, + update: { + username: username as string, + email: email_addresses[0].email_address as string, + firstname: (first_name as string) || '', + lastname: (last_name as string) || '', + attributes: attributes, + }, + }); + } - await prisma.user.upsert({ - where: { id: id as string }, - create: { - id: id as string, - username: username as string, - email: email_addresses[0].email_address as string, - firstname: first_name as string || "", - lastname: last_name as string || "", - avatar: profile_image_url, - attributes: attributes - }, - update: { - username: username as string, - email: email_addresses[0].email_address as string, - firstname: first_name as string || "", - lastname: last_name as string || "", - attributes: attributes, - }, - }); - } - - - return NextResponse.json({ - message: "ok", - }, { status: 200 }); + return NextResponse.json( + { + message: 'ok', + }, + { status: 200 } + ); } -type EventType = "user.created" | "user.updated" | "*"; +type EventType = 'user.created' | 'user.updated' | '*'; type Event = { - data: Record; - object: "event"; - type: EventType; + data: Record; + object: 'event'; + type: EventType; }; export const GET = handler; diff --git a/app/app/(auth)/sign-in/[[...sign-in]]/page.tsx b/app/app/(auth)/sign-in/[[...sign-in]]/page.tsx index 51a26b0..8722f84 100644 --- a/app/app/(auth)/sign-in/[[...sign-in]]/page.tsx +++ b/app/app/(auth)/sign-in/[[...sign-in]]/page.tsx @@ -1,12 +1,9 @@ -import { SignIn } from "@clerk/nextjs"; +import { SignIn } from '@clerk/nextjs'; export default function Page() { - return ( -
- -
- ) -} \ No newline at end of file + return ( +
+ +
+ ); +} diff --git a/app/app/(auth)/sign-up/[[...sign-up]]/page.tsx b/app/app/(auth)/sign-up/[[...sign-up]]/page.tsx index 3d6b29b..b44b5c5 100644 --- a/app/app/(auth)/sign-up/[[...sign-up]]/page.tsx +++ b/app/app/(auth)/sign-up/[[...sign-up]]/page.tsx @@ -1,9 +1,9 @@ -import { SignUp } from "@clerk/nextjs"; +import { SignUp } from '@clerk/nextjs'; export default function Page() { - return ( -
- -
- ) -} \ No newline at end of file + return ( +
+ +
+ ); +} diff --git a/app/app/community/page.tsx b/app/app/community/page.tsx index b9a5880..71978ef 100644 --- a/app/app/community/page.tsx +++ b/app/app/community/page.tsx @@ -1,15 +1,15 @@ -import NavBar from "@/components/common/NavBar" -import { TypographyH1 } from "@/components/common/Typography" +import NavBar from '@/components/common/NavBar'; +import { TypographyH1 } from '@/components/common/Typography'; function CommunityPage() { - return ( - <> - -
- Comming Soon -
- - ) + return ( + <> + +
+ Comming Soon +
+ + ); } -export default CommunityPage \ No newline at end of file +export default CommunityPage; diff --git a/app/app/dashboard/feedback/page.tsx b/app/app/dashboard/feedback/page.tsx index 76bf078..5a23350 100644 --- a/app/app/dashboard/feedback/page.tsx +++ b/app/app/dashboard/feedback/page.tsx @@ -1,11 +1,11 @@ -import FeedbackForm from "@/components/dashboard/feedback/FeedbackForm" +import FeedbackForm from '@/components/dashboard/feedback/FeedbackForm'; function FeedbackPage() { - return ( -
- -
- ) + return ( +
+ +
+ ); } -export default FeedbackPage \ No newline at end of file +export default FeedbackPage; diff --git a/app/app/dashboard/layout.tsx b/app/app/dashboard/layout.tsx index 6416a51..ca4f9c1 100644 --- a/app/app/dashboard/layout.tsx +++ b/app/app/dashboard/layout.tsx @@ -1,30 +1,24 @@ - - -import NavBar from "@/components/common/NavBar"; -import SideNavBar from "@/components/dashboard/DashBoardSideNavBar"; -import { APP_DESC, APP_NAME } from "@/lib/contants"; - +import NavBar from '@/components/common/NavBar'; +import SideNavBar from '@/components/dashboard/DashBoardSideNavBar'; +import { APP_DESC, APP_NAME } from '@/lib/contants'; export const metadata = { - title: `Dashboard - ${APP_NAME}`, - description: APP_DESC, + title: `Dashboard - ${APP_NAME}`, + description: APP_DESC, }; - export default function DashboardLayout({ - children, // will be a page or nested layout + children, // will be a page or nested layout }: { - children: React.ReactNode + children: React.ReactNode; }) { - return ( -
- -
- -
- {children} -
-
-
- ) -} \ No newline at end of file + return ( +
+ +
+ +
{children}
+
+
+ ); +} diff --git a/app/app/dashboard/page.tsx b/app/app/dashboard/page.tsx index 341f7d2..2b1221e 100644 --- a/app/app/dashboard/page.tsx +++ b/app/app/dashboard/page.tsx @@ -1,17 +1,15 @@ - -import AlertCard from "@/components/dashboard/AlertCard"; -import { currentUser } from "@clerk/nextjs/server"; -import { redirect } from "next/navigation"; - +import AlertCard from '@/components/dashboard/AlertCard'; +import { currentUser } from '@clerk/nextjs/server'; +import { redirect } from 'next/navigation'; export default async function Page() { - const User = await currentUser(); - if (!User) { - redirect("/sign-in") - } - return ( -
- -
- ) + const User = await currentUser(); + if (!User) { + redirect('/sign-in'); + } + return ( +
+ +
+ ); } diff --git a/app/app/dashboard/portfolio/[slug]/analytics/page.tsx b/app/app/dashboard/portfolio/[slug]/analytics/page.tsx index 2012de4..70e3135 100644 --- a/app/app/dashboard/portfolio/[slug]/analytics/page.tsx +++ b/app/app/dashboard/portfolio/[slug]/analytics/page.tsx @@ -1,40 +1,39 @@ -import { TypographyH1, TypographyH3 } from "@/components/common/Typography"; -import PortfolioAnaytlics from "@/components/dashboard/portfolio/PortfolioAnaytlics"; -import UserAgentsAnalytics from "@/components/dashboard/portfolio/UserAgentsAnalytics"; -import prisma from "@/lib/db"; -import { auth } from "@clerk/nextjs/server"; -import { notFound, redirect } from "next/navigation"; +import { TypographyH1, TypographyH3 } from '@/components/common/Typography'; +import PortfolioAnaytlics from '@/components/dashboard/portfolio/PortfolioAnaytlics'; +import UserAgentsAnalytics from '@/components/dashboard/portfolio/UserAgentsAnalytics'; +import prisma from '@/lib/db'; +import { auth } from '@clerk/nextjs/server'; +import { notFound, redirect } from 'next/navigation'; async function AnalyticsPage({ params }: { params: { slug: string } }) { - - const session = auth(); - if (!session) { - redirect("/sign-in"); - } - - - const data = await prisma.site.findUnique({ - where: { - id: decodeURIComponent(params.slug), - }, - }); - - if (!data || data.userId !== session.userId) { - notFound(); - } - const url = `${data.subdomain}.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`; - - - - return ( -
- Analytics 🔍🐬 - Portfolio Insights 🔍 - -

- -
- ) + const session = auth(); + if (!session) { + redirect('/sign-in'); + } + + const data = await prisma.site.findUnique({ + where: { + id: decodeURIComponent(params.slug), + }, + }); + + if (!data || data.userId !== session.userId) { + notFound(); + } + const url = `${data.subdomain}.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`; + + return ( +
+ Analytics 🔍🐬 + + Portfolio Insights 🔍 + + +
+
+ +
+ ); } -export default AnalyticsPage \ No newline at end of file +export default AnalyticsPage; diff --git a/app/app/dashboard/portfolio/[slug]/blog/[blogslug]/not-found.tsx b/app/app/dashboard/portfolio/[slug]/blog/[blogslug]/not-found.tsx index 9727873..df6408e 100644 --- a/app/app/dashboard/portfolio/[slug]/blog/[blogslug]/not-found.tsx +++ b/app/app/dashboard/portfolio/[slug]/blog/[blogslug]/not-found.tsx @@ -1,18 +1,18 @@ -import Image from "next/image"; +import Image from 'next/image'; export default function NotFoundPost() { - return ( -
-

404

- missing site -

- Blogs does not exist, or you do not have permission to edit it -

-
- ); + return ( +
+

404

+ missing site +

+ Blogs does not exist, or you do not have permission to edit it +

+
+ ); } diff --git a/app/app/dashboard/portfolio/[slug]/blog/[blogslug]/page.tsx b/app/app/dashboard/portfolio/[slug]/blog/[blogslug]/page.tsx index dddacc6..78ac2d3 100644 --- a/app/app/dashboard/portfolio/[slug]/blog/[blogslug]/page.tsx +++ b/app/app/dashboard/portfolio/[slug]/blog/[blogslug]/page.tsx @@ -1,34 +1,34 @@ -import BlogEditor from "@/components/dashboard/portfolio/blog/blog-editor"; -import prisma from "@/lib/db"; -import { auth } from "@clerk/nextjs/server"; -import { notFound, redirect } from "next/navigation"; - -export default async function BlogPage({ params }: { params: { blogslug: string } }) { - - const session = auth(); - - if (!session) { - redirect("/sign-in"); - } - - - const data = await prisma.blog.findUnique({ - where: { - id: decodeURIComponent(params.blogslug), +import BlogEditor from '@/components/dashboard/portfolio/blog/blog-editor'; +import prisma from '@/lib/db'; +import { auth } from '@clerk/nextjs/server'; +import { notFound, redirect } from 'next/navigation'; + +export default async function BlogPage({ + params, +}: { + params: { blogslug: string }; +}) { + const session = auth(); + + if (!session) { + redirect('/sign-in'); + } + + const data = await prisma.blog.findUnique({ + where: { + id: decodeURIComponent(params.blogslug), + }, + include: { + site: { + select: { + subdomain: true, }, - include: { - site: { - select: { - subdomain: true, - }, - }, - }, - }); - if (!data || data.userId !== session.userId) { - notFound(); - } - - - return ; + }, + }, + }); + if (!data || data.userId !== session.userId) { + notFound(); + } + + return ; } - diff --git a/app/app/dashboard/portfolio/[slug]/blog/[blogslug]/settings/page.tsx b/app/app/dashboard/portfolio/[slug]/blog/[blogslug]/settings/page.tsx index c5caa07..82207bf 100644 --- a/app/app/dashboard/portfolio/[slug]/blog/[blogslug]/settings/page.tsx +++ b/app/app/dashboard/portfolio/[slug]/blog/[blogslug]/settings/page.tsx @@ -1,9 +1,9 @@ -import Form from "@/components/form"; -import DeletePostForm from "@/components/form/delete-post-form"; -import { updatePostMetadata } from "@/lib/actions"; -import prisma from "@/lib/db"; -import { auth } from "@clerk/nextjs/server"; -import { notFound, redirect } from "next/navigation"; +import Form from '@/components/form'; +import DeletePostForm from '@/components/form/delete-post-form'; +import { updatePostMetadata } from '@/lib/actions'; +import prisma from '@/lib/db'; +import { auth } from '@clerk/nextjs/server'; +import { notFound, redirect } from 'next/navigation'; export default async function PostSettings({ params, @@ -12,7 +12,7 @@ export default async function PostSettings({ }) { const session = auth(); if (!session) { - redirect("/login"); + redirect('/login'); } const data = await prisma.blog.findUnique({ where: { @@ -33,10 +33,10 @@ export default async function PostSettings({ description="The slug is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens." helpText="Please use a slug that is unique to this post." inputAttrs={{ - name: "slug", - type: "text", + name: 'slug', + type: 'text', defaultValue: data?.slug!, - placeholder: "slug", + placeholder: 'slug', }} handleSubmit={updatePostMetadata} /> @@ -46,8 +46,8 @@ export default async function PostSettings({ description="The thumbnail image for your post. Accepted formats: .png, .jpg, .jpeg" helpText="Max file size 2MB. Recommended size 1200x630." inputAttrs={{ - name: "image", - type: "file", + name: 'image', + type: 'file', defaultValue: data?.image!, }} handleSubmit={updatePostMetadata} diff --git a/app/app/dashboard/portfolio/[slug]/blog/page.tsx b/app/app/dashboard/portfolio/[slug]/blog/page.tsx index f39c913..56c6567 100644 --- a/app/app/dashboard/portfolio/[slug]/blog/page.tsx +++ b/app/app/dashboard/portfolio/[slug]/blog/page.tsx @@ -1,40 +1,43 @@ -import AllBlogs from "@/components/dashboard/portfolio/blog/all-blogs"; -import CreateBlogButton from "@/components/dashboard/portfolio/blog/create-blog-button"; -import prisma from "@/lib/db"; -import { auth } from "@clerk/nextjs/server"; -import { notFound, redirect } from "next/navigation"; +import AllBlogs from '@/components/dashboard/portfolio/blog/all-blogs'; +import CreateBlogButton from '@/components/dashboard/portfolio/blog/create-blog-button'; +import prisma from '@/lib/db'; +import { auth } from '@clerk/nextjs/server'; +import { notFound, redirect } from 'next/navigation'; -export default async function SiteBlogsPage({ params, }: { params: { slug: string } }) { - const session = auth(); +export default async function SiteBlogsPage({ + params, +}: { + params: { slug: string }; +}) { + const session = auth(); - if (!session.userId) { - redirect("/sign-in"); - } + if (!session.userId) { + redirect('/sign-in'); + } - const data = await prisma.site.findUnique({ - where: { - id: decodeURIComponent(params.slug), - }, - }); + const data = await prisma.site.findUnique({ + where: { + id: decodeURIComponent(params.slug), + }, + }); - if (!data || data.userId !== session.userId) { - notFound(); - } + if (!data || data.userId !== session.userId) { + notFound(); + } - const url = `${data.subdomain}.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`; + const url = `${data.subdomain}.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`; - return ( - <> -
-
-

- All Posts for {data.name} -

-
- -
- - - ) + return ( + <> +
+
+

+ All Posts for {data.name} +

+
+ +
+ + + ); } - diff --git a/app/app/dashboard/portfolio/[slug]/layout.tsx b/app/app/dashboard/portfolio/[slug]/layout.tsx index 83f4707..3d0706e 100644 --- a/app/app/dashboard/portfolio/[slug]/layout.tsx +++ b/app/app/dashboard/portfolio/[slug]/layout.tsx @@ -1,33 +1,32 @@ - -import prisma from "@/lib/db"; -import { auth } from "@clerk/nextjs/server"; -import { notFound, redirect } from "next/navigation"; -import { ReactNode } from "react"; - - -export default async function SiteLayout({ children, params }: - { children: ReactNode, params: { slug: string } }) { - - const session = auth(); - if (!session) { - redirect("/sign-in"); - } - const data = await prisma.site.findUnique({ - where: { - id: decodeURIComponent(params.slug), - }, - }); - - if (!data || data.userId !== session.userId) { - notFound(); - } - - const url = `${data.subdomain}.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`; - - - return ( -
- {children} -
- ); +import prisma from '@/lib/db'; +import { auth } from '@clerk/nextjs/server'; +import { notFound, redirect } from 'next/navigation'; +import { ReactNode } from 'react'; + +export default async function SiteLayout({ + children, + params, +}: { + children: ReactNode; + params: { slug: string }; +}) { + const session = auth(); + if (!session) { + redirect('/sign-in'); + } + const data = await prisma.site.findUnique({ + where: { + id: decodeURIComponent(params.slug), + }, + }); + + if (!data || data.userId !== session.userId) { + notFound(); + } + + const url = `${data.subdomain}.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`; + + return ( +
{children}
+ ); } diff --git a/app/app/dashboard/portfolio/[slug]/loading.tsx b/app/app/dashboard/portfolio/[slug]/loading.tsx index 30fa440..1ea5973 100644 --- a/app/app/dashboard/portfolio/[slug]/loading.tsx +++ b/app/app/dashboard/portfolio/[slug]/loading.tsx @@ -1,12 +1,11 @@ // a bunch of loading divs -import { Loader2Icon } from "lucide-react"; - +import { Loader2Icon } from 'lucide-react'; export default function Loading() { - return ( -
- -
- ); + return ( +
+ +
+ ); } diff --git a/app/app/dashboard/portfolio/[slug]/not-found.tsx b/app/app/dashboard/portfolio/[slug]/not-found.tsx index 22656df..e9cc9c0 100644 --- a/app/app/dashboard/portfolio/[slug]/not-found.tsx +++ b/app/app/dashboard/portfolio/[slug]/not-found.tsx @@ -1,26 +1,26 @@ -import Image from "next/image"; +import Image from 'next/image'; export default function NotFoundSite() { - return ( -
-

404

- missing site - missing site -

- Site does not exist, or you do not have permission to view it -

-
- ); + return ( +
+

404

+ missing site + missing site +

+ Site does not exist, or you do not have permission to view it +

+
+ ); } diff --git a/app/app/dashboard/portfolio/[slug]/page.tsx b/app/app/dashboard/portfolio/[slug]/page.tsx index e09fb96..332ba55 100644 --- a/app/app/dashboard/portfolio/[slug]/page.tsx +++ b/app/app/dashboard/portfolio/[slug]/page.tsx @@ -1,57 +1,52 @@ -import { TypographyH1, TypographyH2 } from "@/components/common/Typography"; -import BlogAnalytics from "@/components/dashboard/portfolio/BlogAnalytics"; -import PortfolioAnaytlics from "@/components/dashboard/portfolio/PortfolioAnaytlics"; -import prisma from "@/lib/db"; -import { auth } from "@clerk/nextjs/server"; -import { Button } from "@nextui-org/react"; -import Link from "next/link"; -import { notFound, redirect } from "next/navigation"; -async function SinglePortfolioPage({ - params, -}: { - params: { slug: string }; -}) { +import { TypographyH1, TypographyH2 } from '@/components/common/Typography'; +import BlogAnalytics from '@/components/dashboard/portfolio/BlogAnalytics'; +import PortfolioAnaytlics from '@/components/dashboard/portfolio/PortfolioAnaytlics'; +import prisma from '@/lib/db'; +import { auth } from '@clerk/nextjs/server'; +import { Button } from '@nextui-org/react'; +import Link from 'next/link'; +import { notFound, redirect } from 'next/navigation'; +async function SinglePortfolioPage({ params }: { params: { slug: string } }) { + const session = auth(); + if (!session) { + redirect('/sign-in'); + } + const data = await prisma.site.findUnique({ + where: { + id: decodeURIComponent(params.slug), + }, + }); - const session = auth(); - if (!session) { - redirect("/sign-in"); - } - const data = await prisma.site.findUnique({ - where: { - id: decodeURIComponent(params.slug), - }, - }); + if (!data || data.userId !== session.userId) { + notFound(); + } + const url = `${data.subdomain}.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`; - if (!data || data.userId !== session.userId) { - notFound(); - } - const url = `${data.subdomain}.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`; - - - - return ( -
- - - - Portfolio Insights 🔍 - - Blogs Insights 🔍 - -
- ) + return ( +
+ + + + + Portfolio Insights 🔍 + + + Blogs Insights 🔍 + +
+ ); } -export default SinglePortfolioPage \ No newline at end of file +export default SinglePortfolioPage; diff --git a/app/app/dashboard/portfolio/[slug]/settings/AppearanceSection.tsx b/app/app/dashboard/portfolio/[slug]/settings/AppearanceSection.tsx index d7752ef..02ab760 100644 --- a/app/app/dashboard/portfolio/[slug]/settings/AppearanceSection.tsx +++ b/app/app/dashboard/portfolio/[slug]/settings/AppearanceSection.tsx @@ -1,64 +1,66 @@ -import Form from "@/components/form"; -import { updateSite } from "@/lib/actions"; -import prisma from "@/lib/db"; +import Form from '@/components/form'; +import { updateSite } from '@/lib/actions'; +import prisma from '@/lib/db'; -export default async function AppearanceSection({ siteId }: { siteId: string }) { +export default async function AppearanceSection({ + siteId, +}: { + siteId: string; +}) { + const data = await prisma.site.findUnique({ + where: { + id: decodeURIComponent(siteId), + }, + }); - const data = await prisma.site.findUnique({ - where: { - id: decodeURIComponent(siteId), - }, - }); - - - return ( -
-
- - - -
- ) -} \ No newline at end of file + return ( +
+ + + + +
+ ); +} diff --git a/app/app/dashboard/portfolio/[slug]/settings/CertificateSection.tsx b/app/app/dashboard/portfolio/[slug]/settings/CertificateSection.tsx index ff80892..c212591 100644 --- a/app/app/dashboard/portfolio/[slug]/settings/CertificateSection.tsx +++ b/app/app/dashboard/portfolio/[slug]/settings/CertificateSection.tsx @@ -1,12 +1,11 @@ -import { TypographyH1 } from "@/components/common/Typography" +import { TypographyH1 } from '@/components/common/Typography'; function CertificateSection() { - return ( -
- Comming Soon... - -
- ) + return ( +
+ Comming Soon... +
+ ); } -export default CertificateSection \ No newline at end of file +export default CertificateSection; diff --git a/app/app/dashboard/portfolio/[slug]/settings/DomainSection.tsx b/app/app/dashboard/portfolio/[slug]/settings/DomainSection.tsx index 82ca705..f546131 100644 --- a/app/app/dashboard/portfolio/[slug]/settings/DomainSection.tsx +++ b/app/app/dashboard/portfolio/[slug]/settings/DomainSection.tsx @@ -1,47 +1,44 @@ -import Form from "@/components/form"; -import { updateSite } from "@/lib/actions"; -import prisma from "@/lib/db"; - +import Form from '@/components/form'; +import { updateSite } from '@/lib/actions'; +import prisma from '@/lib/db'; export default async function DomainSection({ siteId }: { siteId: string }) { + // console.log(siteId) + const data = await prisma.site.findUnique({ + where: { + id: siteId as string, + }, + }); - // console.log(siteId) - const data = await prisma.site.findUnique({ - where: { - id: siteId as string, - }, - }); - - - return ( -
- - -
- ) + return ( +
+ + +
+ ); } diff --git a/app/app/dashboard/portfolio/[slug]/settings/EducationSection.tsx b/app/app/dashboard/portfolio/[slug]/settings/EducationSection.tsx index 5f6d370..cf1cc9c 100644 --- a/app/app/dashboard/portfolio/[slug]/settings/EducationSection.tsx +++ b/app/app/dashboard/portfolio/[slug]/settings/EducationSection.tsx @@ -1,49 +1,43 @@ - -import EducationCard from "@/components/dashboard/portfolio/education/EducationCard"; -import AddEducationForm from "@/components/form/education-form"; -import { Separator } from "@/components/ui/separator"; -import prisma from "@/lib/db"; -import { auth } from "@clerk/nextjs/server"; +import EducationCard from '@/components/dashboard/portfolio/education/EducationCard'; +import AddEducationForm from '@/components/form/education-form'; +import { Separator } from '@/components/ui/separator'; +import prisma from '@/lib/db'; +import { auth } from '@clerk/nextjs/server'; async function EducationSection({ siteId }: { siteId: string }) { + const user = auth(); + if (!user.userId) { + return '/'; + } + const education = await prisma.userEducation.findMany({ + where: { + user_id: user.userId as string, + siteId, + }, + orderBy: { + school_end_date: 'desc', + }, + }); - const user = auth(); - if (!user.userId) { - return ("/") - } - const education = await prisma.userEducation.findMany({ - where: { - user_id: user.userId as string, - siteId, - }, - orderBy: { - school_end_date: "desc", - }, - }) - - - return education.length > 0 ? ( -
-
- Add Education - -
- {education.map((education) => ( - - ))} - -
- ) : ( -
-

- You do not have any Education yet. Create one to get started. -

- -
- ); + return education.length > 0 ? ( +
+
+ Add Education + +
+ {education.map((education) => ( + + ))} + +
+ ) : ( +
+

+ You do not have any Education yet. Create one to get started. +

+ +
+ ); } -export default EducationSection \ No newline at end of file +export default EducationSection; diff --git a/app/app/dashboard/portfolio/[slug]/settings/GeneralSection.tsx b/app/app/dashboard/portfolio/[slug]/settings/GeneralSection.tsx index 069c2b7..cdf10da 100644 --- a/app/app/dashboard/portfolio/[slug]/settings/GeneralSection.tsx +++ b/app/app/dashboard/portfolio/[slug]/settings/GeneralSection.tsx @@ -1,81 +1,81 @@ -import { TypographyH2 } from "@/components/common/Typography"; -import Form from "@/components/form"; -import DeleteSiteForm from "@/components/form/delete-site-form"; -import AboutEditor from "@/components/form/site-about-form"; -import SocialMediaForm from "@/components/form/social-media-form"; -import { updateSite } from "@/lib/actions"; -import prisma from "@/lib/db"; - +import { TypographyH2 } from '@/components/common/Typography'; +import Form from '@/components/form'; +import DeleteSiteForm from '@/components/form/delete-site-form'; +import AboutEditor from '@/components/form/site-about-form'; +import SocialMediaForm from '@/components/form/social-media-form'; +import { updateSite } from '@/lib/actions'; +import prisma from '@/lib/db'; export default async function GeneralSection({ siteId }: { siteId: string }) { - const data = await prisma.site.findUnique({ - where: { - id: decodeURIComponent(siteId), - }, - }); + const data = await prisma.site.findUnique({ + where: { + id: decodeURIComponent(siteId), + }, + }); - return ( -
- + return ( +
+ - - - - Social Media 🤖 - - Danger Zone - -
- ) + + + + Social Media 🤖 + + + Danger Zone + + +
+ ); } - diff --git a/app/app/dashboard/portfolio/[slug]/settings/PortfolioSettingNav.tsx b/app/app/dashboard/portfolio/[slug]/settings/PortfolioSettingNav.tsx index 6c6968f..b7f18d9 100644 --- a/app/app/dashboard/portfolio/[slug]/settings/PortfolioSettingNav.tsx +++ b/app/app/dashboard/portfolio/[slug]/settings/PortfolioSettingNav.tsx @@ -1,80 +1,76 @@ -import { - Tabs, - TabsContent, - TabsList, - TabsTrigger, -} from "@/components/ui/tabs"; -import AppearanceSection from "./AppearanceSection"; -import CertificateSection from "./CertificateSection"; -import DomainSection from "./DomainSection"; -import EducationSection from "./EducationSection"; -import GeneralSection from "./GeneralSection"; -import SkillsToolsSection from "./SkillsToolsSection"; -import WorkExperienceSection from "./WorkSection"; - +import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'; +import AppearanceSection from './AppearanceSection'; +import CertificateSection from './CertificateSection'; +import DomainSection from './DomainSection'; +import EducationSection from './EducationSection'; +import GeneralSection from './GeneralSection'; +import SkillsToolsSection from './SkillsToolsSection'; +import WorkExperienceSection from './WorkSection'; export default function SiteSettingsNav({ slug }: { slug: string }) { - const navItems = [ - { - name: "General", - value: "general", - component: , - }, - { - name: "Domain", - value: "domain", - component: , - }, - { - name: "Education", - value: "education", - component: , - }, - { - name: "Skills & Tools", - value: "tools", - component: , - }, - { - name: "Work", - value: "work", - component: , - }, - { - name: "Project", - value: "project", - component: , - }, - { - name: "Certification", - value: "certificate", - component: , - }, - { - name: "Appearance", - value: "appearance", - component: - }, - ]; + const navItems = [ + { + name: 'General', + value: 'general', + component: , + }, + { + name: 'Domain', + value: 'domain', + component: , + }, + { + name: 'Education', + value: 'education', + component: , + }, + { + name: 'Skills & Tools', + value: 'tools', + component: , + }, + { + name: 'Work', + value: 'work', + component: , + }, + { + name: 'Project', + value: 'project', + component: , + }, + { + name: 'Certification', + value: 'certificate', + component: , + }, + { + name: 'Appearance', + value: 'appearance', + component: , + }, + ]; - return ( -
- - - { - navItems.map((nav, index) => ( - {nav.name} - )) - } - - { - navItems.map((nav, index) => ( - {nav.component} - )) - } - -
- ); + return ( +
+ + + {navItems.map((nav, index) => ( + + {nav.name} + + ))} + + {navItems.map((nav, index) => ( + + {nav.component} + + ))} + +
+ ); } diff --git a/app/app/dashboard/portfolio/[slug]/settings/SkillsToolsSection.tsx b/app/app/dashboard/portfolio/[slug]/settings/SkillsToolsSection.tsx index 658940d..8666ef3 100644 --- a/app/app/dashboard/portfolio/[slug]/settings/SkillsToolsSection.tsx +++ b/app/app/dashboard/portfolio/[slug]/settings/SkillsToolsSection.tsx @@ -1,65 +1,68 @@ -import SkillForm from "@/components/dashboard/portfolio/skills/SkillForm"; -import ToolForm from "@/components/dashboard/portfolio/skills/ToolForm"; -import prisma from "@/lib/db"; -import { auth } from "@clerk/nextjs/server"; +import SkillForm from '@/components/dashboard/portfolio/skills/SkillForm'; +import ToolForm from '@/components/dashboard/portfolio/skills/ToolForm'; +import prisma from '@/lib/db'; +import { auth } from '@clerk/nextjs/server'; +export default async function SkillsToolsSection({ + siteId, +}: { + siteId: string; +}) { + const user = auth(); + if (!user.userId) { + return '/'; + } -export default async function SkillsToolsSection({ siteId }: { siteId: string }) { - const user = auth(); - if (!user.userId) { - return ("/") - } + const masterdata = await Promise.all([ + await prisma.site.findFirst({ + where: { + id: siteId, + }, + select: { + skills: true, + siteTechStack: true, + }, + }), + prisma.techStack.findMany({ + where: { + siteTechStack: { + some: { + siteId: siteId, + }, + }, + }, + }), + await prisma.techStack.findMany(), + ]); + // const Siteskills = await prisma.site.findFirst({ + // where: { + // id: siteId + // }, + // select: { + // skills: true, + // siteTechStack: true + // } + // }) + // const techstack = await prisma.techStack.findMany({ + // where: { + // siteTechStack: { + // some: { + // siteId: siteId + // } + // } + // } + // }) + // const alltechstack = await prisma.techStack.findMany(); - - const masterdata = await Promise.all([ - await prisma.site.findFirst({ - where: { - id: siteId - }, - select: { - skills: true, - siteTechStack: true - } - }), - prisma.techStack.findMany({ - where: { - siteTechStack: { - some: { - siteId: siteId - } - } - } - }), - await prisma.techStack.findMany() - ]) - // const Siteskills = await prisma.site.findFirst({ - // where: { - // id: siteId - // }, - // select: { - // skills: true, - // siteTechStack: true - // } - // }) - // const techstack = await prisma.techStack.findMany({ - // where: { - // siteTechStack: { - // some: { - // siteId: siteId - // } - // } - // } - // }) - - - // const alltechstack = await prisma.techStack.findMany(); - - - return ( -
- - -
- ) + return ( +
+ + +
+ ); } diff --git a/app/app/dashboard/portfolio/[slug]/settings/WorkSection.tsx b/app/app/dashboard/portfolio/[slug]/settings/WorkSection.tsx index 3dba533..f2ad083 100644 --- a/app/app/dashboard/portfolio/[slug]/settings/WorkSection.tsx +++ b/app/app/dashboard/portfolio/[slug]/settings/WorkSection.tsx @@ -1,46 +1,43 @@ -import WorkExperienceCard from "@/components/dashboard/portfolio/work/WorkExperienceCard"; -import WorkExperienceForm from "@/components/form/work-form"; -import prisma from "@/lib/db"; -import { auth } from "@clerk/nextjs/server"; +import WorkExperienceCard from '@/components/dashboard/portfolio/work/WorkExperienceCard'; +import WorkExperienceForm from '@/components/form/work-form'; +import prisma from '@/lib/db'; +import { auth } from '@clerk/nextjs/server'; +export default async function WorkExperienceSection({ + siteId, +}: { + siteId: string; +}) { + const user = auth(); + if (!user.userId) { + return '/'; + } + const work = await prisma.userWorkExperience.findMany({ + where: { + siteId, + user_id: user.userId as string, + }, + orderBy: { + employment_start_date: 'desc', + }, + }); -export default async function WorkExperienceSection({ siteId }: { siteId: string }) { - const user = auth(); - if (!user.userId) { - return ("/") - } - const work = await prisma.userWorkExperience.findMany({ - where: { - siteId, - user_id: user.userId as string - }, - orderBy: { - employment_start_date: "desc", - }, - - }) - - - - return work.length > 0 ? ( -
-
- Add Work Experience - -
- {work.map((work) => ( - - ))} -
- ) : ( -
-

- You do not have any Work Experience yet. Create one to get started. -

- -
- ); -} \ No newline at end of file + return work.length > 0 ? ( +
+
+ Add Work Experience + +
+ {work.map((work) => ( + + ))} +
+ ) : ( +
+

+ You do not have any Work Experience yet. Create one to get started. +

+ +
+ ); +} diff --git a/app/app/dashboard/portfolio/[slug]/settings/page.tsx b/app/app/dashboard/portfolio/[slug]/settings/page.tsx index 8fb7ccc..0adc645 100644 --- a/app/app/dashboard/portfolio/[slug]/settings/page.tsx +++ b/app/app/dashboard/portfolio/[slug]/settings/page.tsx @@ -1,32 +1,30 @@ -import prisma from "@/lib/db"; -import { auth } from "@clerk/nextjs/server"; -import { notFound, redirect } from "next/navigation"; -import SiteSettingsNav from "./PortfolioSettingNav"; - +import prisma from '@/lib/db'; +import { auth } from '@clerk/nextjs/server'; +import { notFound, redirect } from 'next/navigation'; +import SiteSettingsNav from './PortfolioSettingNav'; export default async function PortfolioSettingsIndex({ - params, + params, }: { - params: { slug: string }; + params: { slug: string }; }) { + const session = auth(); + if (!session.userId) { + redirect('/'); + } + const data = await prisma.site.findUnique({ + where: { + id: decodeURIComponent(params.slug), + }, + }); - const session = auth(); - if (!session.userId) { - redirect("/"); - } - const data = await prisma.site.findUnique({ - where: { - id: decodeURIComponent(params.slug), - }, - }); - - if (!data || data.userId !== session.userId) { - notFound(); - } + if (!data || data.userId !== session.userId) { + notFound(); + } - return ( -
- -
- ) + return ( +
+ +
+ ); } diff --git a/app/app/dashboard/portfolio/page.tsx b/app/app/dashboard/portfolio/page.tsx index 13cb686..3814ae3 100644 --- a/app/app/dashboard/portfolio/page.tsx +++ b/app/app/dashboard/portfolio/page.tsx @@ -1,15 +1,15 @@ -import { TypographyH3 } from "@/components/common/Typography"; -import AllPortfolioLayout from "@/components/dashboard/portfolio/AllPortfolio"; -import CreatePortfolio from "@/components/dashboard/portfolio/CreatePortfolio"; +import { TypographyH3 } from '@/components/common/Typography'; +import AllPortfolioLayout from '@/components/dashboard/portfolio/AllPortfolio'; +import CreatePortfolio from '@/components/dashboard/portfolio/CreatePortfolio'; export default async function PortfolioPage() { - return ( -
-
- All Portfolio - -
- -
- ) + return ( +
+
+ All Portfolio + +
+ +
+ ); } diff --git a/app/app/dashboard/settings/page.tsx b/app/app/dashboard/settings/page.tsx index 24699c0..f6f5236 100644 --- a/app/app/dashboard/settings/page.tsx +++ b/app/app/dashboard/settings/page.tsx @@ -1,148 +1,148 @@ -import { TypographyH2 } from "@/components/common/Typography"; -import Form from "@/components/form"; -import { editUser } from "@/lib/actions"; -import prisma from "@/lib/db"; -import { auth } from "@clerk/nextjs/server"; -import { redirect } from "next/navigation"; +import { TypographyH2 } from '@/components/common/Typography'; +import Form from '@/components/form'; +import { editUser } from '@/lib/actions'; +import prisma from '@/lib/db'; +import { auth } from '@clerk/nextjs/server'; +import { redirect } from 'next/navigation'; // import { editUser } from "@/lib/actions"; export default async function SettingsPage() { - const user = auth(); - if (!user) { - return redirect("/sign-in"); - } + const user = auth(); + if (!user) { + return redirect('/sign-in'); + } - const userdetails = await prisma.user.findUnique({ - where: { - id: user.userId!, - }, - }); + const userdetails = await prisma.user.findUnique({ + where: { + id: user.userId!, + }, + }); - return ( -
-
-

- User Settings 🌱 -

- {/* */} - - - - - - Social Media 🤖 - - - - -
-
- ); + return ( +
+
+

+ User Settings 🌱 +

+ {/* */} + + + + + + Social Media 🤖 + + + + +
+
+ ); } diff --git a/app/app/editor/page.tsx b/app/app/editor/page.tsx index 74ff004..459c8f2 100644 --- a/app/app/editor/page.tsx +++ b/app/app/editor/page.tsx @@ -1,15 +1,7 @@ -import { Editor } from "novel" - - +import { Editor } from 'novel'; function page() { - return ( - - ) + return ; } -export default page \ No newline at end of file +export default page; diff --git a/app/app/explore/page.tsx b/app/app/explore/page.tsx index a5d79bf..fc2ec29 100644 --- a/app/app/explore/page.tsx +++ b/app/app/explore/page.tsx @@ -1,19 +1,17 @@ - -import BlogPreviewSection from "@/components/explore/BlogPreview"; -import CallToActionPreview from "@/components/explore/Cta"; -import ProductShowcase from "@/components/explore/FeatureShowcase"; -import LandingPage from "@/components/explore/LandingPage"; -import TestimonialsSection from "@/components/explore/Testimonials"; +import BlogPreviewSection from '@/components/explore/BlogPreview'; +import CallToActionPreview from '@/components/explore/Cta'; +import ProductShowcase from '@/components/explore/FeatureShowcase'; +import LandingPage from '@/components/explore/LandingPage'; +import TestimonialsSection from '@/components/explore/Testimonials'; export default async function Explore() { - return ( - <> - - - - - - - ) + return ( + <> + + + + + + + ); } - diff --git a/app/app/page.tsx b/app/app/page.tsx index f01e80a..4e6688c 100644 --- a/app/app/page.tsx +++ b/app/app/page.tsx @@ -1,14 +1,14 @@ -import Footer from "@/components/common/Footer"; -import NavBar from "@/components/common/NavBar"; -import BlogPreviewSection from "@/components/explore/BlogPreview"; -import CallToActionPreview from "@/components/explore/Cta"; -import ProductShowcase from "@/components/explore/FeatureShowcase"; -import TestimonialsSection from "@/components/explore/Testimonials"; -import LandingSection from "@/components/home/landingsection"; +import Footer from '@/components/common/Footer'; +import NavBar from '@/components/common/NavBar'; +import BlogPreviewSection from '@/components/explore/BlogPreview'; +import CallToActionPreview from '@/components/explore/Cta'; +import ProductShowcase from '@/components/explore/FeatureShowcase'; +import TestimonialsSection from '@/components/explore/Testimonials'; +import LandingSection from '@/components/home/landingsection'; export default function Home() { return ( -
+
diff --git a/app/home/page.tsx b/app/home/page.tsx index e63279f..d43d67d 100644 --- a/app/home/page.tsx +++ b/app/home/page.tsx @@ -1,34 +1,28 @@ -import { TypographyH1 } from "@/components/common/Typography" -import { Button } from "@nextui-org/react" -import Image from "next/image" -import Link from "next/link" - +import { TypographyH1 } from '@/components/common/Typography'; +import { Button } from '@nextui-org/react'; +import Image from 'next/image'; +import Link from 'next/link'; function Page() { - return ( -
- 🤫 Dicovered something unTold❗ - cool stuff discovered - - - -
- ) + return ( +
+ + 🤫 Dicovered something unTold❗ + + cool stuff discovered + + + +
+ ); } -export default Page \ No newline at end of file +export default Page; diff --git a/app/layout.tsx b/app/layout.tsx index aa58e29..c8398d8 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -1,49 +1,53 @@ -import { Toaster } from "@/components/ui/sonner"; +import { Toaster } from '@/components/ui/sonner'; import { APP_DESC, APP_NAME } from '@/lib/contants'; -import { SpeedInsights } from "@vercel/speed-insights/next"; +import { SpeedInsights } from '@vercel/speed-insights/next'; import { GeistSans } from 'geist/font/sans'; -import { Metadata } from "next"; +import { Metadata } from 'next'; import '.././styles/globals.css'; import { Providers } from './NextUIProvider'; -const image = "https://app.dresume.me/placeholder.png"; +const image = 'https://app.dresume.me/placeholder.png'; export const metadata: Metadata = { + title: APP_NAME, + description: APP_DESC, + icons: ['https://app.dresume.me/favicon.ico'], + openGraph: { title: APP_NAME, description: APP_DESC, - icons: ["https://app.dresume.me/favicon.ico"], - openGraph: { - title: APP_NAME, - description: APP_DESC, - images: [image], - }, - twitter: { - card: "summary_large_image", - title: APP_NAME, - description: APP_DESC, - images: [image], - creator: "@abhishekkushwaha", - }, - metadataBase: new URL("https://app.dresume.me"), + images: [image], + }, + twitter: { + card: 'summary_large_image', + title: APP_NAME, + description: APP_DESC, + images: [image], + creator: '@abhishekkushwaha', + }, + metadataBase: new URL('https://app.dresume.me'), }; export default function RootLayout({ - children, + children, }: { - children: React.ReactNode; + children: React.ReactNode; }) { - return ( - - - - - - {/* */} - - {children} - - - - - - ); + return ( + + +