@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.
Files changed (84) hide show
  1. package/dist/cli/index.js +425 -9937
  2. package/package.json +19 -10
  3. package/src/cli/commands/build.ts +33 -31
  4. package/src/cli/commands/dev.ts +23 -31
  5. package/src/cli/commands/init.ts +38 -132
  6. package/src/cli/commands/serve.ts +41 -55
  7. package/src/cli/commands/start.ts +20 -31
  8. package/src/cli/index.ts +14 -14
  9. package/src/cli/utils/config.ts +58 -30
  10. package/src/cli/utils/index.ts +3 -3
  11. package/src/cli/utils/resolve.ts +7 -3
  12. package/src/cli/utils/scaffold.ts +11 -130
  13. package/src/components/mdx/code.tsx +10 -1
  14. package/src/components/mdx/details.module.css +1 -26
  15. package/src/components/mdx/details.tsx +2 -3
  16. package/src/components/mdx/image.tsx +5 -34
  17. package/src/components/mdx/index.tsx +15 -1
  18. package/src/components/mdx/link.tsx +18 -15
  19. package/src/components/ui/breadcrumbs.tsx +8 -42
  20. package/src/components/ui/search.tsx +63 -51
  21. package/src/lib/api-routes.ts +6 -8
  22. package/src/lib/config.ts +12 -36
  23. package/src/lib/head.tsx +49 -0
  24. package/src/lib/openapi.ts +8 -8
  25. package/src/lib/page-context.tsx +111 -0
  26. package/src/lib/remark-strip-md-extensions.ts +14 -0
  27. package/src/lib/source.ts +139 -63
  28. package/src/pages/ApiLayout.tsx +33 -0
  29. package/src/pages/ApiPage.tsx +73 -0
  30. package/src/pages/DocsLayout.tsx +18 -0
  31. package/src/pages/DocsPage.tsx +43 -0
  32. package/src/pages/NotFound.tsx +17 -0
  33. package/src/server/App.tsx +72 -0
  34. package/src/server/api/apis-proxy.ts +69 -0
  35. package/src/server/api/health.ts +5 -0
  36. package/src/server/api/page/[...slug].ts +18 -0
  37. package/src/server/api/search.ts +118 -0
  38. package/src/server/api/specs.ts +9 -0
  39. package/src/server/build-search-index.ts +117 -0
  40. package/src/server/entry-client.tsx +88 -0
  41. package/src/server/entry-server.tsx +102 -0
  42. package/src/server/routes/llms.txt.ts +21 -0
  43. package/src/server/routes/og.tsx +75 -0
  44. package/src/server/routes/robots.txt.ts +11 -0
  45. package/src/server/routes/sitemap.xml.ts +40 -0
  46. package/src/server/utils/safe-path.ts +17 -0
  47. package/src/server/vite-config.ts +133 -0
  48. package/src/themes/default/Layout.tsx +78 -48
  49. package/src/themes/default/Page.module.css +44 -0
  50. package/src/themes/default/Page.tsx +9 -11
  51. package/src/themes/default/Toc.tsx +25 -39
  52. package/src/themes/default/index.ts +7 -9
  53. package/src/themes/paper/ChapterNav.tsx +64 -45
  54. package/src/themes/paper/Layout.module.css +1 -1
  55. package/src/themes/paper/Layout.tsx +24 -12
  56. package/src/themes/paper/Page.module.css +16 -4
  57. package/src/themes/paper/Page.tsx +56 -63
  58. package/src/themes/paper/ReadingProgress.tsx +160 -139
  59. package/src/themes/paper/index.ts +5 -5
  60. package/src/themes/registry.ts +14 -7
  61. package/src/types/config.ts +86 -67
  62. package/src/types/content.ts +5 -21
  63. package/src/types/globals.d.ts +4 -0
  64. package/src/types/theme.ts +4 -3
  65. package/tsconfig.json +2 -3
  66. package/next.config.mjs +0 -10
  67. package/source.config.ts +0 -51
  68. package/src/app/[[...slug]]/layout.tsx +0 -15
  69. package/src/app/[[...slug]]/page.tsx +0 -106
  70. package/src/app/api/apis-proxy/route.ts +0 -59
  71. package/src/app/api/health/route.ts +0 -3
  72. package/src/app/api/search/route.ts +0 -90
  73. package/src/app/apis/[[...slug]]/layout.tsx +0 -26
  74. package/src/app/apis/[[...slug]]/page.tsx +0 -117
  75. package/src/app/layout.tsx +0 -57
  76. package/src/app/llms-full.txt/route.ts +0 -18
  77. package/src/app/llms.txt/route.ts +0 -15
  78. package/src/app/og/route.tsx +0 -62
  79. package/src/app/providers.tsx +0 -8
  80. package/src/app/robots.ts +0 -10
  81. package/src/app/sitemap.ts +0 -29
  82. package/src/cli/utils/process.ts +0 -7
  83. package/src/themes/default/font.ts +0 -6
  84. /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
- }
@@ -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
- }
@@ -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
- }
@@ -1,8 +0,0 @@
1
- 'use client'
2
-
3
- import { ThemeProvider } from '@raystack/apsara'
4
- import type { ReactNode } from 'react'
5
-
6
- export function Providers({ children }: { children: ReactNode }) {
7
- return <ThemeProvider enableSystem>{children}</ThemeProvider>
8
- }
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
- }
@@ -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
- }
@@ -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
- }
@@ -1,6 +0,0 @@
1
- import { Inter } from 'next/font/google'
2
-
3
- export const inter = Inter({
4
- subsets: ['latin'],
5
- display: 'swap',
6
- })