@raystack/chronicle 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.js +425 -9937
- package/package.json +19 -10
- package/src/cli/commands/build.ts +33 -31
- package/src/cli/commands/dev.ts +23 -31
- package/src/cli/commands/init.ts +38 -132
- package/src/cli/commands/serve.ts +41 -55
- package/src/cli/commands/start.ts +20 -31
- package/src/cli/index.ts +14 -14
- package/src/cli/utils/config.ts +58 -30
- package/src/cli/utils/index.ts +3 -3
- package/src/cli/utils/resolve.ts +7 -3
- package/src/cli/utils/scaffold.ts +11 -130
- package/src/components/mdx/code.tsx +10 -1
- package/src/components/mdx/details.module.css +1 -26
- package/src/components/mdx/details.tsx +2 -3
- package/src/components/mdx/image.tsx +5 -34
- package/src/components/mdx/index.tsx +15 -1
- package/src/components/mdx/link.tsx +18 -15
- package/src/components/ui/breadcrumbs.tsx +8 -42
- package/src/components/ui/search.tsx +63 -51
- package/src/lib/api-routes.ts +6 -8
- package/src/lib/config.ts +12 -36
- package/src/lib/head.tsx +49 -0
- package/src/lib/openapi.ts +8 -8
- package/src/lib/page-context.tsx +111 -0
- package/src/lib/remark-strip-md-extensions.ts +14 -0
- package/src/lib/source.ts +139 -63
- package/src/pages/ApiLayout.tsx +33 -0
- package/src/pages/ApiPage.tsx +73 -0
- package/src/pages/DocsLayout.tsx +18 -0
- package/src/pages/DocsPage.tsx +43 -0
- package/src/pages/NotFound.tsx +17 -0
- package/src/server/App.tsx +72 -0
- package/src/server/api/apis-proxy.ts +69 -0
- package/src/server/api/health.ts +5 -0
- package/src/server/api/page/[...slug].ts +18 -0
- package/src/server/api/search.ts +118 -0
- package/src/server/api/specs.ts +9 -0
- package/src/server/build-search-index.ts +117 -0
- package/src/server/entry-client.tsx +88 -0
- package/src/server/entry-server.tsx +102 -0
- package/src/server/routes/llms.txt.ts +21 -0
- package/src/server/routes/og.tsx +75 -0
- package/src/server/routes/robots.txt.ts +11 -0
- package/src/server/routes/sitemap.xml.ts +40 -0
- package/src/server/utils/safe-path.ts +17 -0
- package/src/server/vite-config.ts +133 -0
- package/src/themes/default/Layout.tsx +78 -48
- package/src/themes/default/Page.module.css +44 -0
- package/src/themes/default/Page.tsx +9 -11
- package/src/themes/default/Toc.tsx +25 -39
- package/src/themes/default/index.ts +7 -9
- package/src/themes/paper/ChapterNav.tsx +64 -45
- package/src/themes/paper/Layout.module.css +1 -1
- package/src/themes/paper/Layout.tsx +24 -12
- package/src/themes/paper/Page.module.css +16 -4
- package/src/themes/paper/Page.tsx +56 -63
- package/src/themes/paper/ReadingProgress.tsx +160 -139
- package/src/themes/paper/index.ts +5 -5
- package/src/themes/registry.ts +14 -7
- package/src/types/config.ts +86 -67
- package/src/types/content.ts +5 -21
- package/src/types/globals.d.ts +4 -0
- package/src/types/theme.ts +4 -3
- package/tsconfig.json +2 -3
- package/next.config.mjs +0 -10
- package/source.config.ts +0 -51
- package/src/app/[[...slug]]/layout.tsx +0 -15
- package/src/app/[[...slug]]/page.tsx +0 -106
- package/src/app/api/apis-proxy/route.ts +0 -59
- package/src/app/api/health/route.ts +0 -3
- package/src/app/api/search/route.ts +0 -90
- package/src/app/apis/[[...slug]]/layout.tsx +0 -26
- package/src/app/apis/[[...slug]]/page.tsx +0 -117
- package/src/app/layout.tsx +0 -57
- package/src/app/llms-full.txt/route.ts +0 -18
- package/src/app/llms.txt/route.ts +0 -15
- package/src/app/og/route.tsx +0 -62
- package/src/app/providers.tsx +0 -8
- package/src/app/robots.ts +0 -10
- package/src/app/sitemap.ts +0 -29
- package/src/cli/utils/process.ts +0 -7
- package/src/themes/default/font.ts +0 -6
- /package/src/{app/apis/[[...slug]]/layout.module.css → pages/ApiLayout.module.css} +0 -0
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import type { Metadata, ResolvingMetadata } from 'next'
|
|
2
|
-
import { notFound } from 'next/navigation'
|
|
3
|
-
import type { OpenAPIV3 } from 'openapi-types'
|
|
4
|
-
import { Flex, Headline, Text } from '@raystack/apsara'
|
|
5
|
-
import { loadConfig } from '@/lib/config'
|
|
6
|
-
import { loadApiSpecs } from '@/lib/openapi'
|
|
7
|
-
import { buildApiRoutes, findApiOperation } from '@/lib/api-routes'
|
|
8
|
-
import { EndpointPage } from '@/components/api'
|
|
9
|
-
|
|
10
|
-
interface PageProps {
|
|
11
|
-
params: Promise<{ slug?: string[] }>
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export async function generateMetadata(
|
|
15
|
-
{ params }: PageProps,
|
|
16
|
-
parent: ResolvingMetadata,
|
|
17
|
-
): Promise<Metadata> {
|
|
18
|
-
const { slug } = await params
|
|
19
|
-
const config = loadConfig()
|
|
20
|
-
const specs = loadApiSpecs(config.api ?? [])
|
|
21
|
-
const parentMetadata = await parent
|
|
22
|
-
|
|
23
|
-
if (!slug || slug.length === 0) {
|
|
24
|
-
const apiDescription = `API documentation for ${config.title}`
|
|
25
|
-
const metadata: Metadata = {
|
|
26
|
-
title: 'API Reference',
|
|
27
|
-
description: apiDescription,
|
|
28
|
-
}
|
|
29
|
-
if (config.url) {
|
|
30
|
-
metadata.openGraph = {
|
|
31
|
-
...parentMetadata.openGraph,
|
|
32
|
-
title: 'API Reference',
|
|
33
|
-
description: apiDescription,
|
|
34
|
-
images: [{ url: `/og?title=${encodeURIComponent('API Reference')}&description=${encodeURIComponent(apiDescription)}`, width: 1200, height: 630 }],
|
|
35
|
-
}
|
|
36
|
-
metadata.twitter = {
|
|
37
|
-
...parentMetadata.twitter,
|
|
38
|
-
title: 'API Reference',
|
|
39
|
-
description: apiDescription,
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return metadata
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const match = findApiOperation(specs, slug)
|
|
46
|
-
if (!match) return {}
|
|
47
|
-
|
|
48
|
-
const operation = match.operation as OpenAPIV3.OperationObject
|
|
49
|
-
const title = operation.summary ?? `${match.method.toUpperCase()} ${match.path}`
|
|
50
|
-
const description = operation.description
|
|
51
|
-
|
|
52
|
-
const metadata: Metadata = { title, description }
|
|
53
|
-
|
|
54
|
-
if (config.url) {
|
|
55
|
-
const ogParams = new URLSearchParams({ title })
|
|
56
|
-
if (description) ogParams.set('description', description)
|
|
57
|
-
metadata.openGraph = {
|
|
58
|
-
...parentMetadata.openGraph,
|
|
59
|
-
title,
|
|
60
|
-
description,
|
|
61
|
-
images: [{ url: `/og?${ogParams.toString()}`, width: 1200, height: 630 }],
|
|
62
|
-
}
|
|
63
|
-
metadata.twitter = {
|
|
64
|
-
...parentMetadata.twitter,
|
|
65
|
-
title,
|
|
66
|
-
description,
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return metadata
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export default async function ApiPage({ params }: PageProps) {
|
|
74
|
-
const { slug } = await params
|
|
75
|
-
const config = loadConfig()
|
|
76
|
-
const specs = loadApiSpecs(config.api ?? [])
|
|
77
|
-
|
|
78
|
-
if (!slug || slug.length === 0) {
|
|
79
|
-
return <ApiLanding specs={specs} />
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const match = findApiOperation(specs, slug)
|
|
83
|
-
if (!match) notFound()
|
|
84
|
-
|
|
85
|
-
return (
|
|
86
|
-
<EndpointPage
|
|
87
|
-
method={match.method}
|
|
88
|
-
path={match.path}
|
|
89
|
-
operation={match.operation}
|
|
90
|
-
serverUrl={match.spec.server.url}
|
|
91
|
-
specName={match.spec.name}
|
|
92
|
-
auth={match.spec.auth}
|
|
93
|
-
/>
|
|
94
|
-
)
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
function ApiLanding({ specs }: { specs: { name: string; document: OpenAPIV3.Document }[] }) {
|
|
98
|
-
return (
|
|
99
|
-
<Flex direction="column" gap="large" style={{ padding: 'var(--rs-space-7)' }}>
|
|
100
|
-
<Headline size="medium" as="h1">API Reference</Headline>
|
|
101
|
-
{specs.map((spec) => (
|
|
102
|
-
<Flex key={spec.name} direction="column" gap="small">
|
|
103
|
-
<Headline size="small" as="h2">{spec.name}</Headline>
|
|
104
|
-
{spec.document.info.description && (
|
|
105
|
-
<Text size={3}>{spec.document.info.description}</Text>
|
|
106
|
-
)}
|
|
107
|
-
</Flex>
|
|
108
|
-
))}
|
|
109
|
-
</Flex>
|
|
110
|
-
)
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export function generateStaticParams() {
|
|
114
|
-
const config = loadConfig()
|
|
115
|
-
const specs = loadApiSpecs(config.api ?? [])
|
|
116
|
-
return [{ slug: [] }, ...buildApiRoutes(specs)]
|
|
117
|
-
}
|
package/src/app/layout.tsx
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import '@raystack/apsara/normalize.css'
|
|
2
|
-
import '@raystack/apsara/style.css'
|
|
3
|
-
import type { Metadata } from 'next'
|
|
4
|
-
import { loadConfig } from '@/lib/config'
|
|
5
|
-
import { Providers } from './providers'
|
|
6
|
-
|
|
7
|
-
const config = loadConfig()
|
|
8
|
-
|
|
9
|
-
export const metadata: Metadata = {
|
|
10
|
-
title: {
|
|
11
|
-
default: config.title,
|
|
12
|
-
template: `%s | ${config.title}`,
|
|
13
|
-
},
|
|
14
|
-
description: config.description,
|
|
15
|
-
...(config.url && {
|
|
16
|
-
metadataBase: new URL(config.url),
|
|
17
|
-
openGraph: {
|
|
18
|
-
title: config.title,
|
|
19
|
-
description: config.description,
|
|
20
|
-
url: config.url,
|
|
21
|
-
siteName: config.title,
|
|
22
|
-
type: 'website',
|
|
23
|
-
images: [{ url: '/og?title=' + encodeURIComponent(config.title), width: 1200, height: 630 }],
|
|
24
|
-
},
|
|
25
|
-
twitter: {
|
|
26
|
-
card: 'summary_large_image',
|
|
27
|
-
title: config.title,
|
|
28
|
-
description: config.description,
|
|
29
|
-
images: ['/og?title=' + encodeURIComponent(config.title)],
|
|
30
|
-
},
|
|
31
|
-
}),
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export default function RootLayout({
|
|
35
|
-
children,
|
|
36
|
-
}: {
|
|
37
|
-
children: React.ReactNode
|
|
38
|
-
}) {
|
|
39
|
-
return (
|
|
40
|
-
<html lang="en" suppressHydrationWarning>
|
|
41
|
-
<body suppressHydrationWarning>
|
|
42
|
-
{config.url && (
|
|
43
|
-
<script type="application/ld+json">
|
|
44
|
-
{JSON.stringify({
|
|
45
|
-
'@context': 'https://schema.org',
|
|
46
|
-
'@type': 'WebSite',
|
|
47
|
-
name: config.title,
|
|
48
|
-
description: config.description,
|
|
49
|
-
url: config.url,
|
|
50
|
-
}, null, 2)}
|
|
51
|
-
</script>
|
|
52
|
-
)}
|
|
53
|
-
<Providers>{children}</Providers>
|
|
54
|
-
</body>
|
|
55
|
-
</html>
|
|
56
|
-
)
|
|
57
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { source } from '@/lib/source'
|
|
2
|
-
import { loadConfig } from '@/lib/config'
|
|
3
|
-
import { getLLMText } from '@/lib/get-llm-text'
|
|
4
|
-
|
|
5
|
-
export const revalidate = false
|
|
6
|
-
|
|
7
|
-
export async function GET() {
|
|
8
|
-
const config = loadConfig()
|
|
9
|
-
|
|
10
|
-
if (!config.llms?.enabled) {
|
|
11
|
-
return new Response('Not Found', { status: 404 })
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const scan = source.getPages().map(getLLMText)
|
|
15
|
-
const scanned = await Promise.all(scan)
|
|
16
|
-
|
|
17
|
-
return new Response(scanned.join('\n\n'))
|
|
18
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { source } from '@/lib/source'
|
|
2
|
-
import { loadConfig } from '@/lib/config'
|
|
3
|
-
import { llms } from 'fumadocs-core/source'
|
|
4
|
-
|
|
5
|
-
export const revalidate = false
|
|
6
|
-
|
|
7
|
-
export function GET() {
|
|
8
|
-
const config = loadConfig()
|
|
9
|
-
|
|
10
|
-
if (!config.llms?.enabled) {
|
|
11
|
-
return new Response('Not Found', { status: 404 })
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
return new Response(llms(source).index())
|
|
15
|
-
}
|
package/src/app/og/route.tsx
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { ImageResponse } from 'next/og'
|
|
2
|
-
import type { NextRequest } from 'next/server'
|
|
3
|
-
import { loadConfig } from '@/lib/config'
|
|
4
|
-
|
|
5
|
-
export async function GET(request: NextRequest) {
|
|
6
|
-
const { searchParams } = request.nextUrl
|
|
7
|
-
const title = searchParams.get('title') ?? loadConfig().title
|
|
8
|
-
const description = searchParams.get('description') ?? ''
|
|
9
|
-
const siteName = loadConfig().title
|
|
10
|
-
|
|
11
|
-
return new ImageResponse(
|
|
12
|
-
(
|
|
13
|
-
<div
|
|
14
|
-
style={{
|
|
15
|
-
height: '100%',
|
|
16
|
-
width: '100%',
|
|
17
|
-
display: 'flex',
|
|
18
|
-
flexDirection: 'column',
|
|
19
|
-
justifyContent: 'center',
|
|
20
|
-
padding: '60px 80px',
|
|
21
|
-
backgroundColor: '#0a0a0a',
|
|
22
|
-
color: '#fafafa',
|
|
23
|
-
}}
|
|
24
|
-
>
|
|
25
|
-
<div
|
|
26
|
-
style={{
|
|
27
|
-
fontSize: 24,
|
|
28
|
-
color: '#888',
|
|
29
|
-
marginBottom: 16,
|
|
30
|
-
}}
|
|
31
|
-
>
|
|
32
|
-
{siteName}
|
|
33
|
-
</div>
|
|
34
|
-
<div
|
|
35
|
-
style={{
|
|
36
|
-
fontSize: 56,
|
|
37
|
-
fontWeight: 700,
|
|
38
|
-
lineHeight: 1.2,
|
|
39
|
-
marginBottom: 24,
|
|
40
|
-
}}
|
|
41
|
-
>
|
|
42
|
-
{title}
|
|
43
|
-
</div>
|
|
44
|
-
{description && (
|
|
45
|
-
<div
|
|
46
|
-
style={{
|
|
47
|
-
fontSize: 24,
|
|
48
|
-
color: '#999',
|
|
49
|
-
lineHeight: 1.4,
|
|
50
|
-
}}
|
|
51
|
-
>
|
|
52
|
-
{description}
|
|
53
|
-
</div>
|
|
54
|
-
)}
|
|
55
|
-
</div>
|
|
56
|
-
),
|
|
57
|
-
{
|
|
58
|
-
width: 1200,
|
|
59
|
-
height: 630,
|
|
60
|
-
}
|
|
61
|
-
)
|
|
62
|
-
}
|
package/src/app/providers.tsx
DELETED
package/src/app/robots.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { MetadataRoute } from 'next'
|
|
2
|
-
import { loadConfig } from '@/lib/config'
|
|
3
|
-
|
|
4
|
-
export default function robots(): MetadataRoute.Robots {
|
|
5
|
-
const config = loadConfig()
|
|
6
|
-
return {
|
|
7
|
-
rules: { userAgent: '*', allow: '/' },
|
|
8
|
-
...(config.url && { sitemap: `${config.url}/sitemap.xml` }),
|
|
9
|
-
}
|
|
10
|
-
}
|
package/src/app/sitemap.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { MetadataRoute } from 'next'
|
|
2
|
-
import { loadConfig } from '@/lib/config'
|
|
3
|
-
import { source } from '@/lib/source'
|
|
4
|
-
import { loadApiSpecs } from '@/lib/openapi'
|
|
5
|
-
import { buildApiRoutes } from '@/lib/api-routes'
|
|
6
|
-
|
|
7
|
-
export default function sitemap(): MetadataRoute.Sitemap {
|
|
8
|
-
const config = loadConfig()
|
|
9
|
-
if (!config.url) return []
|
|
10
|
-
|
|
11
|
-
const baseUrl = config.url.replace(/\/$/, '')
|
|
12
|
-
|
|
13
|
-
const docPages = source.getPages().map((page) => ({
|
|
14
|
-
url: `${baseUrl}/${page.slugs.join('/')}`,
|
|
15
|
-
...(page.data.lastModified && { lastModified: new Date(page.data.lastModified) }),
|
|
16
|
-
}))
|
|
17
|
-
|
|
18
|
-
const apiPages = config.api?.length
|
|
19
|
-
? buildApiRoutes(loadApiSpecs(config.api)).map((route) => ({
|
|
20
|
-
url: `${baseUrl}/apis/${route.slug.join('/')}`,
|
|
21
|
-
}))
|
|
22
|
-
: []
|
|
23
|
-
|
|
24
|
-
return [
|
|
25
|
-
{ url: baseUrl },
|
|
26
|
-
...docPages,
|
|
27
|
-
...apiPages,
|
|
28
|
-
]
|
|
29
|
-
}
|
package/src/cli/utils/process.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { ChildProcess } from 'child_process'
|
|
2
|
-
|
|
3
|
-
export function attachLifecycleHandlers(child: ChildProcess) {
|
|
4
|
-
child.on('close', (code) => process.exit(code ?? 0))
|
|
5
|
-
process.on('SIGINT', () => child.kill('SIGINT'))
|
|
6
|
-
process.on('SIGTERM', () => child.kill('SIGTERM'))
|
|
7
|
-
}
|
|
File without changes
|