Skip to content
This repository has been archived by the owner on Sep 8, 2024. It is now read-only.

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
noxify committed Jan 2, 2024
1 parent 6e7ce8b commit aad035d
Show file tree
Hide file tree
Showing 20 changed files with 1,192 additions and 175 deletions.
File renamed without changes.
18 changes: 18 additions & 0 deletions apps/content/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "@acme/content",
"version": "0.1.0",
"private": true,
"devDependencies": {
"@acme/eslint-config": "workspace:*",
"@acme/prettier-config": "workspace:*",
"eslint": "8.56.0",
"prettier": "3.1.1"
},
"eslintConfig": {
"root": true,
"extends": [
"@acme/eslint-config/base"
]
},
"prettier": "@acme/prettier-config"
}
2 changes: 1 addition & 1 deletion apps/docs/src/content/test.md → apps/content/test.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Hello World
description: A short summary about this awesome page
---

Corporis cognosces Peleus tibi
Corporis cognosces Peleus tibi test

## Spes terra illis cum silvas gaudere videtque

Expand Down
2 changes: 2 additions & 0 deletions apps/docs/next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Importing env files here to validate on build
import "./src/env.mjs"
//import { withNextDevtools } from '@next-devtools/core/plugin'

/** @type {import("next").NextConfig} */
const config = {
Expand All @@ -13,4 +14,5 @@ const config = {
typescript: { ignoreBuildErrors: true },
}

//export default withNextDevtools(config)
export default config
4 changes: 3 additions & 1 deletion apps/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
},
"dependencies": {
"@acme/markdoc-base": "workspace:*",
"@acme/helpers": "workspace:*",
"@acme/ui": "workspace:*",
"@t3-oss/env-nextjs": "0.7.1",
"@tanstack/query-core": "5.17.0",
Expand All @@ -25,7 +26,8 @@
"p-map": "7.0.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"zod": "3.22.4"
"zod": "3.22.4",
"@next-devtools/core": "0.1.2"
},
"devDependencies": {
"@acme/eslint-config": "workspace:*",
Expand Down
53 changes: 53 additions & 0 deletions apps/docs/src/app/[...slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import path from "path"
import React from "react"
import { notFound } from "next/navigation"

import { getProjectRoot } from "@acme/helpers"
import {
components,
getAllDocuments,
getDocument,
Markdoc,
parseContent,
} from "@acme/markdoc-base"

interface DocPageProps {
params: {
slug: string[]
}
}

async function getContentPath() {
const projectDirectory = await getProjectRoot()
if (!projectDirectory) throw "Unable to determine the project root directory."

return path.join(projectDirectory, "apps/content")
}
export async function generateStaticParams(): Promise<
DocPageProps["params"][]
> {
const contentPath = await getContentPath()
const documents = await getAllDocuments(path.resolve(contentPath))

return documents.map((ele) => ({ slug: ele.slug }))
}

export default async function DocsPage({ params }: DocPageProps) {
const contentPath = await getContentPath()

const parsedParams = `/${params.slug.join("/")}`

const document = await getDocument(contentPath, parsedParams)

if (!document) notFound()

const pageContent = await parseContent(document.docPath)

if (!pageContent) notFound()

return (
<main className="">
{Markdoc.renderers.react(pageContent.content, React, { components })}
</main>
)
}
48 changes: 0 additions & 48 deletions apps/docs/src/app/docs/[...slug]/page.tsx

This file was deleted.

4 changes: 4 additions & 0 deletions apps/docs/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import type { Metadata } from "next"

//import { NextDevtoolsProvider } from "@next-devtools/core"

import { Logo, SidebarNavigation, TailwindIndicator } from "@acme/ui/components"

import "@acme/ui/style.css"
Expand All @@ -17,6 +19,7 @@ export default function Layout({ children }: { children: React.ReactNode }) {
<html lang="en" suppressHydrationWarning={true}>
<head />
<body>
{/* <NextDevtoolsProvider> */}
<Providers defaultTheme="dark" enableSystem disableTransitionOnChange>
<div className="relative flex flex-col">
<header className="sticky top-0 z-50 w-full border-b bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60">
Expand Down Expand Up @@ -52,6 +55,7 @@ export default function Layout({ children }: { children: React.ReactNode }) {
</div>
<TailwindIndicator />
</Providers>
{/* </NextDevtoolsProvider> */}
</body>
</html>
)
Expand Down
18 changes: 2 additions & 16 deletions apps/docs/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
import path from "path"
import React from "react"
import { notFound } from "next/navigation"

import { components, Markdoc, parseContent } from "@acme/markdoc-base"

export default async function HomePage() {
const filePath = path.join(path.resolve(), "./src/content/test.md")

const pageContent = await parseContent(filePath)

if (!pageContent) notFound()

return (
<main className="">
{Markdoc.renderers.react(pageContent.content, React, { components })}
</main>
)
export default function HomePage() {
return <main className="">Homepage</main>
}
57 changes: 0 additions & 57 deletions apps/docs/src/utils/content.ts

This file was deleted.

2 changes: 1 addition & 1 deletion apps/docs/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
],
"tsBuildInfoFile": "node_modules/.cache/tsbuildinfo.json"
},
"include": [".", ".next/types/**/*.ts"],
"include": ["**/*.ts", "**/*.mjs", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
}
3 changes: 2 additions & 1 deletion packages/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { cn } from "./src/cn"
export * from "./src/cn"
export * from "./src/root-dir"
4 changes: 3 additions & 1 deletion packages/helpers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@
"dependencies": {
"clsx": "2.1.0",
"tailwind-merge": "2.2.0",
"tailwindcss": "3.4.0"
"tailwindcss": "3.4.0",
"pkg-dir": "8.0.0"
},
"devDependencies": {
"@types/node": "20.10.6",
"@acme/eslint-config": "workspace:*",
"@acme/prettier-config": "workspace:*",
"@acme/tsconfig": "workspace:*",
Expand Down
5 changes: 5 additions & 0 deletions packages/helpers/src/root-dir.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { packageDirectory } from "pkg-dir"

export const getProjectRoot = async () => {
return await packageDirectory()
}
2 changes: 2 additions & 0 deletions packages/markdoc-base/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ import { components, config } from "./src/config"
export { Markdoc, config, components }

export * from "./src/helpers"
export * from "./src/frontmatter"
export * from "./src/documents"
5 changes: 4 additions & 1 deletion packages/markdoc-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
"@markdoc/markdoc": "0.4.0",
"string-strip-html": "13.4.4",
"zod": "3.22.4",
"zod-matter": "0.1.1"
"zod-matter": "0.1.1",
"p-map": "7.0.1",
"globby": "14.0.0",
"react": "18.2.0"
},
"devDependencies": {
"@acme/eslint-config": "workspace:*",
Expand Down
8 changes: 4 additions & 4 deletions packages/markdoc-base/src/components/table-of-contents.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Source: https://github.com/shadcn/ui/blob/main/apps/www/components/toc.tsx
"use client"

import * as React from "react"
import { useEffect, useMemo, useState } from "react"

import { cn } from "@acme/helpers"

Expand All @@ -18,7 +18,7 @@ interface TreeProps {
}

export function TableOfContents({ toc }: TocProps) {
const itemIds = React.useMemo(
const itemIds = useMemo(
() =>
toc
? toc
Expand All @@ -39,9 +39,9 @@ export function TableOfContents({ toc }: TocProps) {
}

function useActiveItem(itemIds: string[]) {
const [activeId, setActiveId] = React.useState<string>("")
const [activeId, setActiveId] = useState<string>("")

React.useEffect(() => {
useEffect(() => {
const observer = new IntersectionObserver(
(entries) => {
entries.forEach((entry) => {
Expand Down
Loading

0 comments on commit aad035d

Please sign in to comment.