mirror of
https://github.com/BBaoVanC/bobatheme.git
synced 2025-05-10 22:12:57 -05:00
Compare commits
4 Commits
47d6d02186
...
80f5994d96
Author | SHA1 | Date | |
---|---|---|---|
80f5994d96 | |||
342710a755 | |||
8eb642dbc8 | |||
a4be8b395b |
@ -272,7 +272,7 @@
|
||||
.sections {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 40px;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.section {
|
||||
@ -583,6 +583,7 @@ body {
|
||||
}
|
||||
|
||||
footer {
|
||||
margin-top: 20px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
|
@ -12,14 +12,19 @@ window.onscroll = function() {
|
||||
window.onload = () => {
|
||||
document.querySelectorAll(".code-block").forEach(codeBlock => {
|
||||
const button = codeBlock.querySelector(".code-header > .code-copy-button");
|
||||
// TODO: maybe get this from HTMLElement.innerText on the actual code block content element
|
||||
// but it's hard to select it; `data-lang` attribute might not always be there (if lang is unset)
|
||||
const rawCode = codeBlock.querySelector("pre.code-raw").innerText;
|
||||
|
||||
// lang will not be unset because we default it to text
|
||||
// clone it so it doesn't change the actual DOM element
|
||||
const codeElem = codeBlock.querySelector("code[data-lang]").cloneNode(true);
|
||||
// bashsession: remove command output lines
|
||||
codeElem.querySelectorAll(".go").forEach(e => e.parentNode.removeChild(e));
|
||||
// bashsession: remove prompt symbol
|
||||
codeElem.querySelectorAll(".gp").forEach(e => e.parentNode.removeChild(e));
|
||||
const rawCode = codeElem.innerText;
|
||||
|
||||
const originalCopyText = button.innerHTML;
|
||||
button.onclick = event => {
|
||||
navigator.clipboard.writeText(rawCode);
|
||||
console.log(rawCode);
|
||||
// TODO: maybe we could add a fancier indicator, like a flash or something
|
||||
event.target.innerHTML = "Copied!";
|
||||
setTimeout(() => {
|
||||
|
@ -1,13 +1,15 @@
|
||||
{{ $type := "text" }}
|
||||
{{ with .Type }}
|
||||
{{ $type = . }}
|
||||
{{ end }}
|
||||
<div class="code-block">
|
||||
<div class="code-header">
|
||||
<span class="code-type">{{ .Type }}</span>
|
||||
<span class="code-type">{{ $type }}</span>
|
||||
<a class="code-copy-button">
|
||||
{{ i18n "copy_to_clipboard" }}
|
||||
</a>
|
||||
</div>
|
||||
{{/* a div.highlight is already created by highlight function */}}
|
||||
{{ highlight .Inner .Type }}
|
||||
|
||||
{{/* for copy to clipboard */}}
|
||||
<pre class="code-raw" style="display: none;">{{ .Inner }}</pre>
|
||||
{{/* a div.highlight is already created by highlight function */}}
|
||||
{{ highlight .Inner $type }}
|
||||
</div>
|
||||
|
@ -21,7 +21,6 @@
|
||||
</main>
|
||||
|
||||
{{ if or .Site.Copyright .Site.Params.footer }}
|
||||
<hr>
|
||||
<footer>
|
||||
<small>
|
||||
{{ with .Site.Copyright }}
|
||||
|
@ -1,9 +1,4 @@
|
||||
{{ $resource := "" }}
|
||||
{{ if .IsNamedParams }}
|
||||
{{ $resource = $.Page.Resources.GetMatch (.Get "src") }}
|
||||
{{ else }}
|
||||
{{ $resource = $.Page.Resources.GetMatch (.Get 0) }}
|
||||
{{ end }}
|
||||
{{ $resource := .Page.Resources.GetMatch (.Get "src") }}
|
||||
|
||||
{{ $noborder := false }}
|
||||
{{ if .Get "noborder" }}
|
||||
|
@ -9,5 +9,5 @@
|
||||
{{ end }}
|
||||
|
||||
<p>
|
||||
{{ partial "remote_figure.html" (dict "src" (.Get "src") "border" $border "hidecaption" $hidecaption "type" "image" "alt" (.Get "alt")) }}
|
||||
{{ partial "remote_figure.html" (dict "src" (.Get "src") "border" $border "hidecaption" $hidecaption "type" (.Get "type") "alt" (.Get "alt")) }}
|
||||
</p>
|
@ -1,13 +0,0 @@
|
||||
{{ $border := false }}
|
||||
{{ if .Get "border" }}
|
||||
{{ $border = true }}
|
||||
{{ end }}
|
||||
|
||||
{{ $hidecaption := false }}
|
||||
{{ if .Get "hidecaption" }}
|
||||
{{ $hidecaption = true }}
|
||||
{{ end }}
|
||||
|
||||
<p>
|
||||
{{ partial "remote_figure.html" (dict "src" (.Get "src") "border" $border "hidecaption" $hidecaption "type" "video" "alt" (.Get "alt")) }}
|
||||
</p>
|
Loading…
x
Reference in New Issue
Block a user