From c8231bae479cf15d2210e8ece0b000019704ade6 Mon Sep 17 00:00:00 2001 From: CyC2018 Date: Sat, 31 Oct 2026 14:31:33 +0800 Subject: [PATCH] Update site.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 学习路线文章开头加学习站入口。 --- website/templates/site.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/website/templates/site.js b/website/templates/site.js index d639c7fb..c4c14f11 100644 --- a/website/templates/site.js +++ b/website/templates/site.js @@ -193,6 +193,18 @@ } preserveLegacyLinks(); window.addEventListener('hashchange', preserveLegacyLinks); + // 学习路线的文章开头提示可以在学习站中按这条路线定级、排计划 + var LEARN_ROUTES = { 'Java 后端': 'java', '大模型应用开发': 'llm', '面试冲刺': 'sprint' }; + function learnCallout(vm, section) { + var match = decode(vm.route.path).match(/^\/notes\/学习路线 - (.+)$/), id = match && LEARN_ROUTES[match[1]]; + if (!section || !id || section.querySelector('.learn-callout')) return; + var box = document.createElement('a'); + box.className = 'learn-callout'; + box.href = '/learn/#/start/' + id; + box.innerHTML = '在学习站中按这条路线学先做一轮自评定级,跳过已经掌握的天,按每天的时间和面试日期排出计划,自评过的题按间隔复习。'; + var heading = section.querySelector('h1'); + (heading || section.firstChild).insertAdjacentElement(heading ? 'afterend' : 'beforebegin', box); + } window.$docsify = { name: 'CS-Notes', repo: 'https://github.com/CyC2018/CS-Notes', @@ -226,6 +238,7 @@ configureImages(document.querySelector('.markdown-section'), vm.route.path === '/'); stepAnimations(document.querySelector('.markdown-section')); articleToc(vm); + learnCallout(vm, document.querySelector('.markdown-section')); document.querySelectorAll('.article-toc').forEach(function (toc) { toc.open = window.matchMedia('(min-width: 769px)').matches; });