@raystack/chronicle 0.1.0-canary.e11f924
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/bin/chronicle.js +2 -0
- package/dist/cli/index.js +9788 -0
- package/next.config.mjs +10 -0
- package/package.json +62 -0
- package/source.config.ts +50 -0
- package/src/app/[[...slug]]/layout.tsx +15 -0
- package/src/app/[[...slug]]/page.tsx +57 -0
- package/src/app/api/apis-proxy/route.ts +59 -0
- package/src/app/api/health/route.ts +3 -0
- package/src/app/api/search/route.ts +90 -0
- package/src/app/apis/[[...slug]]/layout.module.css +22 -0
- package/src/app/apis/[[...slug]]/layout.tsx +26 -0
- package/src/app/apis/[[...slug]]/page.tsx +57 -0
- package/src/app/layout.tsx +26 -0
- package/src/app/llms-full.txt/route.ts +18 -0
- package/src/app/llms.txt/route.ts +15 -0
- package/src/app/providers.tsx +8 -0
- package/src/cli/commands/build.ts +33 -0
- package/src/cli/commands/dev.ts +34 -0
- package/src/cli/commands/init.ts +58 -0
- package/src/cli/commands/serve.ts +54 -0
- package/src/cli/commands/start.ts +34 -0
- package/src/cli/index.ts +21 -0
- package/src/cli/utils/config.ts +43 -0
- package/src/cli/utils/index.ts +2 -0
- package/src/cli/utils/process.ts +7 -0
- package/src/components/api/code-snippets.module.css +7 -0
- package/src/components/api/code-snippets.tsx +76 -0
- package/src/components/api/endpoint-page.module.css +58 -0
- package/src/components/api/endpoint-page.tsx +283 -0
- package/src/components/api/field-row.module.css +126 -0
- package/src/components/api/field-row.tsx +204 -0
- package/src/components/api/field-section.module.css +24 -0
- package/src/components/api/field-section.tsx +100 -0
- package/src/components/api/index.ts +8 -0
- package/src/components/api/json-editor.module.css +9 -0
- package/src/components/api/json-editor.tsx +61 -0
- package/src/components/api/key-value-editor.module.css +13 -0
- package/src/components/api/key-value-editor.tsx +62 -0
- package/src/components/api/method-badge.module.css +4 -0
- package/src/components/api/method-badge.tsx +29 -0
- package/src/components/api/response-panel.module.css +8 -0
- package/src/components/api/response-panel.tsx +44 -0
- package/src/components/common/breadcrumb.tsx +3 -0
- package/src/components/common/button.tsx +3 -0
- package/src/components/common/callout.module.css +7 -0
- package/src/components/common/callout.tsx +27 -0
- package/src/components/common/code-block.tsx +3 -0
- package/src/components/common/dialog.tsx +3 -0
- package/src/components/common/index.ts +10 -0
- package/src/components/common/input-field.tsx +3 -0
- package/src/components/common/sidebar.tsx +3 -0
- package/src/components/common/switch.tsx +3 -0
- package/src/components/common/table.tsx +3 -0
- package/src/components/common/tabs.tsx +3 -0
- package/src/components/mdx/code.module.css +42 -0
- package/src/components/mdx/code.tsx +27 -0
- package/src/components/mdx/details.module.css +37 -0
- package/src/components/mdx/details.tsx +18 -0
- package/src/components/mdx/image.tsx +38 -0
- package/src/components/mdx/index.tsx +35 -0
- package/src/components/mdx/link.tsx +38 -0
- package/src/components/mdx/mermaid.module.css +9 -0
- package/src/components/mdx/mermaid.tsx +37 -0
- package/src/components/mdx/paragraph.module.css +8 -0
- package/src/components/mdx/paragraph.tsx +19 -0
- package/src/components/mdx/table.tsx +40 -0
- package/src/components/ui/breadcrumbs.tsx +72 -0
- package/src/components/ui/client-theme-switcher.tsx +18 -0
- package/src/components/ui/footer.module.css +27 -0
- package/src/components/ui/footer.tsx +30 -0
- package/src/components/ui/search.module.css +104 -0
- package/src/components/ui/search.tsx +202 -0
- package/src/lib/api-routes.ts +120 -0
- package/src/lib/config.ts +47 -0
- package/src/lib/get-llm-text.ts +10 -0
- package/src/lib/index.ts +2 -0
- package/src/lib/openapi.ts +188 -0
- package/src/lib/remark-unused-directives.ts +30 -0
- package/src/lib/schema.ts +99 -0
- package/src/lib/snippet-generators.ts +87 -0
- package/src/lib/source.ts +67 -0
- package/src/themes/default/Layout.module.css +81 -0
- package/src/themes/default/Layout.tsx +133 -0
- package/src/themes/default/Page.module.css +46 -0
- package/src/themes/default/Page.tsx +21 -0
- package/src/themes/default/Toc.module.css +48 -0
- package/src/themes/default/Toc.tsx +66 -0
- package/src/themes/default/font.ts +6 -0
- package/src/themes/default/index.ts +13 -0
- package/src/themes/paper/ChapterNav.module.css +71 -0
- package/src/themes/paper/ChapterNav.tsx +96 -0
- package/src/themes/paper/Layout.module.css +33 -0
- package/src/themes/paper/Layout.tsx +25 -0
- package/src/themes/paper/Page.module.css +174 -0
- package/src/themes/paper/Page.tsx +107 -0
- package/src/themes/paper/ReadingProgress.module.css +132 -0
- package/src/themes/paper/ReadingProgress.tsx +294 -0
- package/src/themes/paper/index.ts +8 -0
- package/src/themes/registry.ts +14 -0
- package/src/types/config.ts +69 -0
- package/src/types/content.ts +35 -0
- package/src/types/index.ts +3 -0
- package/src/types/theme.ts +22 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
.nav {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
gap: var(--rs-space-5);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.chapter {
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-direction: column;
|
|
10
|
+
gap: var(--rs-space-2);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.chapterLabel {
|
|
14
|
+
font-size: var(--rs-font-size-small);
|
|
15
|
+
font-weight: 600;
|
|
16
|
+
text-transform: uppercase;
|
|
17
|
+
letter-spacing: 0.05em;
|
|
18
|
+
color: var(--rs-color-foreground-base-primary);
|
|
19
|
+
white-space: nowrap;
|
|
20
|
+
overflow: hidden;
|
|
21
|
+
text-overflow: ellipsis;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.chapterItems {
|
|
25
|
+
list-style: none;
|
|
26
|
+
padding: 0;
|
|
27
|
+
margin: 0;
|
|
28
|
+
display: flex;
|
|
29
|
+
flex-direction: column;
|
|
30
|
+
gap: var(--rs-space-1);
|
|
31
|
+
padding-left: var(--rs-space-4);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.link {
|
|
35
|
+
display: flex;
|
|
36
|
+
align-items: center;
|
|
37
|
+
gap: var(--rs-space-2);
|
|
38
|
+
font-size: var(--rs-font-size-small);
|
|
39
|
+
color: var(--rs-color-foreground-base-tertiary);
|
|
40
|
+
text-decoration: none;
|
|
41
|
+
padding: var(--rs-space-1) 0;
|
|
42
|
+
white-space: nowrap;
|
|
43
|
+
overflow: hidden;
|
|
44
|
+
text-overflow: ellipsis;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.link:hover {
|
|
48
|
+
color: var(--rs-color-foreground-base-primary);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.active {
|
|
52
|
+
color: var(--rs-color-foreground-accent-primary);
|
|
53
|
+
font-weight: 500;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.icon {
|
|
57
|
+
display: flex;
|
|
58
|
+
align-items: center;
|
|
59
|
+
flex-shrink: 0;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.subLabel {
|
|
63
|
+
font-size: var(--rs-font-size-small);
|
|
64
|
+
font-weight: 500;
|
|
65
|
+
color: var(--rs-color-foreground-base-secondary);
|
|
66
|
+
margin-top: var(--rs-space-3);
|
|
67
|
+
display: block;
|
|
68
|
+
white-space: nowrap;
|
|
69
|
+
overflow: hidden;
|
|
70
|
+
text-overflow: ellipsis;
|
|
71
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { usePathname } from 'next/navigation'
|
|
4
|
+
import NextLink from 'next/link'
|
|
5
|
+
import { MethodBadge } from '@/components/api/method-badge'
|
|
6
|
+
import type { PageTree, PageTreeItem } from '@/types'
|
|
7
|
+
import styles from './ChapterNav.module.css'
|
|
8
|
+
|
|
9
|
+
const iconMap: Record<string, React.ReactNode> = {
|
|
10
|
+
'method-get': <MethodBadge method="GET" size="micro" />,
|
|
11
|
+
'method-post': <MethodBadge method="POST" size="micro" />,
|
|
12
|
+
'method-put': <MethodBadge method="PUT" size="micro" />,
|
|
13
|
+
'method-delete': <MethodBadge method="DELETE" size="micro" />,
|
|
14
|
+
'method-patch': <MethodBadge method="PATCH" size="micro" />,
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface ChapterNavProps {
|
|
18
|
+
tree: PageTree
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function buildChapterIndices(children: PageTreeItem[]): Map<PageTreeItem, number> {
|
|
22
|
+
const indices = new Map<PageTreeItem, number>()
|
|
23
|
+
let index = 0
|
|
24
|
+
for (const item of children) {
|
|
25
|
+
if (item.type === 'folder' && item.children) {
|
|
26
|
+
index++
|
|
27
|
+
indices.set(item, index)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return indices
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function ChapterNav({ tree }: ChapterNavProps) {
|
|
34
|
+
const pathname = usePathname()
|
|
35
|
+
const chapterIndices = buildChapterIndices(tree.children)
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<nav className={styles.nav}>
|
|
39
|
+
<ul className={styles.chapterItems}>
|
|
40
|
+
{tree.children.map((item) => {
|
|
41
|
+
if (item.type === 'separator') return null
|
|
42
|
+
|
|
43
|
+
if (item.type === 'folder' && item.children) {
|
|
44
|
+
const chapterIndex = chapterIndices.get(item) ?? 0
|
|
45
|
+
return (
|
|
46
|
+
<li key={item.name} className={styles.chapter}>
|
|
47
|
+
<span className={styles.chapterLabel}>
|
|
48
|
+
{String(chapterIndex).padStart(2, '0')}. {item.name}
|
|
49
|
+
</span>
|
|
50
|
+
<ul className={styles.chapterItems}>
|
|
51
|
+
{item.children.map((child) => (
|
|
52
|
+
<ChapterItem key={child.url ?? child.name} item={child} pathname={pathname} />
|
|
53
|
+
))}
|
|
54
|
+
</ul>
|
|
55
|
+
</li>
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return <ChapterItem key={item.url ?? item.name} item={item} pathname={pathname} />
|
|
60
|
+
})}
|
|
61
|
+
</ul>
|
|
62
|
+
</nav>
|
|
63
|
+
)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function ChapterItem({ item, pathname }: { item: PageTreeItem; pathname: string }) {
|
|
67
|
+
if (item.type === 'separator') return null
|
|
68
|
+
|
|
69
|
+
if (item.type === 'folder' && item.children) {
|
|
70
|
+
return (
|
|
71
|
+
<li>
|
|
72
|
+
<span className={styles.subLabel}>{item.name}</span>
|
|
73
|
+
<ul className={styles.chapterItems}>
|
|
74
|
+
{item.children.map((child) => (
|
|
75
|
+
<ChapterItem key={child.url ?? child.name} item={child} pathname={pathname} />
|
|
76
|
+
))}
|
|
77
|
+
</ul>
|
|
78
|
+
</li>
|
|
79
|
+
)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const isActive = pathname === item.url
|
|
83
|
+
const icon = item.icon ? iconMap[item.icon] : null
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<li>
|
|
87
|
+
<NextLink
|
|
88
|
+
href={item.url ?? '#'}
|
|
89
|
+
className={`${styles.link} ${isActive ? styles.active : ''}`}
|
|
90
|
+
>
|
|
91
|
+
{icon && <span className={styles.icon}>{icon}</span>}
|
|
92
|
+
<span>{item.name}</span>
|
|
93
|
+
</NextLink>
|
|
94
|
+
</li>
|
|
95
|
+
)
|
|
96
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
.layout {
|
|
2
|
+
--paper-sidebar-width: 260px;
|
|
3
|
+
|
|
4
|
+
min-height: 100vh;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.body {
|
|
8
|
+
flex: 1;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.sidebar {
|
|
12
|
+
width: var(--paper-sidebar-width);
|
|
13
|
+
padding: var(--rs-space-7) var(--rs-space-5);
|
|
14
|
+
background: var(--rs-color-background-neutral-primary);
|
|
15
|
+
overflow-y: auto;
|
|
16
|
+
font-family: 'SF Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono', monospace;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.title {
|
|
20
|
+
text-transform: uppercase;
|
|
21
|
+
letter-spacing: 0.08em;
|
|
22
|
+
color: var(--rs-color-foreground-accent-primary);
|
|
23
|
+
font-family: inherit;
|
|
24
|
+
font-size: var(--rs-font-size-mono-large);
|
|
25
|
+
margin-bottom: var(--rs-space-7);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.content {
|
|
29
|
+
flex: 1;
|
|
30
|
+
overflow-y: auto;
|
|
31
|
+
background: var(--rs-color-background-neutral-primary);
|
|
32
|
+
padding-right: var(--paper-sidebar-width);
|
|
33
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { Flex, Headline } from '@raystack/apsara'
|
|
4
|
+
import { cx } from 'class-variance-authority'
|
|
5
|
+
import { Footer } from '@/components/ui/footer'
|
|
6
|
+
import { ChapterNav } from './ChapterNav'
|
|
7
|
+
import type { ThemeLayoutProps } from '@/types'
|
|
8
|
+
import styles from './Layout.module.css'
|
|
9
|
+
|
|
10
|
+
export function Layout({ children, config, tree, classNames }: ThemeLayoutProps) {
|
|
11
|
+
return (
|
|
12
|
+
<Flex direction="column" className={cx(styles.layout, classNames?.layout)}>
|
|
13
|
+
<Flex className={cx(styles.body, classNames?.body)}>
|
|
14
|
+
<aside className={cx(styles.sidebar, classNames?.sidebar)}>
|
|
15
|
+
<Headline size="small" weight="medium" as="h1" className={styles.title}>
|
|
16
|
+
{config.title}
|
|
17
|
+
</Headline>
|
|
18
|
+
<ChapterNav tree={tree} />
|
|
19
|
+
</aside>
|
|
20
|
+
<div className={cx(styles.content, classNames?.content)}>{children}</div>
|
|
21
|
+
</Flex>
|
|
22
|
+
<Footer config={config.footer} />
|
|
23
|
+
</Flex>
|
|
24
|
+
)
|
|
25
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
.main {
|
|
2
|
+
--paper-navbar-height: 40px;
|
|
3
|
+
--paper-navbar-padding: var(--rs-space-3);
|
|
4
|
+
--paper-navbar-total: calc(var(--paper-navbar-height) + var(--paper-navbar-padding) * 2 + 1px);
|
|
5
|
+
|
|
6
|
+
flex: 1;
|
|
7
|
+
max-width: 1024px;
|
|
8
|
+
margin: 0 auto;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.navbar {
|
|
12
|
+
height: var(--paper-navbar-height);
|
|
13
|
+
padding: var(--paper-navbar-padding) 0;
|
|
14
|
+
border-bottom: 1px solid var(--rs-color-border-base-primary);
|
|
15
|
+
justify-content: space-between;
|
|
16
|
+
width: 100%;
|
|
17
|
+
position: fixed;
|
|
18
|
+
top: 0;
|
|
19
|
+
background: var(--rs-color-background-neutral-primary);
|
|
20
|
+
z-index: 10;
|
|
21
|
+
max-width: 1024px;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.navLeft {
|
|
25
|
+
align-items: center;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.navRight {
|
|
29
|
+
align-items: center;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.arrow {
|
|
33
|
+
display: flex;
|
|
34
|
+
align-items: center;
|
|
35
|
+
color: var(--rs-color-foreground-base-primary);
|
|
36
|
+
text-decoration: none;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.arrow:hover {
|
|
40
|
+
color: var(--rs-color-foreground-accent-primary);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.arrowDisabled {
|
|
44
|
+
display: flex;
|
|
45
|
+
align-items: center;
|
|
46
|
+
color: var(--rs-color-foreground-base-tertiary);
|
|
47
|
+
opacity: 0.4;
|
|
48
|
+
cursor: default;
|
|
49
|
+
border: none;
|
|
50
|
+
background: none;
|
|
51
|
+
padding: 0;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.breadcrumb {
|
|
55
|
+
font-family: 'SF Mono', 'Fira Code', monospace;
|
|
56
|
+
font-size: var(--rs-font-size-small);
|
|
57
|
+
text-transform: uppercase;
|
|
58
|
+
letter-spacing: 0.05em;
|
|
59
|
+
margin-left: var(--rs-space-3);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.separator {
|
|
63
|
+
margin: 0 var(--rs-space-2);
|
|
64
|
+
color: var(--rs-color-foreground-base-tertiary);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.crumbLink {
|
|
68
|
+
color: var(--rs-color-foreground-base-tertiary);
|
|
69
|
+
text-decoration: none;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.crumbLink:hover {
|
|
73
|
+
color: var(--rs-color-foreground-base-primary);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.crumbActive {
|
|
77
|
+
color: var(--rs-color-foreground-base-primary);
|
|
78
|
+
font-weight: 600;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.article {
|
|
82
|
+
flex: 1;
|
|
83
|
+
min-width: 0;
|
|
84
|
+
margin-top: var(--paper-navbar-total);
|
|
85
|
+
padding: 0 var(--rs-space-7);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.searchButton {
|
|
89
|
+
height: 28px;
|
|
90
|
+
padding: 0 var(--rs-space-3);
|
|
91
|
+
font-size: var(--rs-font-size-small);
|
|
92
|
+
border: none;
|
|
93
|
+
box-shadow: none;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.content {
|
|
97
|
+
font-family: Georgia, 'Times New Roman', serif;
|
|
98
|
+
line-height: 1.8;
|
|
99
|
+
background: var(--rs-color-background-base-primary);
|
|
100
|
+
padding: var(--rs-space-9);
|
|
101
|
+
border-left: 1px solid var(--rs-color-border-base-primary);
|
|
102
|
+
border-right: 1px solid var(--rs-color-border-base-primary);
|
|
103
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 4px 12px rgba(0, 0, 0, 0.04);
|
|
104
|
+
margin-bottom: var(--rs-space-9);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.content h1,
|
|
108
|
+
.content h2,
|
|
109
|
+
.content h3,
|
|
110
|
+
.content h4,
|
|
111
|
+
.content h5,
|
|
112
|
+
.content h6 {
|
|
113
|
+
line-height: 1.4;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.content h1 {
|
|
117
|
+
margin: 2rem 0 1rem;
|
|
118
|
+
font-size: 2rem;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.content h2 {
|
|
122
|
+
margin: 1.75rem 0 0.75rem;
|
|
123
|
+
font-size: 1.5rem;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.content h3 {
|
|
127
|
+
margin: 1.5rem 0 0.5rem;
|
|
128
|
+
font-size: 1.25rem;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.content h4 {
|
|
132
|
+
margin: 1.25rem 0 0.5rem;
|
|
133
|
+
font-size: 1.1rem;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.content h5 {
|
|
137
|
+
margin: 1rem 0 0.5rem;
|
|
138
|
+
font-size: 1rem;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.content h6 {
|
|
142
|
+
margin: 1rem 0 0.5rem;
|
|
143
|
+
font-size: 0.875rem;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.content p {
|
|
147
|
+
margin: 0.75rem 0;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.content ul,
|
|
151
|
+
.content ol {
|
|
152
|
+
margin: 0.75rem 0;
|
|
153
|
+
padding-left: 1.5rem;
|
|
154
|
+
margin-bottom: var(--rs-space-5);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
.content li {
|
|
158
|
+
font-size: var(--rs-font-size-regular);
|
|
159
|
+
margin: var(--rs-space-2) 0;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.content table {
|
|
163
|
+
margin-bottom: var(--rs-space-5);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.content [role="tablist"] {
|
|
167
|
+
margin-bottom: var(--rs-space-3);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.content blockquote {
|
|
171
|
+
margin: 1rem 0;
|
|
172
|
+
padding-left: 1rem;
|
|
173
|
+
border-left: 3px solid var(--rs-color-border-base-primary);
|
|
174
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { useMemo } from 'react'
|
|
4
|
+
import { usePathname } from 'next/navigation'
|
|
5
|
+
import NextLink from 'next/link'
|
|
6
|
+
import { Flex } from '@raystack/apsara'
|
|
7
|
+
import { ChevronLeftIcon, ChevronRightIcon } from '@heroicons/react/24/outline'
|
|
8
|
+
import type { ThemePageProps, PageTreeItem } from '@/types'
|
|
9
|
+
import { Search } from '@/components/ui/search'
|
|
10
|
+
import { ReadingProgress } from './ReadingProgress'
|
|
11
|
+
import styles from './Page.module.css'
|
|
12
|
+
|
|
13
|
+
function flattenTree(items: PageTreeItem[]): PageTreeItem[] {
|
|
14
|
+
const result: PageTreeItem[] = []
|
|
15
|
+
for (const item of items) {
|
|
16
|
+
if (item.type === 'page' && item.url) result.push(item)
|
|
17
|
+
if (item.children) result.push(...flattenTree(item.children))
|
|
18
|
+
}
|
|
19
|
+
return result
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function findBreadcrumb(items: PageTreeItem[], slug: string[]): { label: string; href: string }[] {
|
|
23
|
+
const result: { label: string; href: string }[] = []
|
|
24
|
+
for (let i = 0; i < slug.length; i++) {
|
|
25
|
+
const path = '/' + slug.slice(0, i + 1).join('/')
|
|
26
|
+
const found = findInTree(items, path)
|
|
27
|
+
result.push({ label: found?.name ?? slug[i], href: path })
|
|
28
|
+
}
|
|
29
|
+
return result
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function findInTree(items: PageTreeItem[], path: string): PageTreeItem | undefined {
|
|
33
|
+
for (const item of items) {
|
|
34
|
+
if (item.url === path) return item
|
|
35
|
+
if (item.children) {
|
|
36
|
+
const found = findInTree(item.children, path)
|
|
37
|
+
if (found) return found
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return undefined
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function Page({ page, config, tree }: ThemePageProps) {
|
|
44
|
+
const pathname = usePathname()
|
|
45
|
+
|
|
46
|
+
const { prev, next, crumbs } = useMemo(() => {
|
|
47
|
+
const pages = flattenTree(tree.children)
|
|
48
|
+
const currentIndex = pages.findIndex((p) => p.url === pathname)
|
|
49
|
+
return {
|
|
50
|
+
prev: currentIndex > 0 ? pages[currentIndex - 1] : null,
|
|
51
|
+
next: currentIndex < pages.length - 1 ? pages[currentIndex + 1] : null,
|
|
52
|
+
crumbs: findBreadcrumb(tree.children, page.slug),
|
|
53
|
+
}
|
|
54
|
+
}, [tree, pathname, page.slug])
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<>
|
|
58
|
+
<main className={styles.main}>
|
|
59
|
+
<Flex align="center" className={styles.navbar}>
|
|
60
|
+
<Flex align="center" gap="small" className={styles.navLeft}>
|
|
61
|
+
{prev ? (
|
|
62
|
+
<NextLink href={prev.url!} className={styles.arrow} aria-label="Previous page">
|
|
63
|
+
<ChevronLeftIcon width={14} height={14} />
|
|
64
|
+
</NextLink>
|
|
65
|
+
) : (
|
|
66
|
+
<button disabled className={styles.arrowDisabled} aria-label="Previous page">
|
|
67
|
+
<ChevronLeftIcon width={14} height={14} />
|
|
68
|
+
</button>
|
|
69
|
+
)}
|
|
70
|
+
{next ? (
|
|
71
|
+
<NextLink href={next.url!} className={styles.arrow} aria-label="Next page">
|
|
72
|
+
<ChevronRightIcon width={14} height={14} />
|
|
73
|
+
</NextLink>
|
|
74
|
+
) : (
|
|
75
|
+
<button disabled className={styles.arrowDisabled} aria-label="Next page">
|
|
76
|
+
<ChevronRightIcon width={14} height={14} />
|
|
77
|
+
</button>
|
|
78
|
+
)}
|
|
79
|
+
<nav className={styles.breadcrumb}>
|
|
80
|
+
{crumbs.map((crumb, i) => (
|
|
81
|
+
<span key={crumb.href}>
|
|
82
|
+
{i > 0 && <span className={styles.separator}>/</span>}
|
|
83
|
+
{i === crumbs.length - 1 ? (
|
|
84
|
+
<span className={styles.crumbActive}>{crumb.label}</span>
|
|
85
|
+
) : (
|
|
86
|
+
<NextLink href={crumb.href} className={styles.crumbLink}>
|
|
87
|
+
{crumb.label}
|
|
88
|
+
</NextLink>
|
|
89
|
+
)}
|
|
90
|
+
</span>
|
|
91
|
+
))}
|
|
92
|
+
</nav>
|
|
93
|
+
</Flex>
|
|
94
|
+
<Flex align="center" className={styles.navRight}>
|
|
95
|
+
{config.search?.enabled && <Search className={styles.searchButton} />}
|
|
96
|
+
</Flex>
|
|
97
|
+
</Flex>
|
|
98
|
+
<article className={styles.article} data-article-content>
|
|
99
|
+
<div className={styles.content}>
|
|
100
|
+
{page.content}
|
|
101
|
+
</div>
|
|
102
|
+
</article>
|
|
103
|
+
</main>
|
|
104
|
+
<ReadingProgress items={page.toc} />
|
|
105
|
+
</>
|
|
106
|
+
)
|
|
107
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
.container {
|
|
2
|
+
position: fixed;
|
|
3
|
+
right: var(--rs-space-4);
|
|
4
|
+
top: 100px;
|
|
5
|
+
width: 200px;
|
|
6
|
+
height: calc(100vh - 200px);
|
|
7
|
+
z-index: 10;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.inner {
|
|
11
|
+
position: absolute;
|
|
12
|
+
inset: 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.tickContainer {
|
|
16
|
+
position: absolute;
|
|
17
|
+
right: 0;
|
|
18
|
+
display: grid;
|
|
19
|
+
width: 6rem;
|
|
20
|
+
align-items: center;
|
|
21
|
+
justify-content: flex-end;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.tickLine {
|
|
25
|
+
height: 1px;
|
|
26
|
+
width: 0.5rem;
|
|
27
|
+
transition: all 100ms;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.tickLineBefore {
|
|
31
|
+
background-color: var(--rs-color-foreground-accent-primary);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.tickLineAfter {
|
|
35
|
+
background-color: var(--rs-color-background-neutral-tertiary);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.tickContainer:hover .tickLine {
|
|
39
|
+
width: 1rem;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.tickClickable {
|
|
43
|
+
position: absolute;
|
|
44
|
+
inset-inline: 0;
|
|
45
|
+
height: 0.5rem;
|
|
46
|
+
cursor: pointer;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.headingContainer {
|
|
50
|
+
transition: transform 150ms;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.headingContainer:hover {
|
|
54
|
+
transform: translateX(-0.125rem);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.headingLabel {
|
|
58
|
+
position: absolute;
|
|
59
|
+
display: flex;
|
|
60
|
+
height: 0.75rem;
|
|
61
|
+
align-items: center;
|
|
62
|
+
font-family: var(--rs-font-mono);
|
|
63
|
+
font-size: 0.75rem;
|
|
64
|
+
color: var(--rs-color-foreground-base-primary);
|
|
65
|
+
text-transform: capitalize;
|
|
66
|
+
opacity: 0;
|
|
67
|
+
transition: opacity 300ms;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.headingLink {
|
|
71
|
+
color: var(--rs-color-foreground-base-primary);
|
|
72
|
+
text-align: right;
|
|
73
|
+
font-family: var(--rs-font-mono);
|
|
74
|
+
font-size: var(--rs-font-size-mini);
|
|
75
|
+
font-weight: var(--rs-font-weight-regular);
|
|
76
|
+
line-height: var(--rs-line-height-mini);
|
|
77
|
+
letter-spacing: var(--rs-letter-spacing-mini);
|
|
78
|
+
text-decoration: none;
|
|
79
|
+
cursor: pointer;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.headingLink:hover {
|
|
83
|
+
color: var(--rs-color-foreground-accent-primary);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.container:hover .headingLabel {
|
|
87
|
+
opacity: 1;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.connectingLine {
|
|
91
|
+
position: absolute;
|
|
92
|
+
right: 0;
|
|
93
|
+
height: 1px;
|
|
94
|
+
background-color: var(--rs-color-background-neutral-emphasis);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.scrollMarkerContainer {
|
|
98
|
+
position: absolute;
|
|
99
|
+
right: 0;
|
|
100
|
+
z-index: 20;
|
|
101
|
+
transition: opacity 300ms;
|
|
102
|
+
pointer-events: none;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.scrollMarkerContainerReady {
|
|
106
|
+
opacity: 1;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.scrollMarkerContainerNotReady {
|
|
110
|
+
opacity: 0;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.scrollMarkerLine {
|
|
114
|
+
height: 1px;
|
|
115
|
+
width: 1rem;
|
|
116
|
+
background-color: var(--rs-color-foreground-accent-primary);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.scrollMarkerText {
|
|
120
|
+
position: absolute;
|
|
121
|
+
top: 0;
|
|
122
|
+
left: -2.5rem;
|
|
123
|
+
transform: translateY(-50%);
|
|
124
|
+
font-family: var(--rs-font-mono);
|
|
125
|
+
font-size: 0.75rem;
|
|
126
|
+
color: var(--rs-color-foreground-accent-primary);
|
|
127
|
+
transition: opacity 300ms;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.container:hover .scrollMarkerText {
|
|
131
|
+
opacity: 0;
|
|
132
|
+
}
|