Skip to content

Commit 5e89da6

Browse files
committed
feat: initial commit
0 parents  commit 5e89da6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+8644
-0
lines changed

.gitignore

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# next.js
12+
/.next/
13+
/out/
14+
15+
# production
16+
/build
17+
18+
# misc
19+
.DS_Store
20+
*.pem
21+
22+
# debug
23+
npm-debug.log*
24+
yarn-debug.log*
25+
yarn-error.log*
26+
27+
# local env files
28+
.env*.local
29+
30+
# vercel
31+
.vercel
32+
33+
# typescript
34+
*.tsbuildinfo
35+
next-env.d.ts
36+
37+
.contentlayer

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
## Getting started
2+
3+
`ada-url.com` requires Node.js 20 with [pnpm](https://pnpm.io) to install dependencies.
4+
5+
- To install `pnpm` follow the steps in https://pnpm.io/installation.
6+
- To build locally, run `pnpm install` in the root repository and navigate to `http://localhost:3000`
7+
- To run the linter, run `pnpm run lint-fix`
8+
9+
## Documentation
10+
11+
All documentation lives inside `contents/docs` folder
12+
13+
## Credits
14+
15+
- Components of this website is developed by `ui.shadcn.com`

app/docs/[[...slug]]/mdx.css

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
[data-theme="light"] {
2+
display: block;
3+
}
4+
5+
[data-theme="dark"] {
6+
display: none;
7+
}
8+
9+
.dark [data-theme="light"] {
10+
display: none;
11+
}
12+
13+
.dark [data-theme="dark"] {
14+
display: block;
15+
}
16+
17+
[data-rehype-pretty-code-fragment] {
18+
@apply relative;
19+
}
20+
21+
[data-rehype-pretty-code-fragment] code {
22+
@apply grid min-w-full break-words rounded-none border-0 bg-transparent p-0;
23+
counter-reset: line;
24+
box-decoration-break: clone;
25+
}
26+
27+
[data-rehype-pretty-code-fragment] .line {
28+
@apply px-4 min-h-[1rem] py-0.5 w-full inline-block;
29+
}
30+
31+
[data-rehype-pretty-code-fragment] [data-line-numbers] .line {
32+
@apply px-2;
33+
}
34+
35+
[data-rehype-pretty-code-fragment] [data-line-numbers] > .line::before {
36+
@apply text-muted-foreground/40 text-xs;
37+
counter-increment: line;
38+
content: counter(line);
39+
display: inline-block;
40+
width: 1.8rem;
41+
margin-right: 1.4rem;
42+
text-align: right;
43+
}
44+
45+
[data-rehype-pretty-code-fragment] .line--highlighted {
46+
@apply bg-muted;
47+
}
48+
49+
[data-rehype-pretty-code-fragment] .line-highlighted span {
50+
@apply relative;
51+
}
52+
53+
[data-rehype-pretty-code-fragment] .word--highlighted {
54+
@apply rounded-md bg-muted border-muted border p-1;
55+
}
56+
57+
.dark [data-rehype-pretty-code-fragment] .word--highlighted {
58+
@apply bg-zinc-900;
59+
}
60+
61+
[data-rehype-pretty-code-title] {
62+
@apply mt-2 pt-6 px-4 text-sm font-medium;
63+
}
64+
65+
[data-rehype-pretty-code-title] + pre {
66+
@apply mt-2;
67+
}

app/docs/[[...slug]]/page.tsx

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
import { allDocs } from 'contentlayer/generated'
2+
import { notFound } from 'next/navigation'
3+
4+
import './mdx.css'
5+
import { ChevronRight } from 'lucide-react'
6+
import type { Metadata } from 'next'
7+
import Link from 'next/link'
8+
import Balancer from 'react-wrap-balancer'
9+
10+
import { Icons } from '@/components/icons'
11+
import { Mdx } from '@/components/mdx-components'
12+
import { DocsPager } from '@/components/pager'
13+
import { DashboardTableOfContents } from '@/components/toc'
14+
import { badgeVariants } from '@/components/ui/badge'
15+
import { ScrollArea } from '@/components/ui/scroll-area'
16+
import { Separator } from '@/components/ui/separator'
17+
import { getTableOfContents } from '@/lib/toc'
18+
import { absoluteUrl, cn } from '@/lib/utils'
19+
20+
interface DocPageProps {
21+
params: {
22+
slug: string[]
23+
}
24+
}
25+
26+
async function getDocFromParams({ params }: DocPageProps) {
27+
const slug = params.slug?.join('/') || ''
28+
const doc = allDocs.find((doc) => doc.slugAsParams === slug)
29+
30+
if (!doc) {
31+
null
32+
}
33+
34+
return doc
35+
}
36+
37+
export async function generateMetadata({ params }: DocPageProps): Promise<Metadata> {
38+
const doc = await getDocFromParams({ params })
39+
40+
if (!doc) {
41+
return {}
42+
}
43+
44+
return {
45+
title: doc.title,
46+
description: doc.description,
47+
openGraph: {
48+
title: doc.title,
49+
description: doc.description,
50+
type: 'article',
51+
url: absoluteUrl(doc.slug),
52+
},
53+
twitter: {
54+
card: 'summary_large_image',
55+
title: doc.title,
56+
description: doc.description,
57+
images: [],
58+
},
59+
}
60+
}
61+
62+
export async function generateStaticParams(): Promise<DocPageProps['params'][]> {
63+
return allDocs.map((doc) => ({
64+
slug: doc.slugAsParams.split('/'),
65+
}))
66+
}
67+
68+
export default async function DocPage({ params }: DocPageProps) {
69+
const doc = await getDocFromParams({ params })
70+
71+
if (!doc) {
72+
notFound()
73+
}
74+
75+
const toc = await getTableOfContents(doc.body.raw)
76+
77+
return (
78+
<main className='relative py-6 lg:gap-10 lg:py-8 xl:grid xl:grid-cols-[1fr_300px]'>
79+
<div className='mx-auto w-full min-w-0'>
80+
<div className='mb-4 flex items-center space-x-1 text-sm text-muted-foreground'>
81+
<div className='overflow-hidden text-ellipsis whitespace-nowrap'>Docs</div>
82+
<ChevronRight className='h-4 w-4' />
83+
<div className='font-medium text-foreground'>{doc.title}</div>
84+
</div>
85+
<div className='space-y-2'>
86+
<h1 className={cn('scroll-m-20 text-4xl font-bold tracking-tight')}>{doc.title}</h1>
87+
{doc.description && (
88+
<p className='text-lg text-muted-foreground'>
89+
<Balancer>{doc.description}</Balancer>
90+
</p>
91+
)}
92+
</div>
93+
<Separator className='my-4 md:my-6' />
94+
<Mdx code={doc.body.code} />
95+
<Separator className='my-4 md:my-6' />
96+
<DocsPager doc={doc} />
97+
</div>
98+
<div className='hidden text-sm xl:block'>
99+
<div className='sticky top-16 -mt-10 h-[calc(100vh-3.5rem)] overflow-hidden pt-6'>
100+
<ScrollArea className='pb-10'>
101+
<DashboardTableOfContents toc={toc} />
102+
</ScrollArea>
103+
</div>
104+
</div>
105+
</main>
106+
)
107+
}

app/docs/layout.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { DocsSidebarNav } from '@/components/sidebar-nav'
2+
import { ScrollArea } from '@/components/ui/scroll-area'
3+
import { docsConfig } from '@/config/docs'
4+
import { PropsWithChildren } from 'react'
5+
6+
export default function DocsLayout({ children }: PropsWithChildren) {
7+
return (
8+
<div className='container flex-1 items-start md:grid md:grid-cols-[220px_minmax(0,1fr)] md:gap-6 lg:grid-cols-[240px_minmax(0,1fr)] lg:gap-10'>
9+
<aside className='fixed top-14 z-30 -ml-2 hidden h-[calc(100vh-3.5rem)] w-full shrink-0 overflow-y-auto border-r md:sticky md:block'>
10+
<ScrollArea className='py-6 pr-6 lg:py-8'>
11+
<DocsSidebarNav items={docsConfig.sidebarNav} />
12+
</ScrollArea>
13+
</aside>
14+
{children}
15+
</div>
16+
)
17+
}

app/favicon.ico

25.3 KB
Binary file not shown.

app/globals.css

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
@tailwind base;
2+
@tailwind components;
3+
@tailwind utilities;
4+
5+
@layer base {
6+
:root {
7+
--background: 0 0% 100%;
8+
--foreground: 222.2 47.4% 11.2%;
9+
10+
--muted: 210 40% 96.1%;
11+
--muted-foreground: 215.4 16.3% 46.9%;
12+
13+
--popover: 0 0% 100%;
14+
--popover-foreground: 222.2 47.4% 11.2%;
15+
16+
--card: 0 0% 100%;
17+
--card-foreground: 222.2 47.4% 11.2%;
18+
19+
--border: 214.3 31.8% 91.4%;
20+
--input: 214.3 31.8% 91.4%;
21+
22+
--primary: 222.2 47.4% 11.2%;
23+
--primary-foreground: 210 40% 98%;
24+
25+
--secondary: 210 40% 96.1%;
26+
--secondary-foreground: 222.2 47.4% 11.2%;
27+
28+
--accent: 210 40% 96.1%;
29+
--accent-foreground: 222.2 47.4% 11.2%;
30+
31+
--destructive: 0 100% 50%;
32+
--destructive-foreground: 210 40% 98%;
33+
34+
--ring: 215 20.2% 65.1%;
35+
36+
--radius: 0.5rem;
37+
}
38+
39+
.dark {
40+
--background: 224 71% 4%;
41+
--foreground: 213 31% 91%;
42+
43+
--muted: 223 47% 11%;
44+
--muted-foreground: 215.4 16.3% 56.9%;
45+
46+
--popover: 224 71% 4%;
47+
--popover-foreground: 215 20.2% 65.1%;
48+
49+
--card: 224 71% 4%;
50+
--card-foreground: 213 31% 91%;
51+
52+
--border: 216 34% 17%;
53+
--input: 216 34% 17%;
54+
55+
--primary: 210 40% 98%;
56+
--primary-foreground: 222.2 47.4% 1.2%;
57+
58+
--secondary: 222.2 47.4% 11.2%;
59+
--secondary-foreground: 210 40% 98%;
60+
61+
--accent: 216 34% 17%;
62+
--accent-foreground: 210 40% 98%;
63+
64+
--destructive: 0 63% 31%;
65+
--destructive-foreground: 210 40% 98%;
66+
67+
--ring: 216 34% 17%;
68+
69+
--radius: 0.5rem;
70+
}
71+
}
72+
73+
@layer base {
74+
* {
75+
@apply border-border;
76+
}
77+
body {
78+
@apply bg-background text-foreground;
79+
font-feature-settings: "rlig" 1, "calt" 1;
80+
}
81+
}

app/layout.tsx

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import './globals.css'
2+
import { SiteFooter } from '@/components/site-footer'
3+
import { SiteHeader } from '@/components/site-header'
4+
import { ThemeProvider } from '@/components/theme-provider'
5+
import { siteConfig } from '@/config/site'
6+
import { cn } from '@/lib/utils'
7+
import { Inter } from 'next/font/google'
8+
import type { PropsWithChildren } from 'react'
9+
10+
const inter = Inter({ subsets: ['latin'] })
11+
12+
export const metadata = {
13+
title: {
14+
default: 'Home',
15+
template: `%s - ${siteConfig.name}`,
16+
},
17+
description: siteConfig.description,
18+
keywords: ['WHATWG', 'URL Parser', 'Fast URL parsing', 'ada-url', 'Ada URL Parser'],
19+
authors: [
20+
{
21+
name: 'Yagiz Nizipli',
22+
url: 'https://yagiz.co',
23+
},
24+
{
25+
name: 'Daniel Lemire',
26+
url: 'https://lemire.me',
27+
},
28+
],
29+
themeColor: [
30+
{ media: '(prefers-color-scheme: light)', color: 'white' },
31+
{ media: '(prefers-color-scheme: dark)', color: 'black' },
32+
],
33+
}
34+
35+
export default function RootLayout({ children }: PropsWithChildren) {
36+
return (
37+
<html lang='en' suppressHydrationWarning>
38+
<body className={cn('min-h-screen bg-background font-sans antialiased', inter.className)}>
39+
<ThemeProvider attribute='class' defaultTheme='system' enableSystem>
40+
<div className='relative flex min-h-screen flex-col'>
41+
<SiteHeader />
42+
<div className='flex-1'>{children}</div>
43+
<SiteFooter />
44+
</div>
45+
</ThemeProvider>
46+
</body>
47+
</html>
48+
)
49+
}

0 commit comments

Comments
 (0)