From 1858971885d7c419644fd06a2315d3bb7cfd7764 Mon Sep 17 00:00:00 2001 From: JesseStutler Date: Tue, 31 Dec 2024 17:42:25 +0800 Subject: [PATCH] Upgrade hugo version, fix the js rendering problem in the updated version of hugo and update the css style Signed-off-by: JesseStutler --- config/_default/languages.toml | 13 ++-- config/_default/menus.toml | 13 ++-- netlify.toml | 8 +-- themes/academic/assets/js/academic.js | 40 ++++++++--- .../layouts/partials/css/academic.css | 66 +++++++++++++++---- themes/academic/layouts/partials/footer.html | 48 ++++++++++++++ 6 files changed, 157 insertions(+), 31 deletions(-) diff --git a/config/_default/languages.toml b/config/_default/languages.toml index 1f56bf08..8308f19b 100644 --- a/config/_default/languages.toml +++ b/config/_default/languages.toml @@ -97,23 +97,28 @@ identifier = "concepts" [[zh.menu.docs]] - name = "生态" + name = "关键特性" weight = 4 + identifier = "features" + +[[zh.menu.docs]] + name = "生态" + weight = 5 identifier = "zoology" [[zh.menu.docs]] name = "Scheduler" - weight = 5 + weight = 6 identifier = "scheduler" [[zh.menu.docs]] name = "CLI" - weight = 6 + weight = 7 identifier = "cli" [[zh.menu.docs]] name = "贡献" - weight = 7 + weight = 8 identifier = "contribution" diff --git a/config/_default/menus.toml b/config/_default/menus.toml index 38eae5e2..1d2ebc25 100644 --- a/config/_default/menus.toml +++ b/config/_default/menus.toml @@ -73,23 +73,28 @@ identifier = "concepts" [[docs]] - name = "Ecosystem" + name = "Key Features" weight = 4 + identifier = "features" + +[[docs]] + name = "Ecosystem" + weight = 5 identifier = "ecosystem" [[docs]] name = "Scheduler" - weight = 5 + weight = 6 identifier = "scheduler" [[docs]] name = "CLI" - weight = 6 + weight = 7 identifier = "cli" [[docs]] name = "Contribution" - weight = 7 + weight = 8 identifier = "contribution" diff --git a/netlify.toml b/netlify.toml index 4f18b914..2e9bc9b8 100644 --- a/netlify.toml +++ b/netlify.toml @@ -3,7 +3,7 @@ publish = "public" command = "HUGO_BASEURL=$URL hugo" [context.production.environment] - HUGO_VERSION = "0.57.2" + HUGO_VERSION = "0.79.1" HUGO_ENV = "production" HUGO_ENABLEGITINFO = "true" @@ -11,20 +11,20 @@ HUGO_ENABLEGITINFO = "true" command = "hugo --enableGitInfo" [context.split1.environment] -HUGO_VERSION = "0.57.2" +HUGO_VERSION = "0.79.1" HUGO_ENV = "production" [context.deploy-preview] command = "hugo --buildFuture -b $DEPLOY_PRIME_URL" [context.deploy-preview.environment] -HUGO_VERSION = "0.57.2" +HUGO_VERSION = "0.79.1" [context.branch-deploy] command = "hugo -b $DEPLOY_PRIME_URL" [context.branch-deploy.environment] -HUGO_VERSION = "0.57.2" +HUGO_VERSION = "0.79.1" [context.next.environment] HUGO_ENABLEGITINFO = "true" diff --git a/themes/academic/assets/js/academic.js b/themes/academic/assets/js/academic.js index d90d7ba7..9b329658 100644 --- a/themes/academic/assets/js/academic.js +++ b/themes/academic/assets/js/academic.js @@ -310,16 +310,28 @@ if ($('body').hasClass('dark')) { $('body').css({opacity: 0, visibility: 'visible'}).animate({opacity: 1}, 500); $('body').removeClass('dark'); - $('link[title=hl-light]')[0].disabled = false; - $('link[title=hl-dark]')[0].disabled = true; + let link = document.querySelector('link[title=hl-light]'); + if (link) { + link.disabled = false; + } + let linkDark = document.querySelector('link[title=hl-dark]'); + if (linkDark) { + linkDark.disabled = true; + } $('.js-dark-toggle i').removeClass('fa-sun'); $('.js-dark-toggle i').addClass('fa-moon'); localStorage.setItem('dark_mode', '0'); } else { $('body').css({opacity: 0, visibility: 'visible'}).animate({opacity: 1}, 500); $('body').addClass('dark'); - $('link[title=hl-light]')[0].disabled = true; - $('link[title=hl-dark]')[0].disabled = false; + let link = document.querySelector('link[title=hl-light]'); + if (link) { + link.disabled = true; + } + let linkDark = document.querySelector('link[title=hl-dark]'); + if (linkDark) { + linkDark.disabled = false; + } $('.js-dark-toggle i').removeClass('fa-moon'); $('.js-dark-toggle i').addClass('fa-sun'); localStorage.setItem('dark_mode', '1'); @@ -339,14 +351,26 @@ let dark_mode = parseInt(localStorage.getItem('dark_mode') || default_mode); if (dark_mode) { $('body').addClass('dark'); - $('link[title=hl-light]')[0].disabled = true; - $('link[title=hl-dark]')[0].disabled = false; + let link = document.querySelector('link[title=hl-light]'); + if (link) { + link.disabled = false; + } + let linkDark = document.querySelector('link[title=hl-dark]'); + if (linkDark) { + linkDark.disabled = true; + } $('.js-dark-toggle i').removeClass('fa-moon'); $('.js-dark-toggle i').addClass('fa-sun'); } else { $('body').removeClass('dark'); - $('link[title=hl-light]')[0].disabled = false; - $('link[title=hl-dark]')[0].disabled = true; + let link = document.querySelector('link[title=hl-light]'); + if (link) { + link.disabled = false; + } + let linkDark = document.querySelector('link[title=hl-dark]'); + if (linkDark) { + linkDark.disabled = true; + } $('.js-dark-toggle i').removeClass('fa-sun'); $('.js-dark-toggle i').addClass('fa-moon'); } diff --git a/themes/academic/layouts/partials/css/academic.css b/themes/academic/layouts/partials/css/academic.css index b487cc82..b67dc181 100644 --- a/themes/academic/layouts/partials/css/academic.css +++ b/themes/academic/layouts/partials/css/academic.css @@ -100,16 +100,15 @@ h1 { font-size: 2.25rem; } h2 { + font-weight: 700; margin-top: 1rem; font-size: 1.5rem; } h3 { - font-weight: 700; margin-top: 1.5rem; font-size: 1.25rem; } h4, h5, h6 { - font-weight: 700; margin-top: 1rem; font-size: 1rem; } @@ -174,22 +173,67 @@ figcaption h4 { pre, code { - font-family: '{{ .Get "mono_font" }}', monospace; - color: #c7254e; - background-color: #f9f2f4; + font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace; + font-size: 0.85rem; } pre { - margin: 0 0 1rem 0; - background-color: rgb(248, 248, 248); /* Match default highlight theme. */ - border-color: rgb(248, 248, 248); - font-size: 0.7rem; - border-radius: 4px; + position: relative; /* 为复制按钮定位做准备 */ + margin: 0 0 1.5rem 0; + padding: 1rem; + background-color: #f8f9fa; + border: 1px solid #eee; + border-radius: 6px; + box-shadow: 0 2px 4px rgba(0,0,0,0.05); } pre code { - white-space: pre; /* Override Bootstrap to preserve line breaks in code. */ + white-space: pre; overflow-x: auto; + display: block; + padding: 0; + color: #24292e; + background-color: transparent; +} + +pre::before { + content: attr(data-lang); + display: block; + background: #e9ecef; + color: #666; + font-size: 0.75rem; + padding: 0.2em 0.5em; + border-radius: 3px 3px 0 0; + margin: -1rem -1rem 1rem -1rem; + border-bottom: 1px solid #eee; +} + +.code-copy-btn { + position: absolute; + right: 0.5rem; + top: 0.5rem; + padding: 0.25rem 0.5rem; + font-size: 0.75rem; + color: #666; + background: #fff; + border: 1px solid #eee; + border-radius: 4px; + cursor: pointer; + opacity: 0; + transition: opacity 0.3s; +} + +pre:hover .code-copy-btn { + opacity: 1; +} + +.code-copy-btn:hover { + background: #f8f9fa; + border-color: #ddd; +} + +.code-copy-btn:active { + background: #eee; } hr { diff --git a/themes/academic/layouts/partials/footer.html b/themes/academic/layouts/partials/footer.html index d899e7ce..09338589 100644 --- a/themes/academic/layouts/partials/footer.html +++ b/themes/academic/layouts/partials/footer.html @@ -146,5 +146,53 @@ {{ $js_bundle := $js_bundle | resources.Concat "js/academic-bundle-pre.js" | minify }} {{ $js_bundle := slice $js_bundle_head $js_bundle | resources.Concat "js/academic.min.js" | fingerprint "md5" }} + +