File tree Expand file tree Collapse file tree 4 files changed +56
-3
lines changed Expand file tree Collapse file tree 4 files changed +56
-3
lines changed Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ const nextConfig = {
78
78
const opts = {
79
79
components : { code : "Code" } ,
80
80
syntaxHighlighting : {
81
- theme : "github-dark" ,
81
+ theme : "github-dark-dimmed " ,
82
82
} ,
83
83
lineNumbers : false ,
84
84
showCopyButton : true ,
Original file line number Diff line number Diff line change @@ -108,3 +108,16 @@ body {
108
108
@apply m-0 text-sm;
109
109
}
110
110
}
111
+
112
+ /* add the code bellow */
113
+ @layer utilities {
114
+ /* Hide scrollbar for Chrome, Safari and Opera */
115
+ .no-scrollbar ::-webkit-scrollbar {
116
+ display : none;
117
+ }
118
+ /* Hide scrollbar for IE, Edge and Firefox */
119
+ .no-scrollbar {
120
+ -ms-overflow-style : none; /* IE and Edge */
121
+ scrollbar-width : none; /* Firefox */
122
+ }
123
+ }
Original file line number Diff line number Diff line change 1
1
import { Pre , RawCode , highlight } from 'codehike/code' ;
2
2
3
+ import { CopyButton } from './copy-button' ;
4
+
3
5
export async function Code ( { codeblock} : { codeblock : RawCode } ) {
4
- const highlighted = await highlight ( codeblock , 'github-dark' ) ;
6
+ const highlighted = await highlight ( codeblock , 'github-dark-dimmed ' ) ;
5
7
return (
6
- < Pre code = { highlighted } handlers = { [ ] } className = "border border-zinc-800" />
8
+ < div className = "relative not-prose mb-3" >
9
+ < CopyButton
10
+ text = { highlighted . code }
11
+ className = "absolute right-px top-px bg-black p-2 rounded-lg"
12
+ />
13
+
14
+ < Pre
15
+ code = { highlighted }
16
+ handlers = { [ ] }
17
+ className = "border pl-3 pr-12 py-2 rounded-lg overflow-auto bg-black text-sm no-scrollbar"
18
+ />
19
+ </ div >
7
20
) ;
8
21
}
Original file line number Diff line number Diff line change
1
+ 'use client' ;
2
+
3
+ import { ComponentProps , useState } from 'react' ;
4
+
5
+ import { Copy , Check } from 'lucide-react' ;
6
+
7
+ export type CopyButtonProps = ComponentProps < 'button' > & {
8
+ text : string ;
9
+ } ;
10
+
11
+ export function CopyButton ( props : CopyButtonProps ) {
12
+ const { text, ...buttonProps } = props ;
13
+ const [ copied , setCopied ] = useState ( false ) ;
14
+
15
+ return (
16
+ < button
17
+ { ...buttonProps }
18
+ aria-label = "Copy to clipboard"
19
+ onClick = { ( ) => {
20
+ navigator . clipboard . writeText ( text ) ;
21
+ setCopied ( true ) ;
22
+ setTimeout ( ( ) => setCopied ( false ) , 1200 ) ;
23
+ } } >
24
+ { copied ? < Check size = { 16 } /> : < Copy size = { 16 } /> }
25
+ </ button >
26
+ ) ;
27
+ }
You can’t perform that action at this time.
0 commit comments