mirror of
https://github.com/caddyserver/website.git
synced 2025-04-22 04:56:17 -04:00
docs: Add links to matchers and <directives...> (#84)
This commit is contained in:
parent
99c602bf11
commit
2c6a8a0f9f
1 changed files with 24 additions and 9 deletions
|
@ -31,19 +31,34 @@ $(function() {
|
||||||
// ensure the inner code block does not produce extra padding
|
// ensure the inner code block does not produce extra padding
|
||||||
$('article > pre:not(.chroma) > code:not(.cmd)').parent().addClass('chroma');
|
$('article > pre:not(.chroma) > code:not(.cmd)').parent().addClass('chroma');
|
||||||
|
|
||||||
// Add links to Caddyfile directives in code blocks.
|
// Add links to Caddyfile directive tokens in code blocks.
|
||||||
// See include/docs-head.html for the whitelist bootstrapping logic
|
// See include/docs-head.html for the whitelist bootstrapping logic
|
||||||
$('pre.chroma .k')
|
$('pre.chroma .k')
|
||||||
.filter(function (k, item) {
|
.filter(function (k, item) {
|
||||||
return window.CaddyfileDirectives.includes(item.innerText);
|
return window.CaddyfileDirectives.includes(item.innerText)
|
||||||
|
|| item.innerText === '<directives...>';
|
||||||
})
|
})
|
||||||
.map(function(k, item) {
|
.map(function(k, item) {
|
||||||
$(item).html(
|
let text = item.innerText;
|
||||||
'<a href="/docs/caddyfile/directives/' + item.innerText + '"'
|
let url = text === '<directives...>'
|
||||||
+ 'style="color: inherit;"'
|
? '/docs/caddyfile/directives'
|
||||||
+ '>'
|
: '/docs/caddyfile/directives/' + text;
|
||||||
+ item.innerText
|
$(item)
|
||||||
+ '</a>'
|
.html('<a href="' + url + '" style="color: inherit;"></a>')
|
||||||
);
|
.find('a')
|
||||||
|
.text(text);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Add links to [<matcher>] or named matcher tokens in code blocks.
|
||||||
|
// We can't do it exactly the same as the above block, because
|
||||||
|
// the matcher text includes <> character which are parsed as HTML
|
||||||
|
// unless we use text() to change the link text.
|
||||||
|
$('pre.chroma .nd')
|
||||||
|
.map(function(k, item) {
|
||||||
|
let text = item.innerText;
|
||||||
|
$(item)
|
||||||
|
.html('<a href="/docs/caddyfile/matchers" style="color: inherit;"></a>')
|
||||||
|
.find('a')
|
||||||
|
.text(text);
|
||||||
});
|
});
|
||||||
});
|
});
|
Loading…
Add table
Add a link
Reference in a new issue