Skip to content

Commit d1f2d3a

Browse files
authored
Feat/new docs (#446)
* feat: use fumadocs for site * feat: add doc contents * feat: site deploy * fixes * feat: add rhythm patterns * fix: test and build
1 parent 5d78b19 commit d1f2d3a

Some content is hidden

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

67 files changed

+6605
-11646
lines changed

package-lock.json

Lines changed: 1473 additions & 2738 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

site/.gitignore

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,28 @@
1-
# Dependencies
1+
# deps
22
/node_modules
33

4-
# Production
5-
/build
4+
# generated content
5+
.contentlayer
6+
.content-collections
7+
.source
68

7-
# Generated files
8-
.docusaurus
9-
.cache-loader
9+
# test & build
10+
/coverage
11+
/.next/
12+
/out/
13+
/build
14+
*.tsbuildinfo
1015

11-
# Misc
16+
# misc
1217
.DS_Store
13-
.env.local
14-
.env.development.local
15-
.env.test.local
16-
.env.production.local
17-
18+
*.pem
19+
/.pnp
20+
.pnp.js
1821
npm-debug.log*
1922
yarn-debug.log*
2023
yarn-error.log*
24+
25+
# others
26+
.env*.local
27+
.vercel
28+
next-env.d.ts

site/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# tonal docs
22

3-
```
4-
npm run deploy
3+
Run development server:
4+
5+
```bash
6+
pnpm dev
57
```

site/app/(home)/layout.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import type { ReactNode } from 'react';
2+
import { HomeLayout } from 'fumadocs-ui/home-layout';
3+
import { baseOptions } from '../layout.config';
4+
5+
export default function Layout({
6+
children,
7+
}: {
8+
children: ReactNode;
9+
}): React.ReactElement {
10+
return <HomeLayout {...baseOptions}>{children}</HomeLayout>;
11+
}

site/app/(home)/page.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export default function HomePage() {
2+
return (
3+
<main className="flex h-screen flex-col justify-center text-center">
4+
<h1 className="mb-4 text-2xl font-bold">tonal</h1>
5+
<p className="mb-8 text-fd-muted-foreground">A music theory library</p>
6+
</main>
7+
);
8+
}

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

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import { source } from "@/app/source";
2+
import defaultMdxComponents from "fumadocs-ui/mdx";
3+
import {
4+
DocsBody,
5+
DocsDescription,
6+
DocsPage,
7+
DocsTitle,
8+
} from "fumadocs-ui/page";
9+
import type { Metadata } from "next";
10+
import { notFound } from "next/navigation";
11+
12+
export default async function Page({
13+
params,
14+
}: {
15+
params: { slug?: string[] };
16+
}) {
17+
const page = source.getPage(params.slug);
18+
if (!page) notFound();
19+
20+
const MDX = page.data.body;
21+
22+
return (
23+
<DocsPage toc={page.data.toc} full={page.data.full}>
24+
<DocsTitle>{page.data.title}</DocsTitle>
25+
{page.data.package ? (
26+
<div className="flex">
27+
<a
28+
href={`https://www.npmjs.com/package/@tonaljs/${page.data.package}`}
29+
>
30+
<img
31+
className="rounded-lg"
32+
src={`https://img.shields.io/badge/@tonaljs-${page.data.package.replace("-", "--")}-yellow.svg?style=flat-square`}
33+
/>
34+
</a>
35+
</div>
36+
) : null}
37+
<DocsDescription>{page.data.description}</DocsDescription>
38+
<DocsBody>
39+
<MDX components={{ ...defaultMdxComponents }} />
40+
</DocsBody>
41+
</DocsPage>
42+
);
43+
}
44+
45+
export async function generateStaticParams() {
46+
return source.generateParams();
47+
}
48+
49+
export function generateMetadata({ params }: { params: { slug?: string[] } }) {
50+
const page = source.getPage(params.slug);
51+
if (!page) notFound();
52+
53+
return {
54+
title: page.data.title,
55+
description: page.data.description,
56+
} satisfies Metadata;
57+
}

site/app/docs/layout.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { DocsLayout } from 'fumadocs-ui/layout';
2+
import type { ReactNode } from 'react';
3+
import { baseOptions } from '../layout.config';
4+
import { source } from '@/app/source';
5+
6+
export default function Layout({ children }: { children: ReactNode }) {
7+
return (
8+
<DocsLayout tree={source.pageTree} {...baseOptions}>
9+
{children}
10+
</DocsLayout>
11+
);
12+
}

site/app/global.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@tailwind base;
2+
@tailwind components;
3+
@tailwind utilities;

site/app/layout.config.tsx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { type HomeLayoutProps } from "fumadocs-ui/home-layout";
2+
import { BookIcon, GithubIcon } from "lucide-react";
3+
4+
/**
5+
* Shared layout configurations
6+
*
7+
* you can configure layouts individually from:
8+
* Home Layout: app/(home)/layout.tsx
9+
* Docs Layout: app/docs/layout.tsx
10+
*/
11+
export const baseOptions: HomeLayoutProps = {
12+
nav: {
13+
title: "Tonal",
14+
},
15+
links: [
16+
{
17+
text: "Documentation",
18+
icon: <BookIcon />,
19+
url: "/docs",
20+
active: "nested-url",
21+
},
22+
{
23+
text: "Repository",
24+
icon: <GithubIcon />,
25+
url: "https://github.com/tonaljs/tonal",
26+
},
27+
],
28+
};

site/app/layout.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { RootProvider } from "fumadocs-ui/provider";
2+
import { Inter } from "next/font/google";
3+
import type { ReactNode } from "react";
4+
import "./global.css";
5+
6+
const inter = Inter({
7+
subsets: ["latin"],
8+
});
9+
10+
export default function Layout({ children }: { children: ReactNode }) {
11+
return (
12+
<html lang="en" className={inter.className} suppressHydrationWarning>
13+
<body>
14+
<RootProvider search={{ enabled: false }}>{children}</RootProvider>
15+
</body>
16+
</html>
17+
);
18+
}

0 commit comments

Comments
 (0)