diff --git a/apps/docs/app/[lang]/[[...slug]]/page.tsx b/apps/docs/app/[lang]/[[...slug]]/page.tsx index 150326afb95..2d2d3e633f5 100644 --- a/apps/docs/app/[lang]/[[...slug]]/page.tsx +++ b/apps/docs/app/[lang]/[[...slug]]/page.tsx @@ -1,3 +1,5 @@ +import { existsSync } from 'node:fs' +import { join, relative } from 'node:path' import type React from 'react' import type { Root } from 'fumadocs-core/page-tree' import { findNeighbour } from 'fumadocs-core/page-tree' @@ -11,7 +13,7 @@ import Link from 'next/link' import { notFound } from 'next/navigation' import { PageNavigationArrows } from '@/components/docs-layout/page-navigation-arrows' import { TOCFooter } from '@/components/docs-layout/toc-footer' -import { LLMCopyButton } from '@/components/page-actions' +import { LLMCopyButton, ViewOptionsPopover } from '@/components/page-actions' import { StructuredData } from '@/components/structured-data' import { CodeBlock } from '@/components/ui/code-block' import { Heading } from '@/components/ui/heading' @@ -22,6 +24,30 @@ import { type PageData, source } from '@/lib/source' const SUPPORTED_LANGUAGES: Set = new Set(i18n.languages) const BASE_URL = 'https://docs.sim.ai' +const CONTENT_DOCS_DIR = join(process.cwd(), 'content/docs') + +function resolveGitHubDocUrl(pageUrl: string) { + const pathParts = pageUrl.split('/').filter(Boolean) + if (pathParts.length === 0) return undefined + + const first = pathParts[0] ?? '' + const lang = SUPPORTED_LANGUAGES.has(first) ? first : i18n.defaultLanguage + const restParts = SUPPORTED_LANGUAGES.has(first) ? pathParts.slice(1) : pathParts + + const relBase = restParts.join('/') + if (!relBase) return undefined + + const candidates = [ + join(CONTENT_DOCS_DIR, lang, `${relBase}.mdx`), + join(CONTENT_DOCS_DIR, lang, relBase, 'index.mdx'), + ] + + const foundPath = candidates.find((p) => existsSync(p)) + if (!foundPath) return undefined + + const relFromContent = relative(CONTENT_DOCS_DIR, foundPath).split('\\').join('/') + return `https://github.com/simstudioai/sim/blob/main/apps/docs/content/docs/${relFromContent}` +} function resolveLangAndSlug(params: { slug?: string[]; lang: string }) { const isValidLang = SUPPORTED_LANGUAGES.has(params.lang) @@ -67,6 +93,9 @@ export default async function Page(props: { params: Promise<{ slug?: string[]; l const isOpenAPI = '_openapi' in data && data._openapi != null const isApiReference = slug?.some((s) => s === 'api-reference') ?? false + const markdownUrl = `${page.url}.mdx` + const githubUrl = resolveGitHubDocUrl(page.url) + const pageTreeRecord = source.pageTree as Record const pageTree = pageTreeRecord[lang] ?? pageTreeRecord.en ?? Object.values(pageTreeRecord)[0] const rawNeighbours = pageTree ? findNeighbour(pageTree, page.url) : null @@ -148,71 +177,6 @@ export default async function Page(props: { params: Promise<{ slug?: string[]; l
)}
- -
- -
- -
- - -
- - -
- -
) @@ -257,6 +221,11 @@ export default async function Page(props: { params: Promise<{ slug?: string[]; l
+
+ + Open + +
{data.title} @@ -271,7 +240,6 @@ export default async function Page(props: { params: Promise<{ slug?: string[]; l } const MDX = data.body - const markdownContent = await data.getText('processed') return ( <> @@ -306,7 +274,12 @@ export default async function Page(props: { params: Promise<{ slug?: string[]; l
- + +
+
+ + Open +
diff --git a/apps/docs/app/[lang]/layout.tsx b/apps/docs/app/[lang]/layout.tsx index e6a46813e74..a3923a60def 100644 --- a/apps/docs/app/[lang]/layout.tsx +++ b/apps/docs/app/[lang]/layout.tsx @@ -2,29 +2,33 @@ import type { ReactNode } from 'react' import { defineI18nUI } from 'fumadocs-ui/i18n' import { DocsLayout } from 'fumadocs-ui/layouts/docs' import { RootProvider } from 'fumadocs-ui/provider/next' -import { Geist_Mono, Inter } from 'next/font/google' +import { Martian_Mono } from 'next/font/google' +import localFont from 'next/font/local' import Script from 'next/script' +import { DocsFooter } from '@/components/docs-layout/docs-footer' import { SidebarFolder, SidebarItem, SidebarSeparator, } from '@/components/docs-layout/sidebar-components' import { Navbar } from '@/components/navbar/navbar' -import { AnimatedBlocks } from '@/components/ui/animated-blocks' import { SimLogoFull } from '@/components/ui/sim-logo' import { i18n } from '@/lib/i18n' import { source } from '@/lib/source' import '../global.css' -const inter = Inter({ - subsets: ['latin'], - variable: '--font-geist-sans', +const season = localFont({ + src: [{ path: '../fonts/SeasonSansUprightsVF.woff2', weight: '300 800', style: 'normal' }], display: 'swap', + preload: true, + variable: '--font-season', + fallback: ['system-ui', 'Segoe UI', 'Roboto', 'Helvetica Neue', 'Arial', 'Noto Sans'], + adjustFontFallback: 'Arial', }) -const geistMono = Geist_Mono({ +const martianMono = Martian_Mono({ subsets: ['latin'], - variable: '--font-geist-mono', + variable: '--font-martian-mono', display: 'swap', }) @@ -92,7 +96,7 @@ export default async function Layout({ children, params }: LayoutProps) { return ( @@ -101,9 +105,8 @@ export default async function Layout({ children, params }: LayoutProps) { dangerouslySetInnerHTML={{ __html: JSON.stringify(structuredData) }} /> - +