File tree 2 files changed +40
-1
lines changed
2 files changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -116,7 +116,13 @@ blockquote {
116
116
border-left : 3px solid # 9ca3af ;
117
117
}
118
118
119
+ .code-block {
120
+ position : relative;
121
+ }
122
+
119
123
.highlight {
124
+ padding-right : 40px ;
125
+
120
126
background-color : rgba (var (--color-light-gray ), 0.5 );
121
127
border : 1px solid rgba (var (--color-light-gray ), 1 );
122
128
border-radius : 2px ;
@@ -132,6 +138,27 @@ blockquote {
132
138
width : fit-content;
133
139
}
134
140
141
+ .clipboard-button {
142
+ position : absolute;
143
+ top : 8px ;
144
+ right : 8px ;
145
+ background : none;
146
+ border : 1px solid # cacfd2 ;
147
+ border-radius : 4px ;
148
+ width : 24px ;
149
+ height : 24px ;
150
+
151
+ padding : 0 ;
152
+ line-height : 24px ;
153
+
154
+ cursor : pointer;
155
+ transition : 0.25s all ease;
156
+ }
157
+
158
+ .clipboard-button : hover {
159
+ background-color : # cacfd2 ;
160
+ }
161
+
135
162
/* SIDEBAR */
136
163
.logo-container {
137
164
width : 100% ;
@@ -345,6 +372,7 @@ h1.centered {
345
372
transform : translateX (100% );
346
373
opacity : 0 ;
347
374
transition : 0.25s all ease;
375
+ z-index : 2 ;
348
376
}
349
377
350
378
.mobile-sidebar .visible {
Original file line number Diff line number Diff line change 6
6
class ArticlesController < ApplicationController
7
7
class HTMLwithPygments < Redcarpet ::Render ::HTML
8
8
def block_code ( code , language )
9
- Pygments . highlight ( code , lexer : language )
9
+ puts code
10
+ result = Pygments . highlight ( code , lexer : language )
11
+ result = "<div class=\" code-block\" >
12
+ #{ result }
13
+ <button class=\" clipboard-button\" onclick=\"
14
+ parent = this.parentElement;
15
+ content = parent.getElementsByClassName('highlight')[0].textContent;
16
+ navigator.clipboard.writeText(content);
17
+ \" >📋</button>
18
+ </div>"
19
+ result
20
+
10
21
end
11
22
end
12
23
You can’t perform that action at this time.
0 commit comments