mirror of
https://github.com/caddyserver/website.git
synced 2025-04-21 20:46:15 -04:00
docs: Add links to Caddyfile directives in code blocks (#82)
This commit is contained in:
parent
ec9e966e55
commit
99c602bf11
2 changed files with 21 additions and 0 deletions
|
@ -1,5 +1,10 @@
|
||||||
{{include "/includes/head.html"}}
|
{{include "/includes/head.html"}}
|
||||||
<link rel="stylesheet" href="/resources/css/docs.css">
|
<link rel="stylesheet" href="/resources/css/docs.css">
|
||||||
<link rel="stylesheet" href="/resources/css/chroma.css">
|
<link rel="stylesheet" href="/resources/css/chroma.css">
|
||||||
|
{{$directives := list }}
|
||||||
|
{{range $i, $file := (listFiles "/docs/markdown/caddyfile/directives")}}
|
||||||
|
{{$directives = append $directives ($file | trimSuffix ".md")}}
|
||||||
|
{{end}}
|
||||||
|
<script type="text/javascript">window.CaddyfileDirectives = {{$directives | toJson}};</script>
|
||||||
<script src="/resources/js/jquery-3.4.1.min.js"></script>
|
<script src="/resources/js/jquery-3.4.1.min.js"></script>
|
||||||
<script src="/resources/js/docs.js"></script>
|
<script src="/resources/js/docs.js"></script>
|
|
@ -30,4 +30,20 @@ $(function() {
|
||||||
// to the outer pre element, and our CSS file has a style to
|
// to the outer pre element, and our CSS file has a style to
|
||||||
// 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.
|
||||||
|
// See include/docs-head.html for the whitelist bootstrapping logic
|
||||||
|
$('pre.chroma .k')
|
||||||
|
.filter(function (k, item) {
|
||||||
|
return window.CaddyfileDirectives.includes(item.innerText);
|
||||||
|
})
|
||||||
|
.map(function(k, item) {
|
||||||
|
$(item).html(
|
||||||
|
'<a href="/docs/caddyfile/directives/' + item.innerText + '"'
|
||||||
|
+ 'style="color: inherit;"'
|
||||||
|
+ '>'
|
||||||
|
+ item.innerText
|
||||||
|
+ '</a>'
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
Loading…
Add table
Add a link
Reference in a new issue