🚧 Change the code block style settings.

This commit is contained in:
凡梦星尘 2022-06-29 08:56:13 +08:00
parent 748c44e25d
commit b9cd603c04
5 changed files with 44 additions and 37 deletions

View File

@ -1,6 +1,3 @@
.highlight:hover .copy-btn, pre:hover .copy-btn {
opacity: 1;
}
.highlight {
@ -15,7 +12,13 @@
}
}
.copy-btn {
@if $codeblock_copy_btn_enable {
.highlight:hover .copy-btn, pre:hover .copy-btn {
opacity: 1;
}
.copy-btn {
color: $black-dim;
cursor: pointer;
line-height: 1.6;
@ -27,12 +30,12 @@
transition: opacity $transition-ease;
background: var(--highlight-background);
@if $codeblock_copy_btn_style == 'flat' {
@if $codeblock_style == 'flat' {
background: white;
border: 0;
font-size: $font-size-smaller;
} @else if $codeblock_copy_btn_style == 'mac' {
} @else if $codeblock_style == 'mac' {
color: var(--highlight-foreground);
font-size: 14px;
border-radius: 3px;
@ -44,9 +47,10 @@
font-size: $font-size-smaller;
}
}
}
@if $codeblock_copy_btn_style == 'mac' {
@if $codeblock_style == 'mac' {
.highlight {
border-radius: 5px;
box-shadow: 0 10px 30px 0 rgba(0, 0, 0, .4);

View File

@ -52,7 +52,8 @@ $highlight_dark_foreground : #fff;
$highlight_light_background : #565656;
$highlight_light_foreground : #fff;
$codeblock_copy_btn_style : {{ $P.codeblock.copyBtn.style }};
$codeblock_copy_btn_enable : {{ $P.codeblock.copyBtn }};
$codeblock_style : {{ $P.codeblock.style }};
// Sidebar
$sidebar_offset : {{ $P.sidebar.offset }};
@ -113,7 +114,9 @@ $reading_progress_reversed : {{ $P.readingProgress.reversed }};
// Thirdparty
$math_mathjax_enable : {{ $P.math.mathjax.enable }};
$related_posts_enable : {{ $P.relatedPosts.enable }};
// TODO
//$related_posts_enable : {{ $P.relatedPosts.enable }};
$related_posts_enable : false;
$pdf_enable : {{ $P.pdf.enable }};
$pdf_height : {{ $P.pdf.height }};

View File

@ -10,7 +10,7 @@ if (!window.NexT) window.NexT = {};
"darkmode" : {{ .Site.Params.darkmode }},
"version" : "{{ .Site.Data.config.version }}",
"sidebar" : {{ .Site.Params.sidebar | jsonify }},
"copycode" : {{ .Site.Params.codeblock.copyBtn | jsonify }},
"copybtn" : {{ .Site.Params.codeblock.copyBtn }},
"bookmark" : {{ .Site.Params.bookmark | jsonify }},
"comments" : {{ .Site.Params.comments | jsonify }},
"mediumzoom" : {{ .Site.Params.mediumzoom }},

View File

@ -45,7 +45,7 @@ NexT.boot.refresh = function() {
CONFIG.pangu && window.pangu.spacingPage();
CONFIG.isPage && NexT.utils.replacePostCRLink();
CONFIG.isPage && NexT.utils.registerCopyCode();
CONFIG.isPage && CONFIG.copybtn && NexT.utils.registerCopyCode();
NexT.utils.registerTabsTag();
/*NexT.utils.registerActiveMenuItem();
NexT.utils.registerLangSelect();*/

View File

@ -41,7 +41,7 @@ NexT.utils = {
*/
registerCopyCode: function() {
let figure = document.querySelectorAll('.highlight pre');
if (figure.length === 0 || !CONFIG.copycode) return;
if (figure.length === 0 || !CONFIG.copybtn) return;
figure.forEach(element => {
let cn = element.querySelector('code').className;
// TODO seems hard code need find other ways fixed it.