-
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
7 changed files
with
320 additions
and
10 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 |
---|---|---|
@@ -1,7 +1,18 @@ | ||
import mdx from '@next/mdx'; | ||
import type { NextConfig } from 'next'; | ||
import rehypeSlug from 'rehype-slug'; | ||
import rehypeAutolinkHeadings from 'rehype-autolink-headings'; | ||
|
||
const nextConfig: NextConfig = { | ||
/* config options here */ | ||
}; | ||
const withMDX = mdx({ | ||
extension: /\.mdx?$/, | ||
options: { | ||
providerImportSource: '@mdx-js/react', | ||
rehypePlugins: [rehypeSlug, rehypeAutolinkHeadings], | ||
}, | ||
}); | ||
|
||
export default nextConfig; | ||
const nextConfig: NextConfig = withMDX({ | ||
pageExtensions: ['js', 'jsx', 'ts', 'tsx', 'md', 'mdx'], | ||
}); | ||
|
||
export default nextConfig; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,64 @@ | ||
"use client"; | ||
|
||
import { MDXProvider } from "@mdx-js/react"; | ||
import { Navbar } from "@/components/ui/navbar"; | ||
import { Footer } from "@/components/ui/footer"; | ||
import { TableOfContents } from "@/components/ui/toc"; | ||
import TermsContent from "@/data/md/terms-of-service.mdx"; | ||
|
||
const mdxComponents = { | ||
h1: (props: React.ComponentPropsWithoutRef<"h1">) => ( | ||
<h1 className="text-4xl font-bold text-black dark:text-white mb-8" {...props} /> | ||
), | ||
h2: (props: React.ComponentPropsWithoutRef<"h2">) => ( | ||
<h2 className="text-3xl font-semibold text-gray-800 dark:text-white mb-6" {...props} /> | ||
), | ||
p: (props: React.ComponentPropsWithoutRef<"p">) => ( | ||
<p className="text-black dark:text-white mb-6" {...props} /> | ||
), | ||
ul: (props: React.ComponentPropsWithoutRef<"ul">) => ( | ||
<ul className="list-disc pl-6 text-gray-700 dark:text-white mb-6" {...props} /> | ||
), | ||
a: (props: React.ComponentPropsWithoutRef<"a">) => ( | ||
<a className="text-orange-500 underline" {...props} /> | ||
), | ||
blockquote: (props: React.ComponentPropsWithoutRef<"blockquote">) => ( | ||
<blockquote | ||
className="border-l-4 border-gray-300 pl-4 italic text-gray-600 dark:text-gray-400 mb-6" | ||
{...props} | ||
/> | ||
), | ||
}; | ||
|
||
export default function TermsOfService() { | ||
return ( | ||
<div className="grid grid-rows-[auto_1fr_auto] items-center justify-items-center min-h-screen gap-8 font-[family-name:var(--font-geist-sans)]"> | ||
<Navbar /> | ||
|
||
{/* | ||
<main className="container mx-auto px-6 py-8"> | ||
<MDXProvider components={mdxComponents}> | ||
<div className="prose prose-lg max-w-3xl mx-auto text-gray-700 dark:text-gray-300"> | ||
<TermsContent /> | ||
</div> | ||
</MDXProvider> | ||
</main> | ||
*/} | ||
|
||
<main className="container mx-auto px-6 py-8"> | ||
<div className="flex"> | ||
<div className="flex-grow prose prose-lg max-w-3xl mx-auto text-gray-700 dark:text-gray-300"> | ||
<MDXProvider components={mdxComponents}> | ||
<TermsContent /> | ||
</MDXProvider> | ||
</div> | ||
<aside className="hidden lg:block ml-8"> | ||
<TableOfContents /> | ||
</aside> | ||
</div> | ||
</main> | ||
|
||
<Footer /> | ||
</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
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,60 @@ | ||
"use client"; | ||
|
||
import { useEffect, useState } from "react"; | ||
import { useInView } from "react-intersection-observer"; | ||
|
||
export function TableOfContents() { | ||
const [activeId, setActiveId] = useState<string | null>(null); | ||
|
||
useEffect(() => { | ||
if (typeof window !== "undefined") { | ||
const headings = document.querySelectorAll("h1, h2, h3"); | ||
const headingElements = Array.from(headings); | ||
|
||
const observer = new IntersectionObserver( | ||
(entries) => { | ||
const visibleHeadings = entries.filter((entry) => entry.isIntersecting); | ||
if (visibleHeadings.length > 0) { | ||
setActiveId(visibleHeadings[0].target.id); | ||
} | ||
}, | ||
{ rootMargin: "0px 0px -80% 0px" } | ||
); | ||
|
||
headingElements.forEach((element) => observer.observe(element)); | ||
|
||
return () => observer.disconnect(); | ||
} | ||
}, []); | ||
|
||
const [headings, setHeadings] = useState<Array<{ id: string, text: string, level: string }>>([]); | ||
|
||
useEffect(() => { | ||
if (typeof window !== "undefined") { | ||
const headings = Array.from(document.querySelectorAll("h1, h2, h3")).map((heading) => ({ | ||
id: heading.id, | ||
text: heading.textContent || "", | ||
level: heading.tagName.toLowerCase(), | ||
})); | ||
setHeadings(headings); | ||
} | ||
}, []); | ||
|
||
return ( | ||
<nav className="sticky top-16 max-h-screen overflow-y-auto p-4 w-72"> | ||
<h3 className="text-lg font-semibold mb-4 text-neutral-900 dark:text-white">Table of Contents</h3> | ||
<ul className="space-y-1"> | ||
{headings.map(({ id, text, level }) => ( | ||
<li | ||
key={id} | ||
className={`pl-${level === "h1" ? 4 : level === "h2" ? 6 : 8} ${ | ||
activeId === id ? "text-orange-500 font-semibold" : "text-neutral-500" | ||
}`} | ||
> | ||
<a href={`#${id}`}>{text}</a> | ||
</li> | ||
))} | ||
</ul> | ||
</nav> | ||
); | ||
} |
Oops, something went wrong.