Skip to content

Commit

Permalink
Update to the documentation site (#541)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexasselin008 authored Dec 5, 2024
2 parents 388f597 + 2d5bb7f commit a299ef4
Show file tree
Hide file tree
Showing 80 changed files with 2,974 additions and 2,634 deletions.
Binary file added apps/docs/app/apple-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
73 changes: 44 additions & 29 deletions apps/docs/app/components/[...slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,39 +1,30 @@
import { notFound } from "next/navigation";

import Heading from "@/app/ui/components/heading/Heading.tsx";
import Aside from "@/app/ui/layout/aside/Aside.tsx";
import SubHeader from "@/app/ui/layout/subHeader/SubHeader.tsx";

import { getComponentDetails } from "@/app/lib/getComponentDetails.ts";
import getSectionLinks from "@/app/lib/getSectionLinks.ts";
import Heading from "@/app/ui/components/heading/Heading.tsx";
import { BasePageLayout } from "@/app/ui/layout/basePageLayout/BasePageLayout";
import { notFound } from "next/navigation";

interface PageProps {
params: {
slug: string[];
};
}

export async function generateStaticParams(): Promise<PageProps["params"][]> {
const componentsDetails = await getComponentDetails();
async function findComponentFromSlug(params : { slug: string[] }) {
const [type] = params.slug;

return componentsDetails.map(({ slugs }) => {
const [, type] = slugs;
return (await getComponentDetails()).find(componentDetail => {
// the path should be the component name, but the content files are classified by sections
const [, componentSlugType] = componentDetail.slugs;

return ({
slug: [type]
});
return componentSlugType === type;
});
}

export default async function ComponentPage({ params }: PageProps) {
const [type] = params.slug;

const component = (await getComponentDetails()).find(componentDetail => {
// the path should be the component name, but the content files are classified by sections
const [, componentSlugType] = componentDetail.slugs;

return componentSlugType === type;
});
const component = await findComponentFromSlug(params);

if (!component) {
notFound();
Expand Down Expand Up @@ -69,16 +60,40 @@ export default async function ComponentPage({ params }: PageProps) {

return (
<div className="hd-section">
<SubHeader links={sectionLinks} />
<div className="hd-container">
{type !== "component-list" && <Aside title="On this page" links={sectionLinks} />}
<main>
<Heading title={title} tag={status} description={description} links={componentLinks} />
<div className="hd-content">
{content}
</div>
</main>
</div>
<BasePageLayout showSections={type !== "component-list"} sectionsLinks={sectionLinks}>
<Heading title={title} tag={status} description={description} links={componentLinks} />
<div className="hd-content">
{content}
</div>
</BasePageLayout>
</div>
);
}

export async function generateMetadata({ params }: PageProps) {
const component = await findComponentFromSlug(params);
if (component) {
const { frontmatter: { title } } = component;

return {
title: `${title}`
};
}

return {
title: null
};
}


export async function generateStaticParams() {
const componentsDetails = await getComponentDetails();

return componentsDetails.map(({ slugs }) => {
const [, type] = slugs;

return ({
slug: [type]
});
});
}
24 changes: 7 additions & 17 deletions apps/docs/app/components/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
import type { ReactNode } from "react";
import Sidebar from "@/app/ui/layout/sidebar/Sidebar";
import Wrapper from "@/app/ui/layout/wrapper/Wrapper";
import { SidebarProvider } from "@/context/sidebar/SidebarProvider";
import { type ComponentData, getComponentDetails } from "@/app/lib/getComponentDetails.ts";
import { getComponentDetails } from "@/app/lib/getComponentDetails.ts";
import getPageLinks from "@/app/lib/getPageLinks.ts";
import { SidebarLayout } from "@/app/ui/layout/sidebarLayout";
import type { ReactNode } from "react";

interface Data {
frontmatter: ComponentData;
slugs: string[];
content: ReactNode;
}

function formatComponentData(data: Data[]) {
function formatComponentData(data: Awaited<ReturnType<typeof getComponentDetails>>) {
return data.map((component, index) => {
const { slugs, frontmatter: { title, order, status } } = component;
let section = "";
Expand Down Expand Up @@ -56,12 +49,9 @@ async function ComponentsLayout({ children }: { children: ReactNode }) {
] });

return (
<SidebarProvider>
<Wrapper type="with-sidebar">
<Sidebar links={links} />
{children}
</Wrapper>
</SidebarProvider>
<SidebarLayout links={links}>
{children}
</SidebarLayout>
);
}

Expand Down
Binary file modified apps/docs/app/favicon.ico
Binary file not shown.
55 changes: 33 additions & 22 deletions apps/docs/app/getting-started/[...slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,42 +1,53 @@
import { allGettingStarteds } from "contentlayer/generated";
import { notFound } from "next/navigation";

import getSectionLinks from "@/app/lib/getSectionLinks.ts";
import Aside from "@/app/ui/layout/aside/Aside.tsx";
import { BasePageLayout } from "@/app/ui/layout/basePageLayout/BasePageLayout";
import Mdx from "@/components/mdx/Mdx.tsx";
import Title from "@/components/title/Title";
import { allGettingStarteds } from "contentlayer/generated";
import { notFound } from "next/navigation";

interface PageProps {
params: {
slug: string[];
};
}

export async function generateStaticParams() {
return allGettingStarteds.map(({ section }) => ({
slug: [section]
}));
function findPageFromSlug(slug: string[]) {
const [section, type] = slug;

return allGettingStarteds.find(page => page.section === section && page.slug === type);
}

export default function IconPage({ params }: PageProps) {
const [section, type] = params.slug;
const pages = allGettingStarteds.find(page => page.slug === type && page.section === section);
export default function GettingStartedPage({ params }: PageProps) {
const page = findPageFromSlug(params.slug);

if (!pages) {
if (!page) {
notFound();
}

const sectionLinks = getSectionLinks(pages);
const sectionLinks = getSectionLinks(page);
const { title, body: { code }, _id: id } = page;

return (
<div className="hd-container">
<Aside title="On this page" links={sectionLinks} />
<main>
<article className="hd-content" key={pages._id}>
<Title as="h1">{pages.title}</Title>
<Mdx code={pages.body.code} />
</article>
</main>
</div>
<BasePageLayout sectionsLinks={sectionLinks}>
<article className="hd-content" key={id}>
<Title level={1}>{title}</Title>
<Mdx code={code} />
</article>
</BasePageLayout>
);
}


export async function generateStaticParams() {
return allGettingStarteds.map(({ section, slug }) => ({
slug: [section, slug]
}));
}

export async function generateMetadata({ params }: PageProps) {
const page = await findPageFromSlug(params.slug);

return {
title: page ? `${page.title}` : null
};
}
30 changes: 5 additions & 25 deletions apps/docs/app/getting-started/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,36 +1,16 @@
"use client";

import getPageLinks from "@/app/lib/getPageLinks";
import getSectionLinks from "@/app/lib/getSectionLinks";
import Sidebar from "@/app/ui/layout/sidebar/Sidebar";
import SubHeader from "@/app/ui/layout/subHeader/SubHeader";
import Wrapper from "@/app/ui/layout/wrapper/Wrapper";
import { SidebarProvider } from "@/context/sidebar/SidebarProvider";
import { SidebarLayout } from "@/app/ui/layout/sidebarLayout";
import { allGettingStarteds } from "contentlayer/generated";
import { notFound, useSelectedLayoutSegment } from "next/navigation";
import type { ReactNode } from "react";

export default function GettingStartedLayout({ children }: { children: ReactNode }) {
const selectedLayoutSegment = useSelectedLayoutSegment();
const [section, type] = selectedLayoutSegment?.split("/") ?? ["", ""];

const pageContent = allGettingStarteds.find(page => page.slug === type && page.section === section);
if (!pageContent) {
return notFound();
}

const sectionLinks = getSectionLinks(pageContent);
const allGettingStartedsLinks = getPageLinks(allGettingStarteds, {
const allGettingStartedLinks = getPageLinks(allGettingStarteds, {
order: ["overview", "installation-path", "advanced-options", "guides"]
});

return (
<SidebarProvider>
<SubHeader links={sectionLinks} />
<Wrapper type="with-sidebar">
<Sidebar links={allGettingStartedsLinks} />
{children}
</Wrapper>
</SidebarProvider>
<SidebarLayout links={allGettingStartedLinks}>
{children}
</SidebarLayout>
);
}
43 changes: 0 additions & 43 deletions apps/docs/app/guides/[...slug]/page.tsx

This file was deleted.

41 changes: 0 additions & 41 deletions apps/docs/app/guides/layout.tsx

This file was deleted.

Loading

0 comments on commit a299ef4

Please sign in to comment.