mirror of
https://github.com/CaiJimmy/hugo-theme-stack.git
synced 2025-04-28 19:43:31 +08:00
Add comments support for Beaudar(表达)
This commit is contained in:
parent
40234ff23a
commit
badb1bbdfe
@ -51,6 +51,12 @@ params:
|
|||||||
issueTerm: pathname
|
issueTerm: pathname
|
||||||
label:
|
label:
|
||||||
|
|
||||||
|
beaudar:
|
||||||
|
repo:
|
||||||
|
issueTerm: pathname
|
||||||
|
label:
|
||||||
|
theme:
|
||||||
|
|
||||||
remark42:
|
remark42:
|
||||||
host:
|
host:
|
||||||
site:
|
site:
|
||||||
|
@ -91,6 +91,12 @@ params:
|
|||||||
issueTerm: pathname
|
issueTerm: pathname
|
||||||
label:
|
label:
|
||||||
|
|
||||||
|
beaudar:
|
||||||
|
repo:
|
||||||
|
issueTerm: pathname
|
||||||
|
label:
|
||||||
|
theme:
|
||||||
|
|
||||||
remark42:
|
remark42:
|
||||||
host:
|
host:
|
||||||
site:
|
site:
|
||||||
|
@ -1,16 +1,46 @@
|
|||||||
<script src="https://beaudar.lipk.org/client.js"
|
<script
|
||||||
repo="{{ .Site.Params.comments.beaudar.repo }}"
|
src="https://beaudar.lipk.org/client.js"
|
||||||
issue-term="{{ .Site.Params.comments.beaudar.issueTerm }}"
|
repo="{{ .Site.Params.comments.beaudar.repo }}"
|
||||||
{{ with .Site.Params.comments.beaudar.label }}
|
issue-term="{{ .Site.Params.comments.beaudar.issueTerm }}"
|
||||||
label="{{ . }}"
|
{{ with .Site.Params.comments.beaudar.label }}
|
||||||
{{ end }}
|
label="{{ . }}"
|
||||||
crossorigin="anonymous"
|
{{ end }}
|
||||||
async
|
theme="{{ .Site.Params.comments.beaudar.theme }}"
|
||||||
>
|
crossorigin="anonymous"
|
||||||
</script>
|
async
|
||||||
|
></script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.beaudar {
|
.beaudar {
|
||||||
max-width: unset;
|
max-width: unset;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
let beaudarLoaded = false;
|
||||||
|
|
||||||
|
function setBeaudarTheme(theme) {
|
||||||
|
let beaudar = document.querySelector(".beaudar iframe");
|
||||||
|
if (beaudar) {
|
||||||
|
beaudar.contentWindow.postMessage(
|
||||||
|
{
|
||||||
|
type: "set-theme",
|
||||||
|
theme: `github-${theme}`,
|
||||||
|
},
|
||||||
|
"https://beaudar.lipk.org"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
</style>
|
}
|
||||||
|
|
||||||
|
addEventListener("message", (event) => {
|
||||||
|
if (event.origin !== "https://beaudar.lipk.org") return;
|
||||||
|
/// Called when Beaudar is ready
|
||||||
|
beaudarLoaded = true;
|
||||||
|
setBeaudarTheme(document.documentElement.dataset.scheme);
|
||||||
|
});
|
||||||
|
|
||||||
|
window.addEventListener("onColorSchemeChange", (e) => {
|
||||||
|
if (!beaudarLoaded) return;
|
||||||
|
setBeaudarTheme(e.detail);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user