diff --git a/index.html b/index.html index b3da35c..60f5b2f 100644 --- a/index.html +++ b/index.html @@ -3,7 +3,7 @@ - + @@ -257,6 +257,43 @@ // 读取并解析指定文件 const getMarkdown = async (mdPath, response = null) => { + // 生成目录 + function generateOutline(doc) { + let outline = ''; + } + + if (stack.length === 0 || stack[stack.length - 1].level < level) { + outline += '
  • '; + stack.pop(); + } + + outline += ''; + return outline; + } + if (!response) { response = await fetch(mdPath); if (!response.ok) { @@ -264,9 +301,13 @@ } } var content = marked.parse(await response.text()); - content = `
    ${decodeURIComponent(mdPath)}

    ${content}`; + content = `
    ${decodeURIComponent(mdPath)}

    ${content}`; const parser = new DOMParser(); const doc = parser.parseFromString(content, 'text/html'); + + const outline = generateOutline(doc); + doc.querySelector('.outline').innerHTML += outline; + const links = doc.querySelectorAll('a[href$=".md"]'); const pValue = await getPValue() links.forEach(link => { @@ -505,10 +546,15 @@ background-color: rgba(255, 255, 255, 0.1); } + #c ul, + #c ol { + padding-left: 2rem; + } + #c pre { background-color: rgba(0, 0, 0, 0.05); padding: .4rem; - border-radius: .5rem; + border-radius: .1rem; overflow-y: scroll; } @@ -527,9 +573,25 @@ background-color: rgba(0, 0, 0, 0.05); font-size: small; padding: .4rem; + margin: .5rem 2rem; border-left: 5px solid rgba(0, 0, 0, 0.1); } + #c details { + border: 1px solid rgba(0, 0, 0, 0.1); + border-radius: .1rem; + } + + #c summary { + background-color: rgba(0, 0, 0, 0.05); + padding: .4rem; + font-weight: bold; + } + + #c details a { + margin-left: -2rem; + } + #c table { border-spacing: 0; border-radius: .1rem;