|
15 | 15 | <link rel="stylesheet" href="/css/syntax.css?v={{ site.time | date: '%s' }}" type="text/css" /> |
16 | 16 | <link rel="stylesheet" href="/css/screen.css?v={{ site.time | date: '%s' }}" type="text/css" /> |
17 | 17 |
|
| 18 | + {% if page.math %} |
18 | 19 | <!-- KaTeX CSS & JS for Math equations --> |
19 | 20 | <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.8/dist/katex.min.css" crossorigin="anonymous"> |
20 | 21 | <script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.8/dist/katex.min.js" crossorigin="anonymous"></script> |
21 | 22 | <script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.8/dist/contrib/auto-render.min.js" crossorigin="anonymous" |
22 | | - onload="renderMathInElement(document.body, {delimiters: [{left: '$$', right: '$$', display: true}, {left: '$', right: '$', display: false}, {left: '\\\[', right: '\\\]', display: true}, {left: '\\\(', right: '\\\)', display: false}], throwOnError: false});"></script> |
| 23 | + onload="renderMathInElement(document.body, {delimiters: [{left: '$$', right: '$$', display: true}, {left: '$', right: '$', display: false}, {left: '\\\\[', right: '\\\\]', display: true}, {left: '\\\\(', right: '\\\\)', display: false}], throwOnError: false});"></script> |
| 24 | + {% endif %} |
23 | 25 |
|
24 | 26 | <!-- Theme Initialization Script (Avoid Flash of Unstyled Theme) --> |
25 | 27 | <script> |
|
87 | 89 |
|
88 | 90 | <!-- Interactive Scripts: Theme Toggle, Code Block Copy, Rich Note Engine --> |
89 | 91 | <script src="/js/rich-note.js?v={{ site.time | date: '%s' }}" defer></script> |
90 | | - <script> |
91 | | - document.addEventListener('DOMContentLoaded', function() { |
92 | | - // Theme Switcher Logic |
93 | | - const toggleBtn = document.getElementById('theme-toggle'); |
94 | | - const themeIconContainer = document.getElementById('theme-icon-container'); |
95 | | - const themeLabel = document.getElementById('theme-label'); |
96 | | - |
97 | | - const sunSVG = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="4"/><path d="M12 2v2"/><path d="M12 20v2"/><path d="m4.93 4.93 1.41 1.41"/><path d="m17.66 17.66 1.41 1.41"/><path d="M2 12h2"/><path d="M20 12h2"/><path d="m6.34 17.66-1.41 1.41"/><path d="m19.07 4.93-1.41 1.41"/></svg>`; |
98 | | - const moonSVG = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"/></svg>`; |
99 | | - |
100 | | - function updateThemeUI(theme) { |
101 | | - if (theme === 'dark') { |
102 | | - if (themeIconContainer) themeIconContainer.innerHTML = sunSVG; |
103 | | - themeLabel.textContent = 'Light'; |
104 | | - } else { |
105 | | - if (themeIconContainer) themeIconContainer.innerHTML = moonSVG; |
106 | | - themeLabel.textContent = 'Dark'; |
107 | | - } |
108 | | - } |
109 | | - |
110 | | - const currentTheme = document.documentElement.getAttribute('data-theme') || 'light'; |
111 | | - updateThemeUI(currentTheme); |
112 | | - |
113 | | - toggleBtn.addEventListener('click', function() { |
114 | | - const activeTheme = document.documentElement.getAttribute('data-theme'); |
115 | | - const newTheme = activeTheme === 'dark' ? 'light' : 'dark'; |
116 | | - document.documentElement.setAttribute('data-theme', newTheme); |
117 | | - localStorage.setItem('42devops-theme', newTheme); |
118 | | - updateThemeUI(newTheme); |
119 | | - }); |
120 | | - |
121 | | - // Code Block Enhancement: Wrap with Header & Copy Button |
122 | | - const highlightBlocks = document.querySelectorAll('.highlight, pre:not(.highlight pre)'); |
123 | | - highlightBlocks.forEach(function(block) { |
124 | | - // Avoid double wrapping |
125 | | - if (block.closest('.code-wrapper')) return; |
126 | | - |
127 | | - const wrapper = document.createElement('div'); |
128 | | - wrapper.className = 'code-wrapper'; |
129 | | - |
130 | | - const header = document.createElement('div'); |
131 | | - header.className = 'code-header'; |
132 | | - |
133 | | - const dots = document.createElement('div'); |
134 | | - dots.className = 'code-dots'; |
135 | | - dots.innerHTML = '<span class="code-dot code-dot-red"></span><span class="code-dot code-dot-yellow"></span><span class="code-dot code-dot-green"></span>'; |
136 | | - |
137 | | - const copyBtn = document.createElement('button'); |
138 | | - copyBtn.className = 'copy-btn'; |
139 | | - copyBtn.textContent = 'Copy'; |
140 | | - |
141 | | - copyBtn.addEventListener('click', function() { |
142 | | - const codeText = block.querySelector('code') ? block.querySelector('code').innerText : block.innerText; |
143 | | - navigator.clipboard.writeText(codeText).then(function() { |
144 | | - copyBtn.textContent = 'Copied!'; |
145 | | - setTimeout(function() { copyBtn.textContent = 'Copy'; }, 2000); |
146 | | - }); |
147 | | - }); |
148 | | - |
149 | | - header.appendChild(dots); |
150 | | - header.appendChild(copyBtn); |
151 | | - |
152 | | - block.parentNode.insertBefore(wrapper, block); |
153 | | - wrapper.appendChild(header); |
154 | | - wrapper.appendChild(block); |
155 | | - }); |
156 | | - }); |
157 | | - </script> |
| 92 | + <script src="/js/main.js?v={{ site.time | date: '%s' }}" defer></script> |
158 | 93 | </body> |
159 | 94 | </html> |
0 commit comments