polen 0.9.0-next.4 → 0.9.0-next.6
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/build/api/singletons/markdown/markdown.d.ts.map +1 -1
- package/build/api/singletons/markdown/markdown.js +33 -11
- package/build/api/singletons/markdown/markdown.js.map +1 -1
- package/build/api/vite/plugins/pages.d.ts.map +1 -1
- package/build/api/vite/plugins/pages.js +17 -0
- package/build/api/vite/plugins/pages.js.map +1 -1
- package/build/lib/shiki/index.d.ts +2 -0
- package/build/lib/shiki/index.d.ts.map +1 -0
- package/build/lib/shiki/index.js +2 -0
- package/build/lib/shiki/index.js.map +1 -0
- package/build/lib/shiki/shiki.d.ts +26 -0
- package/build/lib/shiki/shiki.d.ts.map +1 -0
- package/build/lib/shiki/shiki.js +105 -0
- package/build/lib/shiki/shiki.js.map +1 -0
- package/build/template/components/CodeBlock.d.ts +17 -0
- package/build/template/components/CodeBlock.d.ts.map +1 -0
- package/build/template/components/CodeBlock.jsx +42 -0
- package/build/template/components/CodeBlock.jsx.map +1 -0
- package/build/template/components/sidebar/Sidebar.d.ts +5 -3
- package/build/template/components/sidebar/Sidebar.d.ts.map +1 -1
- package/build/template/components/sidebar/Sidebar.jsx +3 -3
- package/build/template/components/sidebar/Sidebar.jsx.map +1 -1
- package/build/template/entry.client.jsx +1 -0
- package/build/template/entry.client.jsx.map +1 -1
- package/build/template/routes/root.d.ts.map +1 -1
- package/build/template/routes/root.jsx +56 -29
- package/build/template/routes/root.jsx.map +1 -1
- package/package.json +9 -1
- package/src/api/singletons/markdown/markdown.test.ts +89 -0
- package/src/api/singletons/markdown/markdown.ts +35 -13
- package/src/api/vite/plugins/pages.ts +17 -0
- package/src/lib/shiki/index.ts +1 -0
- package/src/lib/shiki/shiki.test.ts +107 -0
- package/src/lib/shiki/shiki.ts +161 -0
- package/src/template/components/CodeBlock.tsx +73 -0
- package/src/template/components/sidebar/Sidebar.tsx +7 -5
- package/src/template/entry.client.tsx +1 -0
- package/src/template/routes/root.tsx +90 -46
- package/src/template/styles/code-block.css +186 -0
@@ -1,7 +1,7 @@
|
|
1
1
|
import type { ReactRouter } from '#dep/react-router/index'
|
2
2
|
import { createRoute } from '#lib/react-router-aid/react-router-aid'
|
3
3
|
import { GitHubLogoIcon } from '@radix-ui/react-icons'
|
4
|
-
import { Box, Button, Heading, Text } from '@radix-ui/themes'
|
4
|
+
import { Box, Button, Grid, Heading, Text } from '@radix-ui/themes'
|
5
5
|
import { Flex, Theme } from '@radix-ui/themes'
|
6
6
|
import radixStylesUrl from '@radix-ui/themes/styles.css?url'
|
7
7
|
import { Arr } from '@wollybeard/kit'
|
@@ -75,53 +75,97 @@ const Layout = () => {
|
|
75
75
|
|
76
76
|
const currentNavPathExp = getCurrentNavPathExp()
|
77
77
|
const sidebar = currentNavPathExp && projectDataPages.sidebarIndex[currentNavPathExp]
|
78
|
-
const
|
78
|
+
const isShowSidebar = sidebar && sidebar.items.length > 0
|
79
|
+
|
80
|
+
const header = (
|
81
|
+
<Flex
|
82
|
+
gridArea={'header'}
|
83
|
+
align='center'
|
84
|
+
gap='8'
|
85
|
+
pb='4'
|
86
|
+
mb='8'
|
87
|
+
style={{
|
88
|
+
borderBottom: `1px solid var(--gray-3)`,
|
89
|
+
}}
|
90
|
+
>
|
91
|
+
<LinkReactRouter
|
92
|
+
to='/'
|
93
|
+
style={{ color: `inherit`, textDecoration: `none` }}
|
94
|
+
>
|
95
|
+
<Flex align='center' gap='2'>
|
96
|
+
<GitHubLogoIcon style={{ width: 30, height: 30 }} />
|
97
|
+
<Text size='3' weight='medium'>
|
98
|
+
{templateVariables.title}
|
99
|
+
</Text>
|
100
|
+
</Flex>
|
101
|
+
</LinkReactRouter>
|
102
|
+
<Flex direction='row' gap='4'>
|
103
|
+
{projectDataNavbar.map((item, key) => (
|
104
|
+
<Link key={key} color='gray' to={item.pathExp}>
|
105
|
+
{item.title}
|
106
|
+
</Link>
|
107
|
+
))}
|
108
|
+
</Flex>
|
109
|
+
</Flex>
|
110
|
+
)
|
111
|
+
|
79
112
|
return (
|
80
113
|
<Theme asChild>
|
81
|
-
<
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
>
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
114
|
+
<Grid
|
115
|
+
width={{ initial: 'var(--container-4)' }}
|
116
|
+
areas="'header header header header header header header header' 'sidebar sidebar . content content content content content'"
|
117
|
+
rows='min-content auto'
|
118
|
+
columns='repeat(8, 1fr)'
|
119
|
+
gapX='2'
|
120
|
+
my='8'
|
121
|
+
mx='auto'
|
122
|
+
>
|
123
|
+
<style>{`
|
124
|
+
/* Shiki code blocks */
|
125
|
+
pre.shiki {
|
126
|
+
margin: 1rem 0;
|
127
|
+
padding: 1rem;
|
128
|
+
border-radius: 8px;
|
129
|
+
overflow-x: auto;
|
130
|
+
font-size: 14px;
|
131
|
+
line-height: 1.6;
|
132
|
+
background-color: #f6f8fa;
|
133
|
+
}
|
134
|
+
|
135
|
+
/* Light mode: use --shiki-light CSS variables from inline styles */
|
136
|
+
pre.shiki span {
|
137
|
+
color: var(--shiki-light);
|
138
|
+
}
|
139
|
+
|
140
|
+
/* Dark mode - Radix Themes uses [data-is-root-theme="dark"] */
|
141
|
+
[data-is-root-theme="dark"] pre.shiki {
|
142
|
+
background-color: #1a1b26;
|
143
|
+
}
|
144
|
+
|
145
|
+
[data-is-root-theme="dark"] pre.shiki span {
|
146
|
+
color: var(--shiki-dark);
|
147
|
+
}
|
148
|
+
|
149
|
+
pre.shiki code {
|
150
|
+
font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, 'Liberation Mono', Menlo, monospace;
|
151
|
+
background: transparent;
|
152
|
+
display: block;
|
153
|
+
}
|
154
|
+
`}</style>
|
155
|
+
{header}
|
156
|
+
{isShowSidebar && (
|
157
|
+
<Sidebar
|
158
|
+
gridColumn='1 / 3'
|
159
|
+
gridRow='2 / auto'
|
160
|
+
data={sidebar.items}
|
161
|
+
// ml='-100px'
|
162
|
+
// style={{ transform: 'translate(calc(-100% - var(--space-8)))' }}
|
163
|
+
/>
|
164
|
+
)}
|
165
|
+
<Box gridArea='content / content / auto / 8'>
|
166
|
+
<Outlet />
|
167
|
+
</Box>
|
168
|
+
</Grid>
|
125
169
|
</Theme>
|
126
170
|
)
|
127
171
|
}
|
@@ -0,0 +1,186 @@
|
|
1
|
+
/* Code Block Styles */
|
2
|
+
|
3
|
+
/* Base code block container */
|
4
|
+
.code-block {
|
5
|
+
position: relative;
|
6
|
+
margin: 1rem 0;
|
7
|
+
border-radius: 8px;
|
8
|
+
overflow: hidden;
|
9
|
+
font-size: 14px;
|
10
|
+
line-height: 1.6;
|
11
|
+
}
|
12
|
+
|
13
|
+
.code-block pre {
|
14
|
+
margin: 0;
|
15
|
+
padding: 1rem;
|
16
|
+
overflow-x: auto;
|
17
|
+
background: inherit;
|
18
|
+
}
|
19
|
+
|
20
|
+
.code-block code {
|
21
|
+
font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, 'Liberation Mono', Menlo, monospace;
|
22
|
+
font-variant-ligatures: contextual;
|
23
|
+
}
|
24
|
+
|
25
|
+
/* Shiki theme switching with CSS variables */
|
26
|
+
/* Default to light theme */
|
27
|
+
:root {
|
28
|
+
color-scheme: light;
|
29
|
+
}
|
30
|
+
|
31
|
+
/* When dark mode is active */
|
32
|
+
.dark {
|
33
|
+
color-scheme: dark;
|
34
|
+
}
|
35
|
+
|
36
|
+
/* Shiki code blocks */
|
37
|
+
pre.shiki {
|
38
|
+
margin: 1rem 0;
|
39
|
+
padding: 1rem;
|
40
|
+
border-radius: 8px;
|
41
|
+
overflow-x: auto;
|
42
|
+
font-size: 14px;
|
43
|
+
line-height: 1.6;
|
44
|
+
}
|
45
|
+
|
46
|
+
pre.shiki code {
|
47
|
+
font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, 'Liberation Mono', Menlo, monospace;
|
48
|
+
font-variant-ligatures: contextual;
|
49
|
+
}
|
50
|
+
|
51
|
+
/* Line numbers */
|
52
|
+
.code-block[data-line-numbers="true"] pre {
|
53
|
+
padding-left: 3.5rem;
|
54
|
+
position: relative;
|
55
|
+
}
|
56
|
+
|
57
|
+
.code-block[data-line-numbers="true"] .line {
|
58
|
+
position: relative;
|
59
|
+
}
|
60
|
+
|
61
|
+
.code-block[data-line-numbers="true"] .line::before {
|
62
|
+
content: attr(data-line);
|
63
|
+
position: absolute;
|
64
|
+
left: -3rem;
|
65
|
+
width: 2.5rem;
|
66
|
+
text-align: right;
|
67
|
+
color: var(--gray-a6);
|
68
|
+
user-select: none;
|
69
|
+
}
|
70
|
+
|
71
|
+
/* Line highlighting */
|
72
|
+
.code-block .line[data-highlighted="true"] {
|
73
|
+
background-color: var(--amber-a3);
|
74
|
+
display: block;
|
75
|
+
margin: 0 -1rem;
|
76
|
+
padding: 0 1rem;
|
77
|
+
}
|
78
|
+
|
79
|
+
/* Diff lines */
|
80
|
+
.code-block .line[data-diff="+"] {
|
81
|
+
background-color: var(--green-a3);
|
82
|
+
display: block;
|
83
|
+
margin: 0 -1rem;
|
84
|
+
padding: 0 1rem;
|
85
|
+
}
|
86
|
+
|
87
|
+
.code-block .line[data-diff="-"] {
|
88
|
+
background-color: var(--red-a3);
|
89
|
+
display: block;
|
90
|
+
margin: 0 -1rem;
|
91
|
+
padding: 0 1rem;
|
92
|
+
}
|
93
|
+
|
94
|
+
.code-block .line[data-diff="+"]::before {
|
95
|
+
content: "+ ";
|
96
|
+
color: var(--green-11);
|
97
|
+
font-weight: bold;
|
98
|
+
}
|
99
|
+
|
100
|
+
.code-block .line[data-diff="-"]::before {
|
101
|
+
content: "- ";
|
102
|
+
color: var(--red-11);
|
103
|
+
font-weight: bold;
|
104
|
+
}
|
105
|
+
|
106
|
+
/* Focus lines */
|
107
|
+
.code-block .line:not([data-focus="true"]) {
|
108
|
+
opacity: 0.5;
|
109
|
+
filter: grayscale(100%);
|
110
|
+
transition: opacity 0.2s, filter 0.2s;
|
111
|
+
}
|
112
|
+
|
113
|
+
.code-block:hover .line:not([data-focus="true"]) {
|
114
|
+
opacity: 0.8;
|
115
|
+
filter: grayscale(0%);
|
116
|
+
}
|
117
|
+
|
118
|
+
/* Copy button */
|
119
|
+
.code-block-copy {
|
120
|
+
position: absolute;
|
121
|
+
top: 0.5rem;
|
122
|
+
right: 0.5rem;
|
123
|
+
padding: 0.25rem 0.5rem;
|
124
|
+
border-radius: 4px;
|
125
|
+
background: var(--gray-a3);
|
126
|
+
color: var(--gray-12);
|
127
|
+
border: 1px solid var(--gray-a5);
|
128
|
+
cursor: pointer;
|
129
|
+
font-size: 12px;
|
130
|
+
transition: all 0.2s;
|
131
|
+
}
|
132
|
+
|
133
|
+
.code-block-copy:hover {
|
134
|
+
background: var(--gray-a4);
|
135
|
+
border-color: var(--gray-a6);
|
136
|
+
}
|
137
|
+
|
138
|
+
.code-block-copy.copied {
|
139
|
+
background: var(--green-a3);
|
140
|
+
border-color: var(--green-a5);
|
141
|
+
color: var(--green-11);
|
142
|
+
}
|
143
|
+
|
144
|
+
/* Language badge */
|
145
|
+
.code-block-lang {
|
146
|
+
position: absolute;
|
147
|
+
top: 0;
|
148
|
+
right: 0;
|
149
|
+
padding: 0.25rem 0.75rem;
|
150
|
+
background: var(--gray-a3);
|
151
|
+
color: var(--gray-11);
|
152
|
+
font-size: 12px;
|
153
|
+
font-weight: 500;
|
154
|
+
border-bottom-left-radius: 4px;
|
155
|
+
user-select: none;
|
156
|
+
}
|
157
|
+
|
158
|
+
/* Scrollbar styling */
|
159
|
+
.code-block pre::-webkit-scrollbar {
|
160
|
+
height: 8px;
|
161
|
+
width: 8px;
|
162
|
+
}
|
163
|
+
|
164
|
+
.code-block pre::-webkit-scrollbar-track {
|
165
|
+
background: var(--gray-a3);
|
166
|
+
border-radius: 4px;
|
167
|
+
}
|
168
|
+
|
169
|
+
.code-block pre::-webkit-scrollbar-thumb {
|
170
|
+
background: var(--gray-a6);
|
171
|
+
border-radius: 4px;
|
172
|
+
}
|
173
|
+
|
174
|
+
.code-block pre::-webkit-scrollbar-thumb:hover {
|
175
|
+
background: var(--gray-a7);
|
176
|
+
}
|
177
|
+
|
178
|
+
/* Inline code */
|
179
|
+
code:not(.code-block code) {
|
180
|
+
padding: 0.2em 0.4em;
|
181
|
+
margin: 0;
|
182
|
+
font-size: 0.85em;
|
183
|
+
background-color: var(--gray-a3);
|
184
|
+
border-radius: 4px;
|
185
|
+
font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, 'Liberation Mono', Menlo, monospace;
|
186
|
+
}
|