docs: Use headers for individual global options, anchor linkable (#100)

This commit is contained in:
Francis Lavoie 2020-11-12 15:54:37 -05:00 committed by GitHub
parent 828e4a4eb4
commit 6b4998a5dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 76 additions and 22 deletions

View file

@ -60,4 +60,23 @@ $(function() {
.find('a')
.text(text);
});
// On the global options page only, we'll add links to the options to the anchor tags
if (window.location.pathname === '/docs/caddyfile/options') {
let headers = $('article h5').map(function (i, el) {
return el.id.replace(/-/g, "_");
}).toArray();
$('pre.chroma .k')
.filter(function (k, item) {
return headers.includes(item.innerText);
})
.map(function(k, item) {
let text = item.innerText;
let url = '#' + item.innerText.replace(/_/g, "-");
$(item)
.html('<a href="' + url + '" style="color: inherit;" title="Global option"></a>')
.find('a')
.text(text);
});
}
});