Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion apps/docs/app/[lang]/[[...slug]]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { PageFooter } from '@/components/docs-layout/page-footer'
import { PageNavigationArrows } from '@/components/docs-layout/page-navigation-arrows'
import { LLMCopyButton } from '@/components/page-actions'
import { StructuredData } from '@/components/structured-data'
import { APIExampleSelector } from '@/components/ui/api-example-selector'
import { CodeBlock } from '@/components/ui/code-block'
import { Heading } from '@/components/ui/heading'
import { ResponseSection } from '@/components/ui/response-section'
Expand Down Expand Up @@ -70,12 +71,16 @@ function stripLocalePrefix(url: string, lang: string): string {

const APIPage = createAPIPage(openapi, {
playground: { enabled: false },
client: {
operation: { APIExampleSelector },
},
content: {
renderOperationLayout: async (slots) => {
renderOperationLayout: (slots) => {
return (
<div className='flex @4xl:flex-row flex-col @4xl:items-start gap-x-6 gap-y-4'>
<div className='min-w-0 flex-1'>
{slots.header}
{slots.description}
{slots.apiPlayground}
{slots.authSchemes && <div className='api-section-divider'>{slots.authSchemes}</div>}
{slots.parameters}
Expand Down
69 changes: 40 additions & 29 deletions apps/docs/app/[lang]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ 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 Script from 'next/script'
import { ThemeProvider } from 'next-themes'
import {
SidebarFolder,
SidebarItem,
Expand Down Expand Up @@ -90,40 +92,49 @@ export default async function Layout({ children, params }: LayoutProps) {
suppressHydrationWarning
>
<head>
<script
<Script
id='website-json-ld'
type='application/ld+json'
strategy='beforeInteractive'
dangerouslySetInnerHTML={{ __html: serializeJsonLd(structuredData) }}
/>
</head>
<body className='flex min-h-screen flex-col font-sans'>
<RootProvider i18n={provider(lang)}>
<Navbar />
<DocsLayout
tree={source.pageTree[lang]}
nav={{
title: <SimWordmark className='h-[18px]' />,
}}
sidebar={{
tabs: false,
defaultOpenLevel: 0,
collapsible: false,
footer: null,
banner: null,
prefetch: false,
components: {
Item: SidebarItem,
Folder: SidebarFolder,
Separator: SidebarSeparator,
},
}}
containerProps={{
className: '!pt-0',
}}
>
{children}
</DocsLayout>
<Footer />
</RootProvider>
<ThemeProvider
attribute='class'
defaultTheme='system'
enableSystem
disableTransitionOnChange
>
<RootProvider i18n={provider(lang)} theme={{ enabled: false }}>
<Navbar />
<DocsLayout
tree={source.pageTree[lang]}
nav={{
title: <SimWordmark className='h-[18px]' />,
}}
sidebar={{
tabs: false,
defaultOpenLevel: 0,
collapsible: false,
footer: null,
banner: null,
prefetch: false,
components: {
Item: SidebarItem,
Folder: SidebarFolder,
Separator: SidebarSeparator,
},
}}
containerProps={{
className: '!pt-0',
}}
>
{children}
</DocsLayout>
<Footer />
</RootProvider>
</ThemeProvider>
</body>
</html>
)
Expand Down
11 changes: 8 additions & 3 deletions apps/docs/components/structured-data.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Script from 'next/script'
import { serializeJsonLd } from '@/lib/json-ld'
import { DOCS_BASE_URL } from '@/lib/urls'

Expand All @@ -19,6 +20,7 @@ export function StructuredData({
breadcrumb,
}: StructuredDataProps) {
const baseUrl = DOCS_BASE_URL
const structuredDataId = encodeURIComponent(url)

const articleStructuredData = {
'@context': 'https://schema.org',
Expand Down Expand Up @@ -101,22 +103,25 @@ export function StructuredData({

return (
<>
<script
<Script
id={`article-json-ld-${structuredDataId}`}
type='application/ld+json'
dangerouslySetInnerHTML={{
__html: serializeJsonLd(articleStructuredData),
}}
/>
{breadcrumbStructuredData && (
<script
<Script
id={`breadcrumb-json-ld-${structuredDataId}`}
type='application/ld+json'
dangerouslySetInnerHTML={{
__html: serializeJsonLd(breadcrumbStructuredData),
}}
/>
)}
{(url === baseUrl || url === `${baseUrl}/`) && (
<script
<Script
id={`software-json-ld-${structuredDataId}`}
type='application/ld+json'
dangerouslySetInnerHTML={{
__html: serializeJsonLd(softwareStructuredData),
Expand Down
47 changes: 47 additions & 0 deletions apps/docs/components/ui/api-example-selector.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
'use client'

import type { ComponentProps } from 'react'
import { useId } from 'react'
import { ChevronDown } from '@sim/emcn/icons'
import type { APIPageClientOptions } from 'fumadocs-openapi/ui/client'

type FumadocsAPIExampleSelector = NonNullable<
NonNullable<APIPageClientOptions['operation']>['APIExampleSelector']
>

interface APIExampleSelectorProps extends ComponentProps<FumadocsAPIExampleSelector> {}

export function APIExampleSelector({ items, value, onValueChange }: APIExampleSelectorProps) {
const id = useId()

if (items.length <= 1) return null

const selectedValue = value ?? items[0].id
const selectedItem = items.find((item) => item.id === selectedValue)

return (
<div className='not-prose mb-2 flex flex-col gap-1.5'>
<label htmlFor={id} className='sr-only'>
Request example
</label>
<div className='relative'>
<select
id={id}
value={selectedValue}
onChange={(event) => onValueChange(event.target.value)}
className='w-full appearance-none rounded-md border bg-fd-secondary py-2 ps-3 pe-9 text-start font-medium text-fd-secondary-foreground text-sm outline-none transition-colors hover:bg-fd-accent focus-visible:ring-2 focus-visible:ring-fd-ring'
>
{items.map((item) => (
<option key={item.id} value={item.id}>
{item.name}
</option>
))}
</select>
<ChevronDown className='-translate-y-1/2 pointer-events-none absolute end-3 top-1/2 size-[14px] text-fd-muted-foreground' />
</div>
{selectedItem?.description && (
<p className='text-fd-muted-foreground text-xs'>{selectedItem.description}</p>
)}
</div>
)
}
7 changes: 5 additions & 2 deletions apps/docs/components/ui/faq.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
'use client'

import { useState } from 'react'
import { useId, useState } from 'react'
import { ChevronRight } from '@sim/emcn/icons'
import Script from 'next/script'
import { serializeJsonLd } from '@/lib/json-ld'
import { cn } from '@/lib/utils'

Expand Down Expand Up @@ -58,6 +59,7 @@ function FAQItemRow({
}

export function FAQ({ items, title = 'Common Questions' }: FAQProps) {
const structuredDataId = useId()
/**
* Rows open independently rather than as a single-open accordion. Auto-closing
* a sibling collapses content *above* the row being opened, which yanks that
Expand Down Expand Up @@ -89,7 +91,8 @@ export function FAQ({ items, title = 'Common Questions' }: FAQProps) {

return (
<div className='mt-12'>
<script
<Script
id={`faq-json-ld-${structuredDataId}`}
type='application/ld+json'
dangerouslySetInnerHTML={{ __html: serializeJsonLd(faqSchema) }}
/>
Expand Down
12 changes: 6 additions & 6 deletions apps/docs/content/docs/de/api-reference/authentication.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,23 @@ Pass your API key in the `X-API-Key` header with every request:
<Tabs items={['curl', 'TypeScript', 'Python']}>
<Tab value="curl">
```bash
curl -X POST https://www.sim.ai/api/workflows/{workflowId}/execute \
curl -X POST https://www.sim.ai/api/v2/workflows/{workflowId}/execute \
-H "Content-Type: application/json" \
-H "X-API-Key: YOUR_API_KEY" \
-d '{"inputs": {}}'
-d '{"input": {}}'
```
</Tab>
<Tab value="TypeScript">
```typescript
const response = await fetch(
'https://www.sim.ai/api/workflows/{workflowId}/execute',
'https://www.sim.ai/api/v2/workflows/{workflowId}/execute',
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': process.env.SIM_API_KEY!,
},
body: JSON.stringify({ inputs: {} }),
body: JSON.stringify({ input: {} }),
}
)
```
Expand All @@ -67,12 +67,12 @@ Pass your API key in the `X-API-Key` header with every request:
import requests

response = requests.post(
"https://www.sim.ai/api/workflows/{workflowId}/execute",
"https://www.sim.ai/api/v2/workflows/{workflowId}/execute",
Comment thread
cursor[bot] marked this conversation as resolved.
headers={
"Content-Type": "application/json",
"X-API-Key": os.environ["SIM_API_KEY"],
},
json={"inputs": {}},
json={"input": {}},
)
```
</Tab>
Expand Down
Loading
Loading