Add filename option to codeblocks

This commit is contained in:
Alex Shpak
2025-09-14 23:49:47 +02:00
parent 6c2d102c91
commit 2745893250
3 changed files with 29 additions and 2 deletions
-2
View File
@@ -71,8 +71,6 @@
} }
pre { pre {
direction: ltr;
unicode-bidi: embed;
padding: $padding-16; padding: $padding-16;
background: var(--gray-100); background: var(--gray-100);
border-radius: $border-radius; border-radius: $border-radius;
+19
View File
@@ -260,4 +260,23 @@
font-size: 3em; font-size: 3em;
} }
} }
.book-codeblock-filename {
background: var(--gray-200);
font-size: $font-size-14;
margin-top: $padding-16;
padding: $padding-4 $padding-16;
border-start-start-radius: $border-radius;
border-start-end-radius: $border-radius;
a {
color: var(--body-font-color);
}
+ .highlight pre {
margin-top: 0;
border-start-start-radius: 0;
border-start-end-radius: 0;
}
}
} }
+10
View File
@@ -0,0 +1,10 @@
{{- with (index .Attributes "filename") -}}
{{- $href := index $.Attributes "href" -}}
{{- if $href -}}
{{- $href = partial "docs/links/portable-link" (dict "Page" $.PageInner "Destination" $href) -}}
{{- end -}}
<div class="book-codeblock-filename">
<a {{ with $href }}href="{{ . }}"{{ end }}>{{ . }}</a>
</div>
{{- end -}}
{{- (transform.HighlightCodeBlock . .Options).Wrapped -}}