docs: create docs workspace (#5174)
* docs: migrate ui docs to docs universe * created yarn workspace * added eslint and tsconfig configurations * fix eslint configurations * fixed eslint configurations * shared tailwind configurations * added shared ui package * added more shared components * migrating more components * made details components shared * move InlineCode component * moved InputText * moved Loading component * Moved Modal component * moved Select components * Moved Tooltip component * moved Search components * moved ColorMode provider * Moved Notification components and providers * used icons package * use UI colors in api-reference * moved Navbar component * used Navbar and Search in UI docs * added Feedback to UI docs * general enhancements * fix color mode * added copy colors file from ui-preset * added features and enhancements to UI docs * move Sidebar component and provider * general fixes and preparations for deployment * update docusaurus version * adjusted versions * fix output directory * remove rootDirectory property * fix yarn.lock * moved code component * added vale for all docs MD and MDX * fix tests * fix vale error * fix deployment errors * change ignore commands * add output directory * fix docs test * general fixes * content fixes * fix announcement script * added changeset * fix vale checks * added nofilter option * fix vale error
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
import { Text } from "@medusajs/ui"
|
||||
import { allDocs } from "contentlayer/generated"
|
||||
import { notFound } from "next/navigation"
|
||||
|
||||
import { Mdx } from "@/components/mdx-components"
|
||||
import { siteConfig } from "@/config/site"
|
||||
import { Metadata } from "next"
|
||||
|
||||
interface DocPageProps {
|
||||
params: {
|
||||
slug: string[]
|
||||
}
|
||||
}
|
||||
|
||||
async function getDocFromParams({ params }: DocPageProps) {
|
||||
const slug = params.slug?.join("/") || ""
|
||||
|
||||
const doc = allDocs.find((doc) => doc.slugAsParams === slug)
|
||||
|
||||
if (!doc) {
|
||||
null
|
||||
}
|
||||
|
||||
return doc
|
||||
}
|
||||
|
||||
export async function generateMetadata({
|
||||
params,
|
||||
}: DocPageProps): Promise<Metadata> {
|
||||
const doc = await getDocFromParams({ params })
|
||||
|
||||
if (!doc) {
|
||||
return {}
|
||||
}
|
||||
|
||||
const title = `${doc.title} - ${siteConfig.name}`
|
||||
|
||||
return {
|
||||
title: title,
|
||||
description: doc.description,
|
||||
metadataBase: new URL(
|
||||
process.env.NEXT_PUBLIC_BASE_URL || "http://localhost:3000"
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
export async function generateStaticParams(): Promise<
|
||||
DocPageProps["params"][]
|
||||
> {
|
||||
return allDocs.map((doc) => ({
|
||||
slug: doc.slugAsParams.split("/"),
|
||||
}))
|
||||
}
|
||||
|
||||
export default async function DocPage({ params }: DocPageProps) {
|
||||
const doc = await getDocFromParams({ params })
|
||||
|
||||
if (!doc) {
|
||||
notFound()
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex flex-col">
|
||||
<h1 className="h1-docs text-medusa-fg-base dark:text-medusa-fg-base-dark mb-2">
|
||||
{doc.title}
|
||||
</h1>
|
||||
<Text
|
||||
className="text-medusa-fg-subtle dark:text-medusa-fg-subtle-dark mb-6"
|
||||
size="large"
|
||||
>
|
||||
{doc.description}
|
||||
</Text>
|
||||
<div>
|
||||
<Mdx code={doc.body.code} />
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 149 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 149 KiB |
@@ -0,0 +1,34 @@
|
||||
import { MetadataRoute } from "next"
|
||||
|
||||
import { docsConfig } from "@/config/docs"
|
||||
import { absoluteUrl } from "@/lib/absolute-url"
|
||||
import { SidebarItemType } from "docs-ui"
|
||||
|
||||
export default function sitemap(): MetadataRoute.Sitemap {
|
||||
const now = new Date()
|
||||
|
||||
const items: Array<{
|
||||
url: string
|
||||
lastModified?: string | Date
|
||||
}> = []
|
||||
|
||||
function pushItems(newItems: SidebarItemType[]) {
|
||||
newItems.forEach((item) => {
|
||||
if (item.path) {
|
||||
items.push({
|
||||
url: absoluteUrl(item.path),
|
||||
lastModified: now,
|
||||
})
|
||||
}
|
||||
|
||||
if (item.children) {
|
||||
pushItems(item.children)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pushItems(docsConfig.sidebar.top)
|
||||
pushItems(docsConfig.sidebar.bottom)
|
||||
|
||||
return items
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 101 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 101 KiB |
@@ -0,0 +1,52 @@
|
||||
import type { Metadata } from "next"
|
||||
import { Inter, Roboto_Mono } from "next/font/google"
|
||||
|
||||
import { Navbar } from "@/components/navbar"
|
||||
import { Providers } from "@/providers"
|
||||
|
||||
import { siteConfig } from "@/config/site"
|
||||
import "../styles/globals.css"
|
||||
import { Sidebar } from "docs-ui"
|
||||
|
||||
const inter = Inter({ subsets: ["latin"], variable: "--inter" })
|
||||
const robotoMono = Roboto_Mono({
|
||||
subsets: ["latin"],
|
||||
variable: "--font-roboto-mono",
|
||||
})
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: siteConfig.name,
|
||||
description: siteConfig.description,
|
||||
metadataBase: new URL(
|
||||
process.env.NEXT_PUBLIC_BASE_URL || "http://localhost:3000"
|
||||
),
|
||||
}
|
||||
|
||||
export default function RootLayout({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode
|
||||
}) {
|
||||
return (
|
||||
<html lang="en" className="h-full w-full">
|
||||
<head />
|
||||
<body
|
||||
className={` bg-docs-bg dark:bg-docs-bg-dark h-screen w-full ${inter.variable} ${robotoMono.variable}`}
|
||||
>
|
||||
<Providers>
|
||||
<div className="w-full">
|
||||
<Navbar />
|
||||
<div className="max-w-xxl grid w-full grid-cols-1 px-6 lg:mx-auto lg:grid-cols-[280px_1fr]">
|
||||
<Sidebar expandItems={true} />
|
||||
<div className="relative flex w-full flex-1 items-start justify-center px-4 pb-8 pt-16 md:px-8 lg:px-16 lg:py-[112px]">
|
||||
<main className="h-full w-full lg:max-w-[720px] lg:px-px">
|
||||
{children}
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Providers>
|
||||
</body>
|
||||
</html>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
User-Agent: *
|
||||
Allow: /
|
||||
|
||||
Sitemap: https://docs.medusajs.com/ui/assets/sitemap.xml
|
||||
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||
<sitemap>
|
||||
<loc>https://docs.medusajs.com/ui/assets/sitemap.xml</loc>
|
||||
</sitemap>
|
||||
<sitemap>
|
||||
<loc>https://docs.medusajs.com/sitemap-docs.xml</loc>
|
||||
</sitemap>
|
||||
</sitemapindex>
|
||||
Reference in New Issue
Block a user