Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for giscus #428

Closed
wants to merge 13 commits into from
905 changes: 406 additions & 499 deletions CHANGELOG.md

Large diffs are not rendered by default.

135 changes: 68 additions & 67 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion README.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

## 简介

MemE 是一个强大且可高度定制的 [GoHugo](https://github.com/gohugoio/hugo) 博客主题,专为个人博客设计。MemE 主题专注于优雅、简约、现代,以及代码的正确性。同时,希望你将像欣赏一个模因一样欣赏 MemE,希望你将像分享一个模因一样分享 MemE,就像你的博客和文章所做的那样😝!
MemE 是一个强大且可高度定制的 [GoHugo](https://github.com/gohugoio/hugo) 博客主题,专为个人博客设计。MemE 主题专注于优雅、简约、现代,以及代码的正确性。同时,希望你将像欣赏一个模因一样欣赏 MemE,希望你将像分享一个模因一样分享 MemE,就像你的博客和文章所做的那样 😝!

## 预览

Expand Down
2 changes: 1 addition & 1 deletion README.zh-tw.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

## 簡介

MemE 是一個強大且可高度客制化的 [GoHugo](https://github.com/gohugoio/hugo) 部落格主題,專為個人部落格設計。MemE 主題專注於優雅、簡約、現代,以及程式碼的正確性。同時,希望你將像欣賞一個模因一樣欣賞 MemE,希望你將像分享一個模因一樣分享 MemE,就像你的部落格和文章所做的那樣😝!
MemE 是一個強大且可高度客制化的 [GoHugo](https://github.com/gohugoio/hugo) 部落格主題,專為個人部落格設計。MemE 主題專注於優雅、簡約、現代,以及程式碼的正確性。同時,希望你將像欣賞一個模因一樣欣賞 MemE,希望你將像分享一個模因一樣分享 MemE,就像你的部落格和文章所做的那樣 😝!

## 預覽

Expand Down
26 changes: 24 additions & 2 deletions assets/js/dark-mode.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ if (userPrefers === 'dark') {
changeModeMeta('light');
}

window.matchMedia('(prefers-color-scheme: dark)').addListener((e) => {
window.matchMedia('(prefers-color-scheme: dark)').addEventListener("change", () => {
changeMode();
});

window.addEventListener("DOMContentLoaded", event => {
window.addEventListener("DOMContentLoaded", () => {
// Update meta tags and code highlighting
changeMode();

Expand Down Expand Up @@ -89,6 +89,28 @@ function changeMode() {
}
{{ end }}

{{ if and .Site.Params.enableGiscus (eq hugo.Environment "production") }}
// Change Giscus Comments Theme
if (isDark) {
changeGiscusTheme('{{ .Site.Params.giscusThemeDark | default "dark" }}');
} else {
changeGiscusTheme('{{ .Site.Params.giscusTheme | default "light" }}');
}
function changeGiscusTheme(theme) {
function sendMessage(message) {
const iframe = document.querySelector('iframe.giscus-frame');
if (iframe !== null) {
iframe.contentWindow.postMessage({ giscus: message }, 'https://giscus.app');
}
}
sendMessage({
setConfig: {
theme: theme,
},
});
}
{{ end }}

// Mermaid
// https://github.com/reuixiy/hugo-theme-meme/issues/205
if (typeof mermaidConfig !== 'undefined') {
Expand Down
Loading