Import theme
This commit is contained in:
parent
51769fa6be
commit
c59ffbfeee
127 changed files with 13611 additions and 1 deletions
3
layouts/partials/comments/commento.html
Normal file
3
layouts/partials/comments/commento.html
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<div id="commento"></div>
|
||||
<script defer src="{{ .Site.Params.CommentoURL }}"></script>
|
||||
<noscript>Please enable JavaScript to load the comments.</noscript>
|
||||
45
layouts/partials/comments/giscus.html
Normal file
45
layouts/partials/comments/giscus.html
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
<script>
|
||||
const getStoredTheme = () => localStorage.getItem("theme") === "dark" ? "dark" : "light";
|
||||
|
||||
const setGiscusTheme = () => {
|
||||
const sendMessage = (message) => {
|
||||
const iframe = document.querySelector('iframe.giscus-frame');
|
||||
if (iframe) {
|
||||
iframe.contentWindow.postMessage({ giscus: message }, 'https://giscus.app');
|
||||
}
|
||||
}
|
||||
sendMessage({ setConfig: { theme: getStoredTheme() } })
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
const giscusAttributes = {
|
||||
"src": "https://giscus.app/client.js",
|
||||
"data-repo": "{{ .Site.Params.giscus.repo }}",
|
||||
"data-repo-id": "{{ .Site.Params.giscus.repoID }}",
|
||||
"data-category": "{{ .Site.Params.giscus.category }}",
|
||||
"data-category-id": "{{ .Site.Params.giscus.categoryID }}",
|
||||
"data-mapping": "{{ .Site.Params.giscus.mapping | default "pathname" }}",
|
||||
"data-strict": "{{ .Site.Params.giscus.strict | default "0" }}",
|
||||
"data-reactions-enabled": "{{ .Site.Params.giscus.reactionsEnabled | default "1" }}",
|
||||
"data-emit-metadata": "{{ .Site.Params.giscus.emitMetadata | default "0" }}",
|
||||
"data-input-position": "{{ .Site.Params.giscus.inputPosition | default "bottom" }}",
|
||||
"data-theme": getStoredTheme(),
|
||||
"data-lang": "{{ .Site.Params.giscus.lang | default "en" }}",
|
||||
"data-loading": "{{ .Site.Params.giscus.loading | default "lazy" }}",
|
||||
"crossorigin": "anonymous",
|
||||
"async": "",
|
||||
};
|
||||
|
||||
// Dynamically create script tag.
|
||||
const giscusScript = document.createElement("script");
|
||||
Object.entries(giscusAttributes).forEach(
|
||||
([key, value]) => giscusScript.setAttribute(key, value));
|
||||
document.getElementById("comment").appendChild(giscusScript);
|
||||
|
||||
// Update giscus theme when the theme switcher is clicked.
|
||||
const themeSwitcher = document.querySelector(".themeswitch");
|
||||
if (themeSwitcher) {
|
||||
themeSwitcher.addEventListener("click", setGiscusTheme);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
33
layouts/partials/comments/gitalk.html
Normal file
33
layouts/partials/comments/gitalk.html
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<div id="gitalk-container"></div>
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://cdnjs.cloudflare.com/ajax/libs/gitalk/1.7.2/gitalk.min.css"
|
||||
integrity="sha512-0hsIlRjJbiUWaKMhXXNDmjWI2qPvUlhNBLHMhqeF5jIma+bedec27N5FoT2JEeHz5TUmOGCsm1Y89EsX/P0wOg=="
|
||||
crossorigin="anonymous"
|
||||
referrerpolicy="no-referrer"
|
||||
/>
|
||||
<script
|
||||
src="https://cdnjs.cloudflare.com/ajax/libs/gitalk/1.7.2/gitalk.min.js"
|
||||
integrity="sha512-EcTCcXV46teiNwe0VcnM5A038tcY+BaQYO4nW6Gh2i7v4/HjBVg7xx3+JBLl9WofDds//INJAiEGAtdgr8PWyA=="
|
||||
crossorigin="anonymous"
|
||||
referrerpolicy="no-referrer"
|
||||
></script>
|
||||
<script>
|
||||
const gitalk = new Gitalk({
|
||||
clientID: '{{ .Site.Params.Gitalk.clientID }}',
|
||||
clientSecret: '{{ .Site.Params.Gitalk.clientSecret }}',
|
||||
repo: '{{ .Site.Params.Gitalk.repo }}',
|
||||
owner: '{{ .Site.Params.Gitalk.owner }}',
|
||||
admin: ['{{ .Site.Params.Gitalk.admin }}'],
|
||||
id: location.pathname, // Ensure uniqueness and length less than 50
|
||||
distractionFreeMode: false, // Facebook-like distraction free mode
|
||||
});
|
||||
(function () {
|
||||
if (['localhost', '127.0.0.1'].indexOf(window.location.hostname) != -1) {
|
||||
document.getElementById('gitalk-container').innerHTML =
|
||||
'Gitalk comments not available by default when the website is previewed locally.';
|
||||
return;
|
||||
}
|
||||
gitalk.render('gitalk-container');
|
||||
})();
|
||||
</script>
|
||||
11
layouts/partials/comments/utterances.html
Normal file
11
layouts/partials/comments/utterances.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<script
|
||||
src="https://utteranc.es/client.js"
|
||||
repo="{{ .Site.Params.utterances.repo }}"
|
||||
issue-term="{{ .Site.Params.utterances.issueTerm }}"
|
||||
theme="{{ .Site.Params.utterances.theme }}"
|
||||
{{ with .Site.Params.utterances.label }}
|
||||
label="{{ . }}"
|
||||
{{ end }}
|
||||
crossorigin="anonymous"
|
||||
async
|
||||
></script>
|
||||
Loading…
Add table
Add a link
Reference in a new issue