aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--assets/css/default.css34
-rw-r--r--assets/css/syntax-highlight-default.css11
-rw-r--r--themes/default/layouts/_default/_markup/render-codeblock.html12
3 files changed, 36 insertions, 21 deletions
diff --git a/assets/css/default.css b/assets/css/default.css
index a5c77ff..ce1d096 100644
--- a/assets/css/default.css
+++ b/assets/css/default.css
@@ -1035,6 +1035,21 @@ icon-button p {
margin: 0;
}
+code-block pre {
+ border-radius: 0.5rem;
+ border: 1px solid #ccc;
+ border: 1px solid var(--border-darker);
+ display: block;
+ font-size: 95%;
+ margin: 0;
+ overflow-x: auto;
+ overflow-y: hidden;
+ padding: 2.65rem 0 0 0;
+ tab-size: 2;
+ word-break: break-word;
+ white-space: pre;
+}
+
code-block pre code {
display: inline-block;
min-width: 100%;
@@ -1062,19 +1077,12 @@ code-block header language-label {
font-variant: all-small-caps;
}
-code-block pre {
- border-radius: 0.5rem;
- border: 1px solid #ccc;
- border: 1px solid var(--border-darker);
- display: block;
- font-size: 95%;
- margin: 0;
- overflow-x: auto;
- overflow-y: hidden;
- padding: 2.65rem 0 0 0;
- tab-size: 2;
- word-break: break-word;
- white-space: pre;
+code-block header language-label a {
+ text-decoration: none;
+}
+
+code-block header language-label a:hover {
+ text-decoration: underline;
}
paginator-navigation {
diff --git a/assets/css/syntax-highlight-default.css b/assets/css/syntax-highlight-default.css
index 0208323..1a394ea 100644
--- a/assets/css/syntax-highlight-default.css
+++ b/assets/css/syntax-highlight-default.css
@@ -20,14 +20,19 @@
outline-offset: -0.3rem;
}
+.chroma .line:hover {
+ background-color: #f2f2f2;
+ display: block;
+}
+
code-block button {
border: 1px solid #ccc;
display: none;
}
-.chroma .line:hover {
- background-color: #f2f2f2;
- display: block;
+code-block header language-label a,
+code-block header language-label a:hover {
+ color: #111;
}
/* ------ Tokens ------ */
diff --git a/themes/default/layouts/_default/_markup/render-codeblock.html b/themes/default/layouts/_default/_markup/render-codeblock.html
index 7c2670f..8bc484b 100644
--- a/themes/default/layouts/_default/_markup/render-codeblock.html
+++ b/themes/default/layouts/_default/_markup/render-codeblock.html
@@ -1,17 +1,19 @@
-{{ $options := .Attributes.options | default "default=1" }}
-{{ $caption := .Attributes.caption }}
+{{- $caption := .Attributes.caption -}}
+{{- $type := .Type | default "text" -}}
+{{- $options := .Attributes.options | default "default=1" -}}
+{{- $id := print "code-block-" (truncate 7 "" (md5 .Inner)) -}}
-<code-block {{ if in (lower $options) "linenos" }}data-lines{{ end }}>
+<code-block id="{{ $id }}" {{ if in (lower $options) "linenos" }}data-lines{{ end }}>
<header>
<language-label>
- {{ .Type }}
+ <a href="#{{ $id }}">{{ $type }}</a>
</language-label>
<button>
{{ safeHTML (readFile (print (partial "function-paths.html" "static") "/icons/feather/copy.svg")) }}
<span>Copy</span>
</button>
</header>
- {{ highlight .Inner .Type (print $options ",lineAnchors=" "code-" (truncate 7 "" (md5 .Inner))) }}
+ {{ highlight .Inner $type (print $options ",lineAnchors=" "code-line-" (truncate 7 "" (md5 .Inner))) }}
</code-block>
{{ with $caption }}