kopia lustrzana https://github.com/badgen/badgen.net
(doc pages): add links to scheme title
rodzic
e28b59dc88
commit
76904c13d6
|
@ -44,12 +44,26 @@ export default function genHelp (id) {
|
|||
md += '## Examples\n\n'
|
||||
|
||||
Object.entries(egCats).forEach(([cat, egs]) => {
|
||||
// category title (scheme)
|
||||
const hash = hashify(cat)
|
||||
md += `\n\n<h4 id="${hash}"><a href="#${hash}">
|
||||
<code>${cat.replace(/</g, '<')}</code>
|
||||
</a></h4>\n\n`
|
||||
|
||||
// category example list
|
||||
// @ts-ignore
|
||||
const egList = egs.map(([url, desc]) => {
|
||||
return `- ![${url}](${url}) [${url}](${url}) <i>${desc}</i>`
|
||||
}).join('\n')
|
||||
md += `\n\n__\`${cat}\`__\n${egList}`
|
||||
})
|
||||
md += egList.join('\n')
|
||||
})
|
||||
|
||||
return md
|
||||
}
|
||||
|
||||
// turn `/github/:topic<commits|last-commit>/:owner/:repo/:ref?`
|
||||
// into `github-topic-commits-last-commit-owner-repo-ref`
|
||||
function hashify (str: string) {
|
||||
// return str.replace(/[^\w]/g, '')
|
||||
return str.split(/[^\w]+/).filter(Boolean).join('-')
|
||||
}
|
||||
|
|
|
@ -22,11 +22,15 @@ export default async function (req, res) {
|
|||
}
|
||||
|
||||
const inlineCSS = `
|
||||
html, body { scroll-behavior: smooth }
|
||||
.markdown-body { max-width: 850px }
|
||||
.markdown-body h1 { margin-bottom: 42px }
|
||||
li > img { vertical-align: middle; margin: 0.2em 0; font-size: 12px; float: right }
|
||||
li > img + a { font-family: monospace; font-size: 0.9em }
|
||||
li > img + a + i { color: #AAA }
|
||||
h4 a code { color: #333; font-size: 1rem }
|
||||
h4 a:hover { text-decoration: none !important }
|
||||
h4 { padding: 4px 0 }
|
||||
`
|
||||
|
||||
const helpFooter = `
|
||||
|
|
Ładowanie…
Reference in New Issue