feat: add download .md button to doc viewer

This commit is contained in:
Accusys
2026-05-19 03:29:46 +08:00
parent 6da046e831
commit ef64d69be7

View File

@@ -131,7 +131,8 @@ async function loadDoc(name) {
if (!resp.ok) throw new Error('HTTP ' + resp.status + ' fetching /doc-wasm/modules/' + name + '.md');
const md = await resp.text();
if (!wasm_exports) throw new Error('WASM not loaded');
el.innerHTML = md2html(md);
var dlHtml = '<div style="float:right;margin-bottom:8px"><a href="/doc-wasm/modules/' + name + '.md" download="' + name + '.md" style="text-decoration:none;font-size:13px;color:#0066cc;border:1px solid #0066cc;border-radius:4px;padding:4px 10px">↓ Download .md</a></div>';
el.innerHTML = dlHtml + md2html(md);
if (typeof mermaid !== 'undefined') mermaid.run({nodes:[el.querySelector('.mermaid')].filter(Boolean)});
document.querySelectorAll('.sidebar a.module-link').forEach(function(a) { a.classList.remove('active'); });
var link = document.querySelector('.sidebar a[data-module="' + name + '"]');