-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: working reference projects in nextjs
- Loading branch information
1 parent
7407855
commit 2ceca58
Showing
47 changed files
with
908 additions
and
310 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
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
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,18 @@ | ||
import { FullDoc } from "../docParser.js"; | ||
|
||
export const DocArticle = ({ article }: { article: FullDoc }) => { | ||
return ( | ||
<div className="ml-24 mt-[1em] mr-4"> | ||
<h1 className="text-white font-medium text-4xl mb-8"> | ||
{article?.title} | ||
</h1> | ||
|
||
<article | ||
className="mb-4 prose prose-lg prose-invert" | ||
dangerouslySetInnerHTML={{ | ||
__html: article?.html, | ||
}} | ||
></article> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { colorVariants } from "@use-miller/shared-frontend-tooling"; | ||
import clsx from "clsx"; | ||
import { useRouter } from "next/router.js"; | ||
import { LeftMenuItem } from "./LeftMenuItem.js"; | ||
|
||
export type MenuItem = { | ||
name: string; | ||
path: string; | ||
}; | ||
export type MenuSection = { | ||
name: string; | ||
items: MenuItem[]; | ||
}; | ||
|
||
const isCurrentMenuItem = (path: string, item: MenuItem) => { | ||
// special case for the docs route | ||
if (path === "/docs" && item.path === "/docs/get-started-installation") | ||
return true; | ||
|
||
return item.path === path; | ||
}; | ||
|
||
export function LeftMenu({ menuSections }: { menuSections: MenuSection[] }) { | ||
const path = useRouter(); | ||
|
||
return ( | ||
<div className="flex"> | ||
<div className="flex flex-col flex-grow ml-4 pt-[1em]"> | ||
<h1 | ||
className={clsx( | ||
`mb-8 font-bold uppercase`, | ||
colorVariants["green"].foreground | ||
)} | ||
> | ||
Docs | ||
</h1> | ||
{menuSections?.map((section) => ( | ||
<div key={section.name}> | ||
<h3 className="mb-2 font-bold text-white uppercase"> | ||
{section.name} | ||
</h3> | ||
<ul className="mr-4"> | ||
{section.items.map((item) => ( | ||
<LeftMenuItem | ||
key={item.path} | ||
item={item} | ||
isCurrent={isCurrentMenuItem( | ||
path.asPath, | ||
item | ||
)} | ||
/> | ||
))} | ||
</ul> | ||
</div> | ||
))} | ||
</div> | ||
<div className="flex flex-col"> | ||
<div | ||
style={{ | ||
background: "linear-gradient(#56d364, #00bcd4)", | ||
}} | ||
className="h-full w-[2px]" | ||
> | ||
| ||
</div> | ||
</div> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { colorVariants } from "@use-miller/shared-frontend-tooling"; | ||
import clsx from "clsx"; | ||
import Link from "next/link.js"; | ||
import { MenuItem } from "./LeftMenu.js"; | ||
|
||
export function LeftMenuItem({ | ||
item, | ||
isCurrent, | ||
}: { | ||
item: MenuItem; | ||
isCurrent: boolean; | ||
}) { | ||
return ( | ||
<li | ||
key={item.path} | ||
className={clsx( | ||
"px-2 mb-2 ml-1 text-sm text-white whitespace-nowrap", | ||
{ | ||
[colorVariants["green"].backgroundShade]: isCurrent, | ||
["rounded-md"]: isCurrent, | ||
} | ||
)} | ||
> | ||
<Link | ||
href={item.path} | ||
className={clsx("cursor-pointer", { | ||
[colorVariants["green"].foreground]: isCurrent, | ||
})} | ||
> | ||
{item.name} | ||
</Link> | ||
</li> | ||
); | ||
} |
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,49 @@ | ||
import { | ||
getAllCourses, | ||
MenuItem, | ||
MenuSection, | ||
} from "@use-miller/shared-frontend-tooling"; | ||
import { getSortedPostsData } from "./docParser.js"; | ||
|
||
export async function createMenu(): Promise<MenuSection[]> { | ||
if (fetch === undefined) { | ||
throw new Error("fetch is undefined"); | ||
} | ||
const projects = await getAllCourses({ | ||
apiBase: process.env.NEXT_PUBLIC_API_BASE_PATH, | ||
fetchApi: fetch, | ||
}); | ||
const allArticles = getSortedPostsData(); | ||
|
||
const menuSections: MenuSection[] = [ | ||
{ | ||
// get started first! | ||
name: "Get Started", | ||
items: | ||
allArticles | ||
.filter((p) => p.section === "Get Started") | ||
.sort((a, b) => a.order - b.order) | ||
.map((post) => { | ||
return { | ||
name: post.title, | ||
path: `/docs/${post.slug}`, | ||
} as MenuItem; | ||
}) || [], | ||
}, | ||
{ | ||
// then the project references | ||
name: "Projects", | ||
items: | ||
projects.map((project) => { | ||
return { | ||
name: project.name, | ||
path: `/docs/reference/${project.key}/${btoa( | ||
"/README.md" | ||
)}`, | ||
} as MenuItem; | ||
}) || [], | ||
}, | ||
]; | ||
|
||
return menuSections; | ||
} |
File renamed without changes
File renamed without changes.
File renamed without changes.
Oops, something went wrong.