File tree Expand file tree Collapse file tree 4 files changed +66
-46
lines changed
content/post/rich-content Expand file tree Collapse file tree 4 files changed +66
-46
lines changed Original file line number Diff line number Diff line change 123
123
}
124
124
125
125
.article-page.has-toc {
126
-
127
126
.left-sidebar {
128
127
display : none ;
129
128
}
395
394
}
396
395
}
397
396
397
+ .highlight {
398
+ background-color : var (--pre-background-color );
399
+ padding : var (--card-padding );
400
+ position : relative ;
401
+
402
+ & :hover {
403
+ .copyCodeButton {
404
+ opacity : 1 ;
405
+ }
406
+ }
407
+
408
+ pre {
409
+ margin : initial ;
410
+ padding : 0 ;
411
+ margin : 0 ;
412
+ width : auto ;
413
+ }
414
+ }
415
+
416
+ .copyCodeButton {
417
+ position : absolute ;
418
+ top : calc (var (--card-padding ));
419
+ right : calc (var (--card-padding ));
420
+ background : var (--card-background );
421
+ border : none ;
422
+ box-shadow : var (--shadow-l2 );
423
+ border-radius : var (--tag-border-radius );
424
+ padding : 8px 16px ;
425
+ color : var (--card-text-color-main );
426
+ cursor : pointer ;
427
+ font-size : 14px ;
428
+ opacity : 0 ;
429
+ transition : opacity 0.3s ease ;
430
+ }
431
+
398
432
.table-wrapper {
399
433
padding : 0 var (--card-padding );
400
434
overflow-x : auto ;
449
483
/// Negative margins
450
484
blockquote ,
451
485
figure ,
486
+ .highlight ,
452
487
pre ,
453
488
.gallery ,
454
489
.video-wrapper ,
458
493
margin-right : calc ((var (--card-padding )) * -1 );
459
494
width : calc (100% + var (--card-padding ) * 2 );
460
495
}
461
-
462
- .highlight {
463
- position : relative ;
464
-
465
- & :hover {
466
- .copyCodeButton {
467
- opacity : 1 ;
468
- }
469
- }
470
- }
471
-
472
- .copyCodeButton {
473
- position : absolute ;
474
- top : calc (var (--card-padding ));
475
- right : 0 ;
476
- background : var (--card-background );
477
- border : none ;
478
- box-shadow : var (--shadow-l2 );
479
- border-radius : var (--tag-border-radius );
480
- padding : 8px 16px ;
481
- color : var (--card-text-color-main );
482
- cursor : pointer ;
483
- font-size : 14px ;
484
- opacity : 0 ;
485
- transition : opacity 0.3s ease ;
486
- }
487
496
}
Original file line number Diff line number Diff line change @@ -62,20 +62,21 @@ let Stack = {
62
62
/**
63
63
* Add copy button to code block
64
64
*/
65
- const codeBlocks = document . querySelectorAll ( '.article-content > div.highlight' ) ;
65
+ const highlights = document . querySelectorAll ( '.article-content div.highlight' ) ;
66
66
const copyText = `Copy` ,
67
67
copiedText = `Copied!` ;
68
- codeBlocks . forEach ( codeBlock => {
68
+
69
+ highlights . forEach ( highlight => {
69
70
const copyButton = document . createElement ( 'button' ) ;
70
71
copyButton . innerHTML = copyText ;
71
72
copyButton . classList . add ( 'copyCodeButton' ) ;
72
- codeBlock . appendChild ( copyButton ) ;
73
+ highlight . appendChild ( copyButton ) ;
73
74
74
- const pre = codeBlock . getElementsByTagName ( 'pre ') ;
75
- const code = pre [ 0 ] . textContent ;
75
+ const codeBlock = highlight . querySelector ( 'code[data-lang] ') ;
76
+ if ( ! codeBlock ) return ;
76
77
77
78
copyButton . addEventListener ( 'click' , ( ) => {
78
- navigator . clipboard . writeText ( code )
79
+ navigator . clipboard . writeText ( codeBlock . textContent )
79
80
. then ( ( ) => {
80
81
copyButton . textContent = copiedText ;
81
82
Original file line number Diff line number Diff line change @@ -109,7 +109,7 @@ params:
109
109
defaultHomeserverUrl : " https://matrix.cactus.chat:8448"
110
110
serverName : " cactus.chat"
111
111
siteName : " " # You must insert a unique identifier here matching the one you registered (See https://cactus.chat/docs/getting-started/quick-start/#register-your-site)
112
-
112
+
113
113
giscus :
114
114
repo :
115
115
repoID :
@@ -122,15 +122,15 @@ params:
122
122
emitMetadata : 0
123
123
124
124
gitalk :
125
- owner :
126
- admin :
127
- repo :
128
- clientID :
129
- clientSecret :
130
-
125
+ owner :
126
+ admin :
127
+ repo :
128
+ clientID :
129
+ clientSecret :
130
+
131
131
cusdis :
132
- host :
133
- id :
132
+ host :
133
+ id :
134
134
widgets :
135
135
enabled :
136
136
- search
@@ -183,19 +183,19 @@ menu:
183
183
# ## For demonstration purpose, the home link will be open in a new tab
184
184
newTab : true
185
185
icon : home
186
-
186
+
187
187
social :
188
188
- identifier : github
189
189
name : GitHub
190
190
url : https://github.com/CaiJimmy/hugo-theme-stack
191
191
params :
192
- icon : brand-github
193
-
192
+ icon : brand-github
193
+
194
194
- identifier : twitter
195
195
name : Twitter
196
196
url : https://twitter.com
197
197
params :
198
- icon : brand-twitter
198
+ icon : brand-twitter
199
199
200
200
related :
201
201
includeNewer : true
@@ -219,3 +219,9 @@ markup:
219
219
startLevel : 2
220
220
highlight :
221
221
noClasses : false
222
+ codeFences : true
223
+ guessSyntax : true
224
+ lineNoStart : 1
225
+ lineNos : true
226
+ lineNumbersInTable : true
227
+ tabWidth : 4
Original file line number Diff line number Diff line change @@ -36,3 +36,7 @@ Hugo ships with several [Built-in Shortcodes](https://gohugo.io/content-manageme
36
36
## bilibilibi Shortcode
37
37
38
38
{{< bilibili av498363026 >}}
39
+
40
+ ## Gist Shortcode
41
+
42
+ {{< gist spf13 7896402 >}}
You can’t perform that action at this time.
0 commit comments