|
94 | 94 | .doc-content td { padding: 10px 12px; border-bottom: 1px solid var(--hairline); color: var(--body); } |
95 | 95 | .doc-content tr:hover td { background: var(--canvas-soft); } |
96 | 96 | .doc-content img { max-width: 100%; border-radius: var(--rounded-md); margin: 16px 0; } |
| 97 | +.doc-content video, .doc-content iframe { max-width: 100%; height: auto; border-radius: var(--rounded-md); margin: 16px 0; display: block; } |
97 | 98 | .doc-content hr { border: none; border-top: 1px solid var(--hairline); margin: 32px 0; } |
98 | 99 |
|
| 100 | +/* Blog meta */ |
| 101 | +.blog-meta { margin-bottom: 32px; padding-bottom: 24px; border-bottom: 1px solid var(--hairline); } |
| 102 | +.blog-meta-title { font-size: 32px; font-weight: 700; letter-spacing: -1.2px; line-height: 1.2; margin-bottom: 16px; color: var(--ink); } |
| 103 | +.blog-meta-info { display: flex; flex-wrap: wrap; align-items: center; gap: 20px; font-size: 14px; color: var(--mute); margin-bottom: 16px; } |
| 104 | +.blog-meta-info span { display: inline-flex; align-items: center; gap: 6px; } |
| 105 | +.blog-meta-info svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; opacity: 0.7; } |
| 106 | +.blog-meta-desc { background: var(--canvas-soft); border-left: 3px solid var(--link); padding: 14px 18px; border-radius: 0 var(--rounded-sm) var(--rounded-sm) 0; font-size: 15px; color: var(--body); line-height: 1.65; margin-top: 4px; } |
| 107 | + |
| 108 | +/* Code copy button */ |
| 109 | +.code-block-wrapper { position: relative; margin-bottom: 20px; } |
| 110 | +.code-block-wrapper pre { margin-bottom: 0; padding-right: 48px; } |
| 111 | +.copy-btn { position: absolute; top: 50%; right: 12px; transform: translateY(-50%); background: rgba(255,255,255,0.15); border: 1px solid rgba(255,255,255,0.2); color: rgba(255,255,255,0.7); width: 32px; height: 32px; border-radius: 6px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background 0.15s, color 0.15s; } |
| 112 | +.copy-btn:hover { background: rgba(255,255,255,0.25); color: #fff; } |
| 113 | +.copy-btn.copied { background: rgba(34,197,94,0.3); border-color: rgba(34,197,94,0.4); color: #4ade80; } |
| 114 | +.copy-btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; } |
| 115 | + |
99 | 116 | /* Page footer */ |
100 | 117 | .doc-footer { margin-top: 64px; padding-top: 24px; border-top: 1px solid var(--hairline); font-size: 13px; color: var(--mute); } |
101 | 118 | .doc-footer a { color: var(--link); text-decoration: none; } |
|
160 | 177 | </aside> |
161 | 178 |
|
162 | 179 | <main class="doc-content"> |
| 180 | + {%- if page.layout == 'doc' and page.date and page.author -%} |
| 181 | + <div class="blog-meta"> |
| 182 | + <h1 class="blog-meta-title">{{ page.title }}</h1> |
| 183 | + <div class="blog-meta-info"> |
| 184 | + <span><svg viewBox="0 0 24 24"><rect x="3" y="4" width="18" height="18" rx="2"/><line x1="16" y1="2" x2="16" y2="6"/><line x1="8" y1="2" x2="8" y2="6"/><line x1="3" y1="10" x2="21" y2="10"/></svg>{{ page.date | date: "%Y-%m-%d" }}</span> |
| 185 | + <span><svg viewBox="0 0 24 24"><path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"/><circle cx="12" cy="7" r="4"/></svg>{{ page.author }}</span> |
| 186 | + </div> |
| 187 | + {%- if page.description -%} |
| 188 | + <p class="blog-meta-desc">{{ page.description }}</p> |
| 189 | + {%- endif -%} |
| 190 | + </div> |
| 191 | + {%- endif -%} |
| 192 | + |
163 | 193 | {{ content }} |
164 | 194 |
|
165 | 195 | <div class="doc-footer"> |
|
168 | 198 | </main> |
169 | 199 | </div> |
170 | 200 |
|
| 201 | +<script> |
| 202 | +document.addEventListener('DOMContentLoaded', function() { |
| 203 | + var pres = document.querySelectorAll('.doc-content pre'); |
| 204 | + pres.forEach(function(pre) { |
| 205 | + var wrapper = document.createElement('div'); |
| 206 | + wrapper.className = 'code-block-wrapper'; |
| 207 | + pre.parentNode.insertBefore(wrapper, pre); |
| 208 | + wrapper.appendChild(pre); |
| 209 | + |
| 210 | + var btn = document.createElement('button'); |
| 211 | + btn.className = 'copy-btn'; |
| 212 | + btn.innerHTML = '<svg viewBox="0 0 24 24"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>'; |
| 213 | + var checkSvg = '<svg viewBox="0 0 24 24"><polyline points="20 6 9 17 4 12"/></svg>'; |
| 214 | + btn.addEventListener('click', function() { |
| 215 | + var code = pre.querySelector('code'); |
| 216 | + var text = code ? code.textContent : pre.textContent; |
| 217 | + navigator.clipboard.writeText(text).then(function() { |
| 218 | + btn.innerHTML = checkSvg; |
| 219 | + btn.classList.add('copied'); |
| 220 | + setTimeout(function() { |
| 221 | + btn.innerHTML = '<svg viewBox="0 0 24 24"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>'; |
| 222 | + btn.classList.remove('copied'); |
| 223 | + }, 2000); |
| 224 | + }); |
| 225 | + }); |
| 226 | + wrapper.appendChild(btn); |
| 227 | + }); |
| 228 | +}); |
| 229 | +</script> |
| 230 | + |
171 | 231 | </body> |
172 | 232 | </html> |
0 commit comments