mirror of
https://github.com/BBaoVanC/bobatheme.git
synced 2026-09-25 09:54:56 -05:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
31731c9996
|
||
|
|
b67e3f4671
|
@@ -1,25 +0,0 @@
|
|||||||
// code block copy to clipboard
|
|
||||||
window.onload = () => {
|
|
||||||
document.querySelectorAll(".code-block").forEach(codeBlock => {
|
|
||||||
const button = codeBlock.querySelector(".code-header > .code-copy-button");
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
// TODO: maybe we could add a fancier indicator, like a flash or something
|
|
||||||
event.target.innerHTML = "Copied!";
|
|
||||||
setTimeout(() => {
|
|
||||||
event.target.innerHTML = originalCopyText;
|
|
||||||
}, 3000);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
// code block copy to clipboard
|
||||||
|
async function copy_to_clipboard(button) {
|
||||||
|
const codeBlock = button.parentElement.parentElement;
|
||||||
|
|
||||||
|
// lang will not be unset because we default it to textoriginalCopyText
|
||||||
|
// 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;
|
||||||
|
|
||||||
|
await navigator.clipboard.writeText(rawCode);
|
||||||
|
|
||||||
|
// TODO: maybe we could add a fancier indicator, like a flash or something
|
||||||
|
button.innerHTML = "Copied!";
|
||||||
|
setTimeout(() => {
|
||||||
|
button.innerHTML = "{{ i18n "copy_to_clipboard" }}";
|
||||||
|
}, 3000);
|
||||||
|
}
|
||||||
@@ -5,7 +5,8 @@
|
|||||||
<div class="code-block">
|
<div class="code-block">
|
||||||
<div class="code-block-header">
|
<div class="code-block-header">
|
||||||
<pre class="code-block-type">{{ $type }}</pre>
|
<pre class="code-block-type">{{ $type }}</pre>
|
||||||
<a href="javascript:void(0)" class="code-block-copy-button">
|
{{/* https://blog.udemy.com/javascript-href/ */}}
|
||||||
|
<a href="javascript:null" onClick="javascript:copy_to_clipboard(this)" class="code-block-copy-button">
|
||||||
{{ i18n "copy_to_clipboard" }}
|
{{ i18n "copy_to_clipboard" }}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -19,8 +19,10 @@
|
|||||||
<link rel="stylesheet" type="text/css" href="{{ .Permalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous" media="print" onload="this.media='all'">
|
<link rel="stylesheet" type="text/css" href="{{ .Permalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous" media="print" onload="this.media='all'">
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{ with resources.Get "js/bobatheme.js" | fingerprint "sha512" }}
|
{{ with resources.Get "js/bobatheme.tmpl.js" }}
|
||||||
<script defer src="{{ .Permalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous"></script>
|
{{ with resources.ExecuteAsTemplate "js/bobatheme.js" $ . | fingerprint "sha512" }}
|
||||||
|
<script defer src="{{ .Permalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous"></script>
|
||||||
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ if not hugo.IsServer }}
|
{{ if not hugo.IsServer }}
|
||||||
<script defer data-domain="bbaovanc.com" src="https://plausible.bbaovanc.com/js/bobalytics.outbound-links.js"></script>
|
<script defer data-domain="bbaovanc.com" src="https://plausible.bbaovanc.com/js/bobalytics.outbound-links.js"></script>
|
||||||
@@ -68,12 +70,19 @@
|
|||||||
>
|
>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{{ with resources.Get "css/search.css" | fingerprint "sha512" }}
|
{{ if eq .Layout "search" }}
|
||||||
<link rel="stylesheet" type="text/css" href="{{ .Permalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous">
|
{{ with resources.Get "css/search.css" | fingerprint "sha512" }}
|
||||||
{{ end }}
|
<link rel="stylesheet" type="text/css" href="{{ .Permalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous">
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
<link rel="stylesheet" type="text/css" href="{{ absURL "pagefind/pagefind-component-ui.css" }}" crossorigin="anonymous">
|
<link rel="stylesheet" type="text/css" href="{{ absURL "pagefind/pagefind-ui.css" }}" crossorigin="anonymous">
|
||||||
<script src="{{ absURL "pagefind/pagefind-component-ui.js" }}" type="module" crossorigin="anonymous"></script>
|
<script src="{{ absURL "pagefind/pagefind-ui.js" }}" crossorigin="anonymous"></script>
|
||||||
|
<script>
|
||||||
|
window.addEventListener('DOMContentLoaded', (event) => {
|
||||||
|
new PagefindUI({ element: "#search-box", showSubResults: true });
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
{{ with .Site.Params.faviconSVG }}
|
{{ with .Site.Params.faviconSVG }}
|
||||||
<link rel="icon" href="{{ . | absURL }}" />
|
<link rel="icon" href="{{ . | absURL }}" />
|
||||||
|
|||||||
@@ -5,9 +5,6 @@
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<pagefind-modal-trigger></pagefind-modal-trigger>
|
|
||||||
<pagefind-modal></pagefind-modal>
|
|
||||||
|
|
||||||
<nav class="top-navbar" aria-label="{{ i18n "aria_navbar" }}">
|
<nav class="top-navbar" aria-label="{{ i18n "aria_navbar" }}">
|
||||||
{{ with .Site.Home }}
|
{{ with .Site.Home }}
|
||||||
<a class="top-navbar-item{{ if $.IsHome }} top-navbar-item--active{{ end }}" href="{{ .Permalink | absLangURL }}">{{ .Title | markdownify }}</a>
|
<a class="top-navbar-item{{ if $.IsHome }} top-navbar-item--active{{ end }}" href="{{ .Permalink | absLangURL }}">{{ .Title | markdownify }}</a>
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
{{ define "main" }}
|
||||||
|
<div id="search-box"></div>
|
||||||
|
{{ end }}
|
||||||
Reference in New Issue
Block a user