Skip to content

Commit 8f6a325

Browse files
committed
✅ Docs structure
1 parent e442086 commit 8f6a325

File tree

19 files changed

+2551
-36
lines changed

19 files changed

+2551
-36
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,6 @@ yarn-error.log*
3434
# typescript
3535
*.tsbuildinfo
3636
next-env.d.ts
37+
38+
# contentlayer
39+
.contentlayer

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

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import React from "react";
2+
import { allDocs } from "contentlayer/generated";
3+
import { notFound } from "next/navigation";
4+
import {format} from "date-fns"
5+
import MDX from "@/components/MDX";
6+
import { H1, H2, H3, H4 } from "@/packages/ui";
7+
8+
async function getDocParams(slug: string) {
9+
const doc = allDocs.find((doc) => doc.url === slug);
10+
11+
if (!doc) {
12+
return null;
13+
}
14+
15+
return doc;
16+
}
17+
18+
export default async function page({ params }: { params: { slug: string[] } }) {
19+
const slug = params.slug?.join("/") || "/docs";
20+
const doc = await getDocParams(slug);
21+
22+
if (!doc) {
23+
return notFound();
24+
}
25+
26+
return (
27+
<div className="space-y-12 pb-8">
28+
<div>
29+
<H2>{doc.title}</H2>
30+
<p className="text-lg text-muted">{doc.description}</p>
31+
</div>
32+
<div>
33+
<MDX code={doc.body.code} />
34+
</div>
35+
<p className="text-right">Last Updated: {format(doc.lastUpdated, "dd MMM, YYY")}</p>
36+
</div>
37+
);
38+
}

app/(docs)/docs/layout.tsx

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
1-
import SideNav from '@/components/SideNav'
2-
import React from 'react'
1+
import SideNav from "@/components/SideNav";
2+
import { Metadata } from "next";
33

4-
export default function layout() {
4+
export const metadata: Metadata = {
5+
title: "Getting Started | RetroUI",
6+
};
7+
8+
export default function ComponentLayout({
9+
children,
10+
}: Readonly<{
11+
children: React.ReactNode;
12+
}>) {
513
return (
6-
<div>
14+
<div className="relative">
15+
<div className="hidden lg:block">
716
<SideNav />
8-
layout</div>
9-
)
10-
}
17+
</div>
18+
<div className="lg:ml-72 mt-20 px-4">{children}</div>
19+
</div>
20+
);
21+
}

app/(docs)/docs/page.tsx

Lines changed: 0 additions & 7 deletions
This file was deleted.

app/global.css

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@
22
@tailwind components;
33
@tailwind utilities;
44

5+
:root {
6+
--muted: #606067;
7+
}
8+
59
.text-outlined {
6-
@apply relative text-primary-400 font-bold;
7-
letter-spacing: 2px;
8-
text-shadow: -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000, 2px 2px 0 #000; /* Black outline */
9-
}
10+
@apply relative text-primary-400 font-bold;
11+
letter-spacing: 2px;
12+
text-shadow: -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000,
13+
2px 2px 0 #000; /* Black outline */
14+
}

components/MDX.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { H1, H2, H3, H4, H5, H6 } from "@/packages/ui";
2+
import { useMDXComponent } from "next-contentlayer/hooks";
3+
import React from "react";
4+
5+
const components = {
6+
h1: H1,
7+
h2: H2,
8+
h3: H3,
9+
h4: H4,
10+
h5: H5,
11+
h6: H6,
12+
};
13+
14+
export default function MDX({ code }: { code: string }) {
15+
const Content = useMDXComponent(code);
16+
17+
return <Content components={components} />;
18+
}

content/docs/index.mdx

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
---
2+
title: Getting Started
3+
description: This guide will help you get started with RetroUI, a retro styled UI library based on Tailwind CSS.
4+
lastUpdated: 29 Sep, 2024
5+
---
6+
7+
### 1. Add the fonts
8+
We are useing `Archivo Black` for headings and `Share Tech` for everything else.
9+
10+
Installation form Google Fonts:
11+
```
12+
<link rel="preconnect" href="https://fonts.googleapis.com">
13+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
14+
<link href="https://fonts.googleapis.com/css2?family=Archivo+Black&family=Share+Tech&display=swap" rel="stylesheet">
15+
```
16+
17+
Save the fonts in `global.css`:
18+
```
19+
:root {
20+
--font-head: "Archivo Black", sans-serif;
21+
--font-sans: "Share Tech", sans-serif;
22+
}
23+
```
24+
25+
<br />
26+
27+
### 2. Add the theme to your tailwind.config.js file.
28+
```
29+
import type { Config } from "tailwindcss";
30+
31+
const config = {
32+
theme: {
33+
extend: {
34+
fontFamily: {
35+
head: ["var(--font-head)"],
36+
sans: ["var(--font-sans)"],
37+
},
38+
boxShadow: {
39+
"xs": "1px 1px 0 0 #000",
40+
"md": "3px 3px 0 0 #000",
41+
"3xl": "10px 10px 0 0 #000",
42+
},
43+
colors: {
44+
primary: {
45+
50: "#FFFEF0",
46+
100: "#FEF9C3",
47+
200: "#FEF08A",
48+
300: "#FDE047",
49+
400: "#FACC15",
50+
500: "#EAB308",
51+
600: "#CA8A04",
52+
700: "#A16207",
53+
800: "#854D0E",
54+
900: "#713F12",
55+
},
56+
},
57+
},
58+
},
59+
};
60+
export default config;
61+
```
62+
63+
<br />
64+
65+
### 3. Now start copy-pasting the components!

contentlayer.config.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// contentlayer.config.ts
2+
import { defineDocumentType, makeSource } from "contentlayer/source-files";
3+
4+
export const Doc = defineDocumentType(() => ({
5+
name: "Doc",
6+
filePathPattern: `docs/**/*.mdx`,
7+
contentType: "mdx",
8+
fields: {
9+
title: { type: "string", required: true },
10+
description: { type: "string", required: true },
11+
lastUpdated: { type: "date", required: true },
12+
},
13+
computedFields: {
14+
url: {
15+
type: "string",
16+
resolve: (doc) => `/${doc._raw.flattenedPath}`,
17+
},
18+
},
19+
}));
20+
21+
export default makeSource({ contentDirPath: "./content", documentTypes: [Doc] });

next.config.mjs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
import { withContentlayer } from 'next-contentlayer'
2+
13
/** @type {import('next').NextConfig} */
2-
const nextConfig = {};
4+
const nextConfig = { reactStrictMode: true, swcMinify: true }
35

4-
export default nextConfig;
6+
export default withContentlayer(nextConfig)

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99
"lint": "next lint"
1010
},
1111
"dependencies": {
12+
"contentlayer": "^0.3.4",
13+
"date-fns": "^4.1.0",
1214
"lucide-react": "^0.445.0",
1315
"next": "14.2.7",
16+
"next-contentlayer": "^0.3.4",
1417
"react": "^18",
1518
"react-dom": "^18"
1619
},

0 commit comments

Comments
 (0)