-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
79 changed files
with
12,332 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "next/core-web-vitals" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
.yarn/install-state.gz | ||
|
||
# testing | ||
/coverage | ||
|
||
# next.js | ||
/.next/ | ||
/out/ | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
*.pem | ||
|
||
# debug | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# local env files | ||
.env*.local | ||
|
||
# vercel | ||
.vercel | ||
|
||
# typescript | ||
*.tsbuildinfo | ||
next-env.d.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Mohd. Nisab | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import { Typography } from "@/components/typography"; | ||
import { buttonVariants } from "@/components/ui/button"; | ||
import { Author, getAllBlogStaticPaths, getBlogForSlug } from "@/lib/markdown"; | ||
import { ArrowLeftIcon } from "lucide-react"; | ||
import Link from "next/link"; | ||
import { notFound } from "next/navigation"; | ||
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; | ||
import { formatDate } from "@/lib/utils"; | ||
import Image from "next/image"; | ||
|
||
type PageProps = { | ||
params: { slug: string }; | ||
}; | ||
|
||
export async function generateMetadata({ params: { slug } }: PageProps) { | ||
const res = await getBlogForSlug(slug); | ||
if (!res) return null; | ||
const { frontmatter } = res; | ||
return { | ||
title: frontmatter.title, | ||
description: frontmatter.description, | ||
}; | ||
} | ||
|
||
export async function generateStaticParams() { | ||
const val = await getAllBlogStaticPaths(); | ||
if (!val) return []; | ||
return val.map((it) => ({ slug: it })); | ||
} | ||
|
||
export default async function BlogPage({ params: { slug } }: PageProps) { | ||
const res = await getBlogForSlug(slug); | ||
if (!res) notFound(); | ||
return ( | ||
<div className="lg:w-[60%] sm:[95%] md:[75%] mx-auto"> | ||
<Link | ||
className={buttonVariants({ | ||
variant: "link", | ||
className: "!mx-0 !px-0 mb-7 !-ml-1 ", | ||
})} | ||
href="/blog" | ||
> | ||
<ArrowLeftIcon className="w-4 h-4 mr-1.5" /> Back to blog | ||
</Link> | ||
<div className="flex flex-col gap-3 pb-7 w-full mb-2"> | ||
<p className="text-muted-foreground text-sm"> | ||
{formatDate(res.frontmatter.date)} | ||
</p> | ||
<h1 className="sm:text-4xl text-3xl font-extrabold"> | ||
{res.frontmatter.title} | ||
</h1> | ||
<div className="mt-6 flex flex-col gap-3"> | ||
<p className="text-sm text-muted-foreground">Posted by</p> | ||
<Authors authors={res.frontmatter.authors} /> | ||
</div> | ||
</div> | ||
<div className="!w-full"> | ||
<div className="w-full mb-7"> | ||
<Image | ||
src={res.frontmatter.cover} | ||
alt="cover" | ||
width={700} | ||
height={400} | ||
className="w-full h-[400px] rounded-md border object-cover" | ||
/> | ||
</div> | ||
<Typography>{res.content}</Typography> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
function Authors({ authors }: { authors: Author[] }) { | ||
return ( | ||
<div className="flex items-center gap-8 flex-wrap"> | ||
{authors.map((author) => { | ||
return ( | ||
<Link | ||
href={author.handleUrl} | ||
className="flex items-center gap-2" | ||
key={author.username} | ||
> | ||
<Avatar className="w-10 h-10"> | ||
<AvatarImage src={author.avatar} /> | ||
<AvatarFallback> | ||
{author.username.slice(0, 2).toUpperCase()} | ||
</AvatarFallback> | ||
</Avatar> | ||
<div className=""> | ||
<p className="text-sm font-medium">{author.username}</p> | ||
<p className="font-code text-[13px] text-muted-foreground"> | ||
@{author.handle} | ||
</p> | ||
</div> | ||
</Link> | ||
); | ||
})} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { PropsWithChildren } from "react"; | ||
|
||
export default function BlogLayout({ children }: PropsWithChildren) { | ||
return ( | ||
<div className="flex flex-col items-start justify-center pt-8 pb-10 w-full mx-auto"> | ||
{children} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; | ||
import { Author, BlogMdxFrontmatter, getAllBlogs } from "@/lib/markdown"; | ||
import { formatDate2, stringToDate } from "@/lib/utils"; | ||
import { Metadata } from "next"; | ||
import Image from "next/image"; | ||
import Link from "next/link"; | ||
|
||
export const metadata: Metadata = { | ||
title: "AriaDocs - Blog", | ||
}; | ||
|
||
export default async function BlogIndexPage() { | ||
const blogs = (await getAllBlogs()).sort( | ||
(a, b) => stringToDate(b.date).getTime() - stringToDate(a.date).getTime() | ||
); | ||
return ( | ||
<div className="w-full mx-auto flex flex-col gap-1 sm:min-h-[91vh] min-h-[88vh] pt-2"> | ||
<div className="mb-7 flex flex-col gap-2"> | ||
<h1 className="text-3xl font-extrabold"> | ||
The latest blogs of this product | ||
</h1> | ||
<p className="text-muted-foreground"> | ||
All the latest blogs and news, straight from the team. | ||
</p> | ||
</div> | ||
<div className="grid md:grid-cols-3 sm:grid-cols-2 grid-cols-1 sm:gap-8 gap-4 mb-5"> | ||
{blogs.map((blog) => ( | ||
<BlogCard {...blog} slug={blog.slug} key={blog.slug} /> | ||
))} | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
function BlogCard({ | ||
date, | ||
title, | ||
description, | ||
slug, | ||
cover, | ||
authors, | ||
}: BlogMdxFrontmatter & { slug: string }) { | ||
return ( | ||
<Link | ||
href={`/blog/${slug}`} | ||
className="flex flex-col gap-2 items-start border rounded-md py-5 px-3 min-h-[400px]" | ||
> | ||
<h3 className="text-md font-semibold -mt-1 pr-7">{title}</h3> | ||
<div className="w-full"> | ||
<Image | ||
src={cover} | ||
alt={title} | ||
width={400} | ||
height={150} | ||
quality={80} | ||
className="w-full rounded-md object-cover h-[180px] border" | ||
/> | ||
</div> | ||
<p className="text-sm text-muted-foreground">{description}</p> | ||
<div className="flex items-center justify-between w-full mt-auto"> | ||
<p className="text-[13px] text-muted-foreground"> | ||
Published on {formatDate2(date)} | ||
</p> | ||
<AvatarGroup users={authors} /> | ||
</div> | ||
</Link> | ||
); | ||
} | ||
|
||
function AvatarGroup({ users, max = 4 }: { users: Author[]; max?: number }) { | ||
const displayUsers = users.slice(0, max); | ||
const remainingUsers = Math.max(users.length - max, 0); | ||
|
||
return ( | ||
<div className="flex items-center"> | ||
{displayUsers.map((user, index) => ( | ||
<Avatar | ||
key={user.username} | ||
className={`inline-block border-2 w-9 h-9 border-background ${ | ||
index !== 0 ? "-ml-3" : "" | ||
} `} | ||
> | ||
<AvatarImage src={user.avatar} alt={user.username} /> | ||
<AvatarFallback> | ||
{user.username.slice(0, 2).toUpperCase()} | ||
</AvatarFallback> | ||
</Avatar> | ||
))} | ||
{remainingUsers > 0 && ( | ||
<Avatar className="-ml-3 inline-block border-2 border-background hover:translate-y-1 transition-transform"> | ||
<AvatarFallback>+{remainingUsers}</AvatarFallback> | ||
</Avatar> | ||
)} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import DocsBreadcrumb from "@/components/docs-breadcrumb"; | ||
import Pagination from "@/components/pagination"; | ||
import Toc from "@/components/toc"; | ||
import { page_routes } from "@/lib/routes-config"; | ||
import { notFound } from "next/navigation"; | ||
import { getDocsForSlug } from "@/lib/markdown"; | ||
import { Typography } from "@/components/typography"; | ||
|
||
type PageProps = { | ||
params: { slug: string[] }; | ||
}; | ||
|
||
export default async function DocsPage({ params: { slug = [] } }: PageProps) { | ||
const pathName = slug.join("/"); | ||
const res = await getDocsForSlug(pathName); | ||
|
||
if (!res) notFound(); | ||
return ( | ||
<div className="flex items-start gap-10"> | ||
<div className="flex-[4.5] pt-10"> | ||
<DocsBreadcrumb paths={slug} /> | ||
<Typography> | ||
<h1 className="text-3xl !-mt-0.5">{res.frontmatter.title}</h1> | ||
<p className="-mt-4 text-muted-foreground text-[16.5px]"> | ||
{res.frontmatter.description} | ||
</p> | ||
<div>{res.content}</div> | ||
<Pagination pathname={pathName} /> | ||
</Typography> | ||
</div> | ||
<Toc path={pathName} /> | ||
</div> | ||
); | ||
} | ||
|
||
export async function generateMetadata({ params: { slug = [] } }: PageProps) { | ||
const pathName = slug.join("/"); | ||
const res = await getDocsForSlug(pathName); | ||
if (!res) return null; | ||
const { frontmatter } = res; | ||
return { | ||
title: frontmatter.title, | ||
description: frontmatter.description, | ||
}; | ||
} | ||
|
||
export function generateStaticParams() { | ||
return page_routes.map((item) => ({ | ||
slug: item.href.split("/").slice(1), | ||
})); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Leftbar } from "@/components/leftbar"; | ||
|
||
export default function DocsLayout({ | ||
children, | ||
}: Readonly<{ | ||
children: React.ReactNode; | ||
}>) { | ||
return ( | ||
<div className="flex items-start gap-8"> | ||
<Leftbar key="leftbar" /> | ||
<div className="flex-[5.25]">{children}</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
"use client"; // Error components must be Client Components | ||
|
||
import { Button, buttonVariants } from "@/components/ui/button"; | ||
import Link from "next/link"; | ||
import { useEffect } from "react"; | ||
|
||
export default function Error({ | ||
error, | ||
reset, | ||
}: { | ||
error: Error & { digest?: string }; | ||
reset: () => void; | ||
}) { | ||
useEffect(() => { | ||
console.error(error); | ||
}, [error]); | ||
|
||
return ( | ||
<div className="min-h-[87vh] px-2 sm:py-28 py-36 flex flex-col gap-4 items-center"> | ||
<div className="text-center flex flex-col items-center justify-center w-fit gap-2"> | ||
<h2 className="text-7xl font-bold pr-1">Oops!</h2> | ||
<p className="text-muted-foreground text-md font-medium"> | ||
Something went wrong {":`("} | ||
</p> | ||
<p> | ||
We're sorry, but an error occurred while processing your request. | ||
</p> | ||
</div> | ||
<div className="flex items-center gap-2"> | ||
<Button | ||
onClick={ | ||
// Attempt to recover by trying to re-render the segment | ||
() => reset() | ||
} | ||
> | ||
Reload page | ||
</Button> | ||
<Link href="/" className={buttonVariants({})}> | ||
Back to homepage | ||
</Link> | ||
</div> | ||
</div> | ||
); | ||
} |
Binary file not shown.
Oops, something went wrong.