mirror of
https://github.com/BBaoVanC/bobatheme.git
synced 2025-05-11 14:32:57 -05:00
Compare commits
4 Commits
47d6d02186
...
80f5994d96
Author | SHA1 | Date | |
---|---|---|---|
80f5994d96 | |||
342710a755 | |||
8eb642dbc8 | |||
a4be8b395b |
@ -272,7 +272,7 @@
|
|||||||
.sections {
|
.sections {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 40px;
|
gap: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.section {
|
.section {
|
||||||
@ -583,6 +583,7 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
footer {
|
footer {
|
||||||
|
margin-top: 20px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,14 +12,19 @@ window.onscroll = function() {
|
|||||||
window.onload = () => {
|
window.onload = () => {
|
||||||
document.querySelectorAll(".code-block").forEach(codeBlock => {
|
document.querySelectorAll(".code-block").forEach(codeBlock => {
|
||||||
const button = codeBlock.querySelector(".code-header > .code-copy-button");
|
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)
|
// lang will not be unset because we default it to text
|
||||||
const rawCode = codeBlock.querySelector("pre.code-raw").innerText;
|
// 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;
|
const originalCopyText = button.innerHTML;
|
||||||
button.onclick = event => {
|
button.onclick = event => {
|
||||||
navigator.clipboard.writeText(rawCode);
|
navigator.clipboard.writeText(rawCode);
|
||||||
console.log(rawCode);
|
|
||||||
// TODO: maybe we could add a fancier indicator, like a flash or something
|
// TODO: maybe we could add a fancier indicator, like a flash or something
|
||||||
event.target.innerHTML = "Copied!";
|
event.target.innerHTML = "Copied!";
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
@ -1,13 +1,15 @@
|
|||||||
|
{{ $type := "text" }}
|
||||||
|
{{ with .Type }}
|
||||||
|
{{ $type = . }}
|
||||||
|
{{ end }}
|
||||||
<div class="code-block">
|
<div class="code-block">
|
||||||
<div class="code-header">
|
<div class="code-header">
|
||||||
<span class="code-type">{{ .Type }}</span>
|
<span class="code-type">{{ $type }}</span>
|
||||||
<a class="code-copy-button">
|
<a class="code-copy-button">
|
||||||
{{ i18n "copy_to_clipboard" }}
|
{{ i18n "copy_to_clipboard" }}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
{{/* a div.highlight is already created by highlight function */}}
|
|
||||||
{{ highlight .Inner .Type }}
|
|
||||||
|
|
||||||
{{/* for copy to clipboard */}}
|
{{/* a div.highlight is already created by highlight function */}}
|
||||||
<pre class="code-raw" style="display: none;">{{ .Inner }}</pre>
|
{{ highlight .Inner $type }}
|
||||||
</div>
|
</div>
|
||||||
|
@ -21,7 +21,6 @@
|
|||||||
</main>
|
</main>
|
||||||
|
|
||||||
{{ if or .Site.Copyright .Site.Params.footer }}
|
{{ if or .Site.Copyright .Site.Params.footer }}
|
||||||
<hr>
|
|
||||||
<footer>
|
<footer>
|
||||||
<small>
|
<small>
|
||||||
{{ with .Site.Copyright }}
|
{{ with .Site.Copyright }}
|
||||||
|
@ -1,9 +1,4 @@
|
|||||||
{{ $resource := "" }}
|
{{ $resource := .Page.Resources.GetMatch (.Get "src") }}
|
||||||
{{ if .IsNamedParams }}
|
|
||||||
{{ $resource = $.Page.Resources.GetMatch (.Get "src") }}
|
|
||||||
{{ else }}
|
|
||||||
{{ $resource = $.Page.Resources.GetMatch (.Get 0) }}
|
|
||||||
{{ end }}
|
|
||||||
|
|
||||||
{{ $noborder := false }}
|
{{ $noborder := false }}
|
||||||
{{ if .Get "noborder" }}
|
{{ if .Get "noborder" }}
|
||||||
|
@ -9,5 +9,5 @@
|
|||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
<p>
|
<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>
|
</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