From 5d35abe652a8fc260857fdfe6a8eb3f2817a6977 Mon Sep 17 00:00:00 2001 From: kands-code Date: Thu, 4 May 2023 14:59:04 +0800 Subject: [PATCH 1/8] feat: add support to giscus --- assets/js/dark-mode.js | 25 ++++++++-- config-examples/en/config.toml | 33 ++++++------- config-examples/zh-cn/config.toml | 33 ++++++------- config-examples/zh-tw/config.toml | 33 ++++++------- layouts/partials/components/comments.html | 4 ++ layouts/partials/third-party/giscus.html | 58 +++++++++++++++++++++++ layouts/partials/third-party/katex.html | 17 +++++-- layouts/partials/third-party/script.html | 4 ++ layouts/partials/utils/lib.html | 15 ++++-- 9 files changed, 161 insertions(+), 61 deletions(-) create mode 100644 layouts/partials/third-party/giscus.html diff --git a/assets/js/dark-mode.js b/assets/js/dark-mode.js index 5e6426ef..dbbc1e33 100644 --- a/assets/js/dark-mode.js +++ b/assets/js/dark-mode.js @@ -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(); @@ -69,7 +69,7 @@ function changeMode() { const themeColor = isDark ? '{{ .Site.Params.themeColorDark }}' : '{{ .Site.Params.themeColor }}'; document.querySelector('meta[name="theme-color"]').setAttribute('content', themeColor); - {{ if and .Site.Params.enableUtterances (eq hugo.Environment "production") }} + {{ if and .Site.Params.enableUtterances }} // Change Utterances Comments Theme // https://github.com/utterance/utterances/issues/229 if (isDark) { @@ -89,6 +89,25 @@ function changeMode() { } {{ end }} + {{ if and .Site.Params.enableGiscus }} + // Change Giscus Comments Theme + if (isDark) { + changeGiscusTheme('{{ .Site.Params.giscusThemeDark | default "dark" }}'); + } else { + changeGiscusTheme('{{ .Site.Params.giscusTheme | default "light" }}'); + } + function changeGiscusTheme(theme) { + const iframe = document.querySelector('.giscus-frame'); + if (iframe !== null) { + const message = { + type: 'set-theme', + theme: theme + }; + iframe.contentWindow.postMessage(message, 'https://giscus.app'); + } + } + {{ end }} + // Mermaid // https://github.com/reuixiy/hugo-theme-meme/issues/205 if (typeof mermaidConfig !== 'undefined') { diff --git a/config-examples/en/config.toml b/config-examples/en/config.toml index 323d7a8f..96411ecd 100644 --- a/config-examples/en/config.toml +++ b/config-examples/en/config.toml @@ -1456,23 +1456,24 @@ uglyURLs = false # and put this file to your # /static/js/lib.min.js [params.lib.path] - clipboard = "/npm/clipboard-polyfill@2.8.6/dist/clipboard-polyfill.min.js" - instantsearch = "/npm/instantsearch.js@2/dist/instantsearch.min.js" - gitalk = "/npm/gitalk@1/dist/gitalk.min.js" - gitalk_css = "/npm/gitalk@1/dist/gitalk.css" - instantpage = "/npm/instant.page@5.1.0/instantpage.min.js" - katex = "/npm/katex@0.13.0/dist/katex.min.js" - katex_css = "/npm/katex@0.13.0/dist/katex.min.css" - katex_mhchem = "/npm/katex@0.13.0/dist/contrib/mhchem.min.js" - katex_auto_render = "/npm/katex@0.13.0/dist/contrib/auto-render.min.js" + clipboard = "/npm/clipboard-polyfill@4.0.0/dist/clipboard-polyfill.min.js" + instantsearch = "/npm/instantsearch.js@4.53.0/dist/instantsearch.min.js" + gitalk = "/npm/gitalk@1.8.0/dist/gitalk.min.js" + gitalk_css = "/npm/gitalk@1.8.0/dist/gitalk.css" + instantpage = "/npm/instant.page@5.2.0/instantpage.min.js" + katex = "/npm/katex@0.16.7/dist/katex.min.js" + katex_css = "/npm/katex@0.16.7/dist/katex.min.css" + katex_mhchem = "/npm/katex@0.16.7/dist/contrib/mhchem.min.js" + katex_auto_render = "/npm/katex@0.16.7/dist/contrib/auto-render.min.js" lunr = "/npm/lunr@2.3.9/lunr.min.js" - lunr_tinyseg = "/npm/lunr-languages@1.4.0/tinyseg.js" - lunr_stemmer = "/npm/lunr-languages@1.4.0/min/lunr.stemmer.support.min.js" - lunr_lang = "/npm/lunr-languages@1.4.0/min/lunr.de.min.js" - mathjax = "/npm/mathjax@3.1.2/es5/tex-mml-chtml.js" + lunr_tinyseg = "/npm/lunr-languages@1.10.0/tinyseg.js" + lunr_stemmer = "/npm/lunr-languages@1.10.0/min/lunr.stemmer.support.min.js" + lunr_lang = "/npm/lunr-languages@1.10.0/min/lunr.de.min.js" + mathjax = "/npm/mathjax@3.2.2/es5/tex-mml-chtml.js" medium_zoom = "/npm/medium-zoom@latest/dist/medium-zoom.min.js" - mermaid = "/npm/mermaid@8.8.3/dist/mermaid.min.js" + mermaid = "/npm/mermaid/dist/mermaid.min.js" qrcode = "/npm/qrcode-generator@1.4.4/qrcode.min.js" - valine = "/npm/valine@1.4.14/dist/Valine.min.js" - busuanzi = "https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" + valine = "/npm/valine@1.5.1/dist/Valine.min.js" + busuanzi = "/npm/busuanzi@2.3.0/bsz.pure.mini.min.js" utterances = "https://utteranc.es/client.js" + giscus = "https://giscus.app/client.js" diff --git a/config-examples/zh-cn/config.toml b/config-examples/zh-cn/config.toml index 36d02955..e60702f6 100644 --- a/config-examples/zh-cn/config.toml +++ b/config-examples/zh-cn/config.toml @@ -1423,23 +1423,24 @@ uglyURLs = false # 将 path 设置为 "js/lib.min.js", # 并将文件放到你的 /static/js/lib.min.js [params.lib.path] - clipboard = "/npm/clipboard-polyfill@2.8.6/dist/clipboard-polyfill.min.js" - instantsearch = "/npm/instantsearch.js@2/dist/instantsearch.min.js" - gitalk = "/npm/gitalk@1/dist/gitalk.min.js" - gitalk_css = "/npm/gitalk@1/dist/gitalk.css" - instantpage = "/npm/instant.page@5.1.0/instantpage.min.js" - katex = "/npm/katex@0.13.0/dist/katex.min.js" - katex_css = "/npm/katex@0.13.0/dist/katex.min.css" - katex_mhchem = "/npm/katex@0.13.0/dist/contrib/mhchem.min.js" - katex_auto_render = "/npm/katex@0.13.0/dist/contrib/auto-render.min.js" + clipboard = "/npm/clipboard-polyfill@4.0.0/dist/clipboard-polyfill.min.js" + instantsearch = "/npm/instantsearch.js@4.53.0/dist/instantsearch.min.js" + gitalk = "/npm/gitalk@1.8.0/dist/gitalk.min.js" + gitalk_css = "/npm/gitalk@1.8.0/dist/gitalk.css" + instantpage = "/npm/instant.page@5.2.0/instantpage.min.js" + katex = "/npm/katex@0.16.7/dist/katex.min.js" + katex_css = "/npm/katex@0.16.7/dist/katex.min.css" + katex_mhchem = "/npm/katex@0.16.7/dist/contrib/mhchem.min.js" + katex_auto_render = "/npm/katex@0.16.7/dist/contrib/auto-render.min.js" lunr = "/npm/lunr@2.3.9/lunr.min.js" - lunr_tinyseg = "/npm/lunr-languages@1.4.0/tinyseg.js" - lunr_stemmer = "/npm/lunr-languages@1.4.0/min/lunr.stemmer.support.min.js" - lunr_lang = "/npm/lunr-languages@1.4.0/min/lunr.de.min.js" - mathjax = "/npm/mathjax@3.1.2/es5/tex-mml-chtml.js" + lunr_tinyseg = "/npm/lunr-languages@1.10.0/tinyseg.js" + lunr_stemmer = "/npm/lunr-languages@1.10.0/min/lunr.stemmer.support.min.js" + lunr_lang = "/npm/lunr-languages@1.10.0/min/lunr.de.min.js" + mathjax = "/npm/mathjax@3.2.2/es5/tex-mml-chtml.js" medium_zoom = "/npm/medium-zoom@latest/dist/medium-zoom.min.js" - mermaid = "/npm/mermaid@8.8.3/dist/mermaid.min.js" + mermaid = "/npm/mermaid/dist/mermaid.min.js" qrcode = "/npm/qrcode-generator@1.4.4/qrcode.min.js" - valine = "/npm/valine@1.4.14/dist/Valine.min.js" - busuanzi = "https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" + valine = "/npm/valine@1.5.1/dist/Valine.min.js" + busuanzi = "/npm/busuanzi@2.3.0/bsz.pure.mini.min.js" utterances = "https://utteranc.es/client.js" + giscus = "https://giscus.app/client.js" diff --git a/config-examples/zh-tw/config.toml b/config-examples/zh-tw/config.toml index 8bea61e6..15bbb464 100644 --- a/config-examples/zh-tw/config.toml +++ b/config-examples/zh-tw/config.toml @@ -1423,23 +1423,24 @@ uglyURLs = false # 將 path 設置為 "js/lib.min.js", # 並將文件放到你的 /static/js/lib.min.js [params.lib.path] - clipboard = "/npm/clipboard-polyfill@2.8.6/dist/clipboard-polyfill.min.js" - instantsearch = "/npm/instantsearch.js@2/dist/instantsearch.min.js" - gitalk = "/npm/gitalk@1/dist/gitalk.min.js" - gitalk_css = "/npm/gitalk@1/dist/gitalk.css" - instantpage = "/npm/instant.page@5.1.0/instantpage.min.js" - katex = "/npm/katex@0.13.0/dist/katex.min.js" - katex_css = "/npm/katex@0.13.0/dist/katex.min.css" - katex_mhchem = "/npm/katex@0.13.0/dist/contrib/mhchem.min.js" - katex_auto_render = "/npm/katex@0.13.0/dist/contrib/auto-render.min.js" + clipboard = "/npm/clipboard-polyfill@4.0.0/dist/clipboard-polyfill.min.js" + instantsearch = "/npm/instantsearch.js@4.53.0/dist/instantsearch.min.js" + gitalk = "/npm/gitalk@1.8.0/dist/gitalk.min.js" + gitalk_css = "/npm/gitalk@1.8.0/dist/gitalk.css" + instantpage = "/npm/instant.page@5.2.0/instantpage.min.js" + katex = "/npm/katex@0.16.7/dist/katex.min.js" + katex_css = "/npm/katex@0.16.7/dist/katex.min.css" + katex_mhchem = "/npm/katex@0.16.7/dist/contrib/mhchem.min.js" + katex_auto_render = "/npm/katex@0.16.7/dist/contrib/auto-render.min.js" lunr = "/npm/lunr@2.3.9/lunr.min.js" - lunr_tinyseg = "/npm/lunr-languages@1.4.0/tinyseg.js" - lunr_stemmer = "/npm/lunr-languages@1.4.0/min/lunr.stemmer.support.min.js" - lunr_lang = "/npm/lunr-languages@1.4.0/min/lunr.de.min.js" - mathjax = "/npm/mathjax@3.1.2/es5/tex-mml-chtml.js" + lunr_tinyseg = "/npm/lunr-languages@1.10.0/tinyseg.js" + lunr_stemmer = "/npm/lunr-languages@1.10.0/min/lunr.stemmer.support.min.js" + lunr_lang = "/npm/lunr-languages@1.10.0/min/lunr.de.min.js" + mathjax = "/npm/mathjax@3.2.2/es5/tex-mml-chtml.js" medium_zoom = "/npm/medium-zoom@latest/dist/medium-zoom.min.js" - mermaid = "/npm/mermaid@8.8.3/dist/mermaid.min.js" + mermaid = "/npm/mermaid/dist/mermaid.min.js" qrcode = "/npm/qrcode-generator@1.4.4/qrcode.min.js" - valine = "/npm/valine@1.4.14/dist/Valine.min.js" - busuanzi = "https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" + valine = "/npm/valine@1.5.1/dist/Valine.min.js" + busuanzi = "/npm/busuanzi@2.3.0/bsz.pure.mini.min.js" utterances = "https://utteranc.es/client.js" + giscus = "https://giscus.app/client.js" diff --git a/layouts/partials/components/comments.html b/layouts/partials/components/comments.html index 08e9a69f..f3263d40 100644 --- a/layouts/partials/components/comments.html +++ b/layouts/partials/components/comments.html @@ -19,6 +19,10 @@
{{ end }} + {{ if .Site.Params.enableGiscus }} +
+ {{ end }} + {{ if .Site.Params.enableGitalk }}
{{ end }} diff --git a/layouts/partials/third-party/giscus.html b/layouts/partials/third-party/giscus.html new file mode 100644 index 00000000..978ab2af --- /dev/null +++ b/layouts/partials/third-party/giscus.html @@ -0,0 +1,58 @@ +{{- $src := partial "utils/lib.html" (dict "$" . "type" "giscus") -}} + + + +{{- define "giscus-theme" -}} + {{- $theme := .Site.Params.giscusTheme | default "light" -}} + {{- if and .Site.Params.enableDarkMode (eq .Site.Params.defaultTheme "dark") -}} + {{- $theme = .Site.Params.giscusThemeDark | default "dark" -}} + {{- end -}} + + {{- if .Site.Params.enableDarkMode -}} + const isDark = getCurrentTheme() === 'dark'; + if (isDark) { + script.setAttribute('data-theme', '{{ .Site.Params.giscusThemeDark | default "dark" }}'); + } else { + script.setAttribute('data-theme', '{{ .Site.Params.giscusTheme | default "light" }}'); + } + {{- else -}} + script.setAttribute('data-theme', '{{ $theme }}'); + {{- end -}} +{{- end -}} diff --git a/layouts/partials/third-party/katex.html b/layouts/partials/third-party/katex.html index 354f7978..2c212853 100644 --- a/layouts/partials/third-party/katex.html +++ b/layouts/partials/third-party/katex.html @@ -39,11 +39,18 @@ document.body, { delimiters: [ - {left: "$$", right: "$$", display: true}, - {left: "\\[", right: "\\]", display: true}, - {left: "$", right: "$", display: false}, - {left: "\\(", right: "\\)", display: false} - ] + { left: "$$", right: "$$", display: true }, + { left: "\\[", right: "\\]", display: true }, + { left: "$", right: "$", display: false }, + { left: "\\(", right: "\\)", display: false }, + { left: "\\begin{equation}", right: "\\end{equation}", display: true }, + { left: "\\begin{align}", right: "\\end{align}", display: true }, + { left: "\\begin{alignat}", right: "\\end{alignat}", display: true }, + { left: "\\begin{gather}", right: "\\end{gather}", display: true }, + { left: "\\begin{matrix}", right: "\\end{matrix}", display: true }, + { left: "\\begin{array}", right: "\\end{array}", display: true }, + { left: "\\begin{CD}", right: "\\end{CD}", display: true }, + ], } ); } diff --git a/layouts/partials/third-party/script.html b/layouts/partials/third-party/script.html index e36be6fa..32372c19 100644 --- a/layouts/partials/third-party/script.html +++ b/layouts/partials/third-party/script.html @@ -25,6 +25,10 @@ {{ partial "third-party/utterances.html" . }} {{ end }} + {{ if .Site.Params.enableGiscus }} + {{ partial "third-party/giscus.html" . }} + {{ end }} + {{ if .Site.Params.enableGitalk }} {{ partial "third-party/gitalk.html" . }} {{ end }} diff --git a/layouts/partials/utils/lib.html b/layouts/partials/utils/lib.html index f2b7c881..3f890d11 100644 --- a/layouts/partials/utils/lib.html +++ b/layouts/partials/utils/lib.html @@ -36,19 +36,19 @@ {{- end -}} {{- if eq $type "katex" -}} - {{- $defalut := "/npm/katex@0.13.0/dist/katex.min.js" -}} + {{- $defalut := "/npm/katex@0.16.7/dist/katex.min.js" -}} {{- $path = $.Site.Params.lib.path.katex | default $defalut -}} {{- end -}} {{- if eq $type "katex-css" -}} - {{- $defalut := "/npm/katex@0.13.0/dist/katex.min.css" -}} + {{- $defalut := "/npm/katex@0.16.7/dist/katex.min.css" -}} {{- $path = $.Site.Params.lib.path.katex_css | default $defalut -}} {{- end -}} {{- if eq $type "katex-mhchem" -}} - {{- $defalut := "/npm/katex@0.13.0/dist/contrib/mhchem.min.js" -}} + {{- $defalut := "/npm/katex@0.16.7/dist/contrib/mhchem.min.js" -}} {{- $path = $.Site.Params.lib.path.katex_mhchem | default $defalut -}} {{- end -}} {{- if eq $type "katex-auto-render" -}} - {{- $defalut := "/npm/katex@0.13.0/dist/contrib/auto-render.min.js" -}} + {{- $defalut := "/npm/katex@0.16.7/dist/contrib/auto-render.min.js" -}} {{- $path = $.Site.Params.lib.path.katex_auto_render | default $defalut -}} {{- end -}} @@ -80,7 +80,7 @@ {{- end -}} {{- if eq $type "mermaid" -}} - {{- $defalut := "/npm/mermaid@8.8.3/dist/mermaid.min.js" -}} + {{- $defalut := "/npm/mermaid/dist/mermaid.min.js" -}} {{- $path = $.Site.Params.lib.path.mermaid | default $defalut -}} {{- end -}} @@ -110,6 +110,11 @@ {{- $host = $.Site.Params.lib.path.utterances | default $defalut -}} {{- end -}} +{{- if eq $type "giscus" -}} + {{- $defalut := "https://giscus.app/client.js" -}} + {{- $host = $.Site.Params.lib.path.giscus | default $defalut -}} +{{- end -}} + (with no whitespace) - # summary divider to split summary - # manually. Or use the `summary` - # variable in post’s Front - # Matter to assign it manually. - # The priority of them: assign - # manually > split manually > - # split automatically. Additionally, - # `description` in post’s Front - # Matter has a higher priority - # than assign manually in the - # custom Atom & RSS template of - # MemE. - - - ###################################### - # Dark Mode - - enableDarkMode = true - - defaultTheme = "light" - # Note: light or dark - - hideThemeToggle = false - hideThemeToggleInHome = false - # Note: If dark mode is enabled and - # theme toggle is hidden, your - # readers may still read your - # blog in dark mode if the - # reader’s system is set to dark - # mode. Similarly, if dark mode - # is enabled and is set to the - # default theme, your readers - # may still read your blog in - # light mode, even if you have - # hidden the theme toggle. - # Unless you enable the following - # option. - - overrideSystemPreferences = false - - - ###################################### - # Web App - - # Note: go to https://realfavicongenerator.net/ - # to generate related icons and - # files, unzip after downloading, - # and keep only android-chrome-512x512.png, - # apple-touch-icon.png, mstile-150x150.png, - # safari-pinned-tab.svg, favicon.ico, - # site.webmanifest these files, - # delete the rest. Then move - # these files to the ~/blog/static/icons/ - # directory, move favicon.ico, - # site.webmanifest to the ~/blog/static/ - # directory, and finally rename - # site.webmanifest to manifest.json, - # and check and modify related - # content (the path of the icons). - - themeColor = "#fff" - themeColorDark = "#16171d" - safariMaskColor = "#2a6df4" - msApplicationTileColor = "#fff" - - - ###################################### - # HTML Head Meta, SEO & Social Discovery - - jsonLD = true - openGraph = true - twitterCards = true - # ATTENTION: If you set twitterCards - # to `true`, be sure to - # enable openGraph also. - # Otherwise, the Twitter - # Cards info will be - # incomplete. - - autoDetectImages = true - # Note: It is recommended to enable it. - # Otherwise, you must manually - # specify `images` in post’s - # Front Matter or links you - # shared on social networks or - # APPs will not be able to - # display a summary view with a - # large image. - - - ###################################### - # Service Worker - - # Note: render only in production - # environment - - enableServiceWorker = false - - - ###################################### - # KaTeX (chemical equation supported) - - enableKaTeX = false - # Note: *global settings* - # `katex` in post’s Front Matter - # has a higher priority than here - - - ###################################### - # MathJax (chemical equation supported) - - enableMathJax = false - # Note: *global settings* - # `mathjax` in post’s Front Matter - # has a higher priority than here - - disableMathJaxMenu = false - - - ###################################### - # Mermaid (https://github.com/mermaid-js/mermaid) - - enableMermaid = false - # Note: *global settings* - # `mermaid` in post’s Front Matter - # has a higher priority than here - - mermaidTheme = 'default' - mermaidThemeDark = 'dark' - - - ###################################### - # Comments - - # Note: render only in production - # environment - - enableComments = false - # Note: *global settings* - # `comments` in post’s Front Matter - # has a higher priority than here - - # directly load the comments after pages loaded - autoLoadComments = false - - ## Disqus - enableDisqus = false - disqusShortname = "" - - ## Valine - enableValine = false - valineAppId = "" - valineAppKey = "" - valinePlaceholder = "Just go go" - valinePath = "" - valineAvatar = "mm" - valineMeta = ["nick", "mail", "link"] - valinePageSize = 10 - valineLang = "en" - valineVisitor = false - valineHighlight = true - valineAvatarForce = false - valineRecordIP = false - valineServerURLs = "" - valineEmojiCDN = "" - valineEmojiMaps = {} - valineEnableQQ = false - valineRequiredFields = [] - # Note: https://valine.js.org/ - - ## Utterances - enableUtterances = false - utterancesRepo = "" - utterancesIssueTerm = "pathname" - utterancesTheme = "github-light" - utterancesThemeDark = "photon-dark" - utterancesLabel = "" - # Note: https://utteranc.es/ - - ## Giscus - enableGiscus = true - giscusRepo = "repo/you/want" - giscusRepoId = "" - giscusCategory = "General" - giscusCategoryId = "" - giscusMapping = "pathname" - giscusReactionsEnabled = true - giscusEmitMetaData = false - giscusInputPosition = "top" - giscusTheme = "light_tritanopia" - giscusThemeDark = "dark_tritanopia" - giscusLang = "en" - giscusLabel = "giscus" - # 说明:https://giscus.app - - ## Gitalk - enableGitalk = false - gitalkClientID = "your_client_id" - gitalkClientSecret = "your_client_secret" - gitalkRepo = "your_repository" - gitalkOwner = "your_gitalk_owner" - gitalkAdmin = ["your_gitalk_admin"] - - # 1. default (`location.href`) - # 2. pathname (`location.pathname`) - # 3. hash (hash_filepath) - # 4. custom:your_gitalk_id ("your_gitalk_id") - gitalkID = "pathname" - - gitalkNumber = -1 - gitalkLables = ["Gitalk"] - - # 1. default (`document.title`) - # 2. custom:your_gitalk_title ("your_gitalk_title") - gitalkTitle = "default" - - # 1. default (`location.href` + header.meta[description]) - # 2. href (`location.href`) - # 3. custom:your_gitalk_body ("your_gitalk_body") - gitalkBody = "default" - - # 1. default (`navigator.language || navigator.userLanguage`) - # 2. Support [en, zh-CN, zh-TW, es-ES, fr, ru, de, pl, ko, fa, ja] - gitalkLanguage = "en" - - gitalkDistractionFreeMode = false - gitalkPerPage = 10 - gitalkPagerDirection = "last" - gitalkCreateIssueManually = false - gitalkProxy = "https://cors-anywhere.azm.workers.dev/https://github.com/login/oauth/access_token" - gitalkStaggerDelayBy = 150 - gitalkAppearAnimation = "accordionVertical" - gitalkEnterAnimation = "accordionVertical" - gitalkLeaveAnimation = "accordionVertical" - gitalkEnableHotKey = true - # Note: https://github.com/gitalk/gitalk - - - ###################################### - # Google Analytics - - # Note: render only in production - # environment - - enableGoogleAnalytics = false - - trackingCodeType = "gtag" - # Note: gtag or analytics - - trackingID = "" - - - ###################################### - # Google Site Verification - - googleSiteVerification = "" - - - ###################################### - # Google AdSense - - # Note: render only in production - # environment - - googleAdClient = "" - - ## Auto Ads - enableGoogleAutoAds = false +###################################### +# Header + +enableHeader = true + +enableHeaderAutoHide = false +# Note: works for header layout flex only + +displayHeaderInHome = true +# Note: invalid for header layout flex + +headerBackground = "linear-gradient(90deg, #f795331a 0, #f370551a 15%, #ef4e7b1a 30%, #a166ab1a 44%, #5073b81a 58%, #1098ad1a 72%, #07b39b1a 86%, #6dba821a 100%)" +# Note: https://developer.mozilla.org/en-US/docs/Web/CSS/background + +headerLayout = "flex" +# Note: center or flex + +# Hide menu bar and display a toggle +# on narrow screen? +enableNavToggle = true - ## Ad Units - enableGoogleAdUnits = false - googleAdSlot = "" - googleAdSlotInArticle = "" - googleAdSlotAutoRelaxed = "" +navHeight = "10em" +# Note: menu bar height when it’s +# toggled - ###################################### - # Yandex.Metrika - # https://metrika.yandex.ru/ +###################################### +# Brand Bar (inside header) + +# Use SVG? +siteBrandSVG = false +# If true, put your SVG in the `SVG.toml` +# file and configure the following options. +# Unit: px +siteBrandSVGWidth = 250 +siteBrandSVGHeight = 100 +siteBrandSVGFill = "#fff" +# If false, your site title will be +# used as the default and displayed as +# text. The font size and font color +# can be configured below. The font +# family can be configured in typography +# section at the bottom of this file. +# Unit: em +siteBrandFontSize = 1 +siteBrandFontColor = "var(--color-contrast-high)" + + +###################################### +# Menu Bar + +enableMenu = true +# Note: invalid for header layout flex + +displayMenuInHome = true +# Note: invalid for header layout flex + +# Highlight current menu item by section? +activeInSection = false +# Note: if true, the menu item in the +# post page will be highlighted +# also if that post’s section is +# the `url` of that menu item + + +###################################### +# Homepage Layout + +# For homepage layout, MemE has the +# following four different types: +# 1. poetry A few lines of verse +# 2. footage With fullscreen background videos +# 3. posts List of post’s summary +# 4. page Normal page/post + +homeLayout = "posts" + +## Poetry +# Verse (Markdown supported) +homePoetry = [] +# Padding of links at the bottom +# Unit: em +homeLinksPadding = 1 + +## Footage +homePoster = "" +homeVideoWebm = "" +homeVideoMp4 = "" +homeLogo = "" +homeLogoLink = "" +homeTitle = "" +homeMotto = "" +homeDescription = "" +homeKeywords = "" +homeLinksDelimiter = "" + +## Posts +enableHideInHomepage = false +# Note: enable `hideInHomepage` front +# matter support (disabled by +# default for performance concern) + + +###################################### +# Site Info + +siteLogo = "/icons/apple-touch-icon.png" +# Note: used for JSON-LD, Open Graph + +siteDescription = "MemE is a powerful and highly customizable GoHugo theme for personal blogs." +# Note: used for HTML head meta, JSON-LD, +# Open Graph, Atom, RSS + +siteCreatedTime = "1969-07-20T20:17:43+00:00" +# ATTENTION: keep this format, change +# the number + +siteTwitter = "reuixiy" +# Note: used for Twitter Cards + + +###################################### +# Category By + +# MemE supports category by: +# 1. sections +# 2. categories +# The sections is based on the site’s +# `content` directory structure; the +# categories is based on the post’s +# Front Matter. First of all, category +# means tree structure (nested, with +# sub-category). To achieve it, Hexo +# uses the second method, while Hugo +# uses the first method. Due to the +# different design philosophy, the +# difference between Hexo and Hugo has +# been made. Therefore, this option +# was designed here to be user friendly +# to those who come from Hexo. But note +# that the second method cannot be +# implemented perfectly in Hugo. I +# recommended you adapt to Hugo’s design +# philosophy if you want to keep the +# tree organization structure of your +# posts. + +categoryBy = "categories" +# ATTENTION: If you set it to `sections`, +# be sure to delete `categories` +# in `taxonomies` at the top +# of this file. Otherwise, +# the categories page will +# be invalid. Also, you need +# to create a new +# `content/categories/_index.md` +# file by yourself. + + +###################################### +# Categories Page + +# Enable tree structure layout? +enableTree = true +# ATTENTION: This option cannot be +# disabled if you set +# `categoryBy` to `sections` + +# Display title of posts? +displayPosts = true + +# Display count of posts under each +# category? +displayPostsCount = true + +# Set to a non-negative number to limit +# the number of posts displayed per +# category/section. +limitPostsLimit = -1 + + +###################################### +# Tags Page + +enableTagCloud = true + +fontUnit = "em" +largestFontSize = 2.5 +smallestFontSize = 1 + + +###################################### +# List Page + +listWidth = 36 +# Note: you can leave it empty("") to +# fallback to the default value: 42 +# Unit: em + +displayListTitle = true + +listDateFormat = "January 2" +# ATTENTION: be sure to follow the +# specified format +# https://gohugo.io/functions/format/ + +listDatePosition = "right" +# Note: left or right + +# Separate the list by month? +groupByMonth = true + +# Enable Chinese zodiac? +chineseZodiac = true + +# Translate the year? (valid for title) +i18nYear = false +# Translate the month? (valid for title) +i18nMonth = false + + +###################################### +# Taxonomy List Page + +# Note: for categories page, you can +# set `enableTree` to false to +# get a normal taxonomy list +# page; for tags page, you can +# set `enableTagCloud` to false +# to get a normal taxonomy list +# page. + +# Display count of posts in each +# taxonomy term? +displayTaxonomyTermCount = true + +# Set to a non-negative number to limit +# the number of posts displayed per +# taxonomy term. +limitEntriesLimit = -1 + + +###################################### +# Post Sections + +# Note: the name of the section is the +# name of the folder under the +# site’s `content` directory. + +# mainSections = ["posts"] + + +###################################### +# Atom & RSS + +# Include full content? +includeContent = true +# Note: If false, only the summary of +# the post will be included. The +# summary, Hugo automatically +# takes the first 70 words (you +# can customize this via +# `summaryLength`) of your content +# as its summary by default. +# Alternatively, you may use the +# (with no whitespace) +# summary divider to split summary +# manually. Or use the `summary` +# variable in post’s Front +# Matter to assign it manually. +# The priority of them: assign +# manually > split manually > +# split automatically. Additionally, +# `description` in post’s Front +# Matter has a higher priority +# than assign manually in the +# custom Atom & RSS template of +# MemE. + + +###################################### +# Dark Mode + +enableDarkMode = true + +defaultTheme = "light" +# Note: light or dark + +hideThemeToggle = false +hideThemeToggleInHome = false +# Note: If dark mode is enabled and +# theme toggle is hidden, your +# readers may still read your +# blog in dark mode if the +# reader’s system is set to dark +# mode. Similarly, if dark mode +# is enabled and is set to the +# default theme, your readers +# may still read your blog in +# light mode, even if you have +# hidden the theme toggle. +# Unless you enable the following +# option. + +overrideSystemPreferences = false + + +###################################### +# Web App + +# Note: go to https://realfavicongenerator.net/ +# to generate related icons and +# files, unzip after downloading, +# and keep only android-chrome-512x512.png, +# apple-touch-icon.png, mstile-150x150.png, +# safari-pinned-tab.svg, favicon.ico, +# site.webmanifest these files, +# delete the rest. Then move +# these files to the ~/blog/static/icons/ +# directory, move favicon.ico, +# site.webmanifest to the ~/blog/static/ +# directory, and finally rename +# site.webmanifest to manifest.json, +# and check and modify related +# content (the path of the icons). + +themeColor = "#fff" +themeColorDark = "#16171d" +safariMaskColor = "#2a6df4" +msApplicationTileColor = "#fff" + + +###################################### +# HTML Head Meta, SEO & Social Discovery + +jsonLD = true +openGraph = true +twitterCards = true +# ATTENTION: If you set twitterCards +# to `true`, be sure to +# enable openGraph also. +# Otherwise, the Twitter +# Cards info will be +# incomplete. + +autoDetectImages = true +# Note: It is recommended to enable it. +# Otherwise, you must manually +# specify `images` in post’s +# Front Matter or links you +# shared on social networks or +# APPs will not be able to +# display a summary view with a +# large image. + + +###################################### +# Service Worker + +# Note: render only in production +# environment + +enableServiceWorker = false + + +###################################### +# KaTeX (chemical equation supported) + +enableKaTeX = false +# Note: *global settings* +# `katex` in post’s Front Matter +# has a higher priority than here + + +###################################### +# MathJax (chemical equation supported) + +enableMathJax = false +# Note: *global settings* +# `mathjax` in post’s Front Matter +# has a higher priority than here + +disableMathJaxMenu = false + + +###################################### +# Mermaid (https://github.com/mermaid-js/mermaid) + +enableMermaid = false +# Note: *global settings* +# `mermaid` in post’s Front Matter +# has a higher priority than here + +mermaidTheme = 'default' +mermaidThemeDark = 'dark' + + +###################################### +# Comments + +# Note: render only in production +# environment + +enableComments = false +# Note: *global settings* +# `comments` in post’s Front Matter +# has a higher priority than here + +# directly load the comments after pages loaded +autoLoadComments = false + +## Disqus +enableDisqus = false +disqusShortname = "" + +## Valine +enableValine = false +valineAppId = "" +valineAppKey = "" +valinePlaceholder = "Just go go" +valinePath = "" +valineAvatar = "mm" +valineMeta = ["nick", "mail", "link"] +valinePageSize = 10 +valineLang = "en" +valineVisitor = false +valineHighlight = true +valineAvatarForce = false +valineRecordIP = false +valineServerURLs = "" +valineEmojiCDN = "" +valineEmojiMaps = {} +valineEnableQQ = false +valineRequiredFields = [] +# Note: https://valine.js.org/ + +## Utterances +enableUtterances = false +utterancesRepo = "" +utterancesIssueTerm = "pathname" +utterancesTheme = "github-light" +utterancesThemeDark = "photon-dark" +utterancesLabel = "" +# Note: https://utteranc.es/ + +## Giscus +enableGiscus = true +giscusRepo = "repo/you/want" +giscusRepoId = "" +giscusCategory = "General" +giscusCategoryId = "" +giscusMapping = "pathname" +giscusReactionsEnabled = true +giscusEmitMetaData = false +giscusInputPosition = "top" +giscusTheme = "light_tritanopia" +giscusThemeDark = "dark_tritanopia" +giscusLang = "en" +giscusLabel = "giscus" +# 说明:https://giscus.app - # Note: render only in production - # environment +## Gitalk +enableGitalk = false +gitalkClientID = "your_client_id" +gitalkClientSecret = "your_client_secret" +gitalkRepo = "your_repository" +gitalkOwner = "your_gitalk_owner" +gitalkAdmin = ["your_gitalk_admin"] + +# 1. default (`location.href`) +# 2. pathname (`location.pathname`) +# 3. hash (hash_filepath) +# 4. custom:your_gitalk_id ("your_gitalk_id") +gitalkID = "pathname" + +gitalkNumber = -1 +gitalkLables = ["Gitalk"] + +# 1. default (`document.title`) +# 2. custom:your_gitalk_title ("your_gitalk_title") +gitalkTitle = "default" + +# 1. default (`location.href` + header.meta[description]) +# 2. href (`location.href`) +# 3. custom:your_gitalk_body ("your_gitalk_body") +gitalkBody = "default" + +# 1. default (`navigator.language || navigator.userLanguage`) +# 2. Support [en, zh-CN, zh-TW, es-ES, fr, ru, de, pl, ko, fa, ja] +gitalkLanguage = "en" + +gitalkDistractionFreeMode = false +gitalkPerPage = 10 +gitalkPagerDirection = "last" +gitalkCreateIssueManually = false +gitalkProxy = "https://cors-anywhere.azm.workers.dev/https://github.com/login/oauth/access_token" +gitalkStaggerDelayBy = 150 +gitalkAppearAnimation = "accordionVertical" +gitalkEnterAnimation = "accordionVertical" +gitalkLeaveAnimation = "accordionVertical" +gitalkEnableHotKey = true +# Note: https://github.com/gitalk/gitalk + + +###################################### +# Google Analytics + +# Note: render only in production +# environment + +enableGoogleAnalytics = false + +trackingCodeType = "gtag" +# Note: gtag or analytics + +trackingID = "" + + +###################################### +# Google Site Verification + +googleSiteVerification = "" + + +###################################### +# Google AdSense + +# Note: render only in production +# environment + +googleAdClient = "" - yandexMetrikaId = "" +## Auto Ads +enableGoogleAutoAds = false +## Ad Units +enableGoogleAdUnits = false +googleAdSlot = "" +googleAdSlotInArticle = "" +googleAdSlotAutoRelaxed = "" - ###################################### - # Post Settings - # The color change duration of the - # hyperlink (in seconds) - duration = 0.5 +###################################### +# Yandex.Metrika +# https://metrika.yandex.ru/ - # Primary color of light mode - primaryColorLight = "220, 90%, 56%" - # Primary color of dark mode - primaryColorDark = "201, 65%, 62%" - # ATTENTION: only HSL color values ​​are - # supported +# Note: render only in production +# environment - # The content width of the post - postWidth = 36 - # Note: you can leave it empty("") to - # fallback to the default value: 42 - # Unit: em +yandexMetrikaId = "" - # Is the post original? - original = true - # Note: will affect the author and - # copyright information of the - # post - # *global settings* - # `original` in post’s Front Matter - # has a higher priority than here +###################################### +# Post Settings - ###################################### - # Post Description +# The color change duration of the +# hyperlink (in seconds) +duration = 0.5 - displayPostDescription = true +# Primary color of light mode +primaryColorLight = "220, 90%, 56%" +# Primary color of dark mode +primaryColorDark = "201, 65%, 62%" +# ATTENTION: only HSL color values ​​are +# supported +# The content width of the post +postWidth = 36 +# Note: you can leave it empty("") to +# fallback to the default value: 42 +# Unit: em - ###################################### - # Post Meta Info +# Is the post original? +original = true +# Note: will affect the author and +# copyright information of the +# post +# *global settings* +# `original` in post’s Front Matter +# has a higher priority than here - enablePostMeta = true - # Note: *global settings* - # `meta` in post’s Front Matter - # has a higher priority than here - enablePostMetaInHome = true - # Note: valid for the `posts` and - # `page` homepage layout only +###################################### +# Post Description - postMetaDateFormat = "2006.1.2" - # ATTENTION: be sure to follow the - # specified format - # https://gohugo.io/functions/format/ +displayPostDescription = true - displayPublishedDate = true - publishedDateIcon = "calendar-alt" - displayModifiedDate = true - modifiedDateIcon = "calendar-check" +###################################### +# Post Meta Info - displayExpiredDate = true - expiredDateIcon = "calendar-times" +enablePostMeta = true +# Note: *global settings* +# `meta` in post’s Front Matter +# has a higher priority than here - displayCategory = true - categoryIcon = "folder" - categoryDelimiter = "/" +enablePostMetaInHome = true +# Note: valid for the `posts` and +# `page` homepage layout only - displayWordCount = true - wordCountIcon = "pencil-alt" +postMetaDateFormat = "2006.1.2" +# ATTENTION: be sure to follow the +# specified format +# https://gohugo.io/functions/format/ - displayReadingTime = true - readingTimeIcon = "clock" +displayPublishedDate = true +publishedDateIcon = "calendar-alt" - displayBusuanziPagePV = false - busuanziPagePVIcon = "eye" - # Note: render only in production - # environment - # Homepage is not supported yet - # https://busuanzi.ibruce.info/ +displayModifiedDate = true +modifiedDateIcon = "calendar-check" +displayExpiredDate = true +expiredDateIcon = "calendar-times" - ###################################### - # Markdown Related +displayCategory = true +categoryIcon = "folder" +categoryDelimiter = "/" - # Open external links in a new tab? - hrefTargetBlank = true +displayWordCount = true +wordCountIcon = "pencil-alt" +displayReadingTime = true +readingTimeIcon = "clock" - ###################################### - # Table of Contents +displayBusuanziPagePV = false +busuanziPagePVIcon = "eye" +# Note: render only in production +# environment +# Homepage is not supported yet +# https://busuanzi.ibruce.info/ - enableTOC = false - # Note: *global settings* - # `toc` in post’s Front Matter - # has a higher priority than here - displayTOCTitle = true +###################################### +# Markdown Related - displayTOCNum = true - # Note: *global settings* - # `tocNum` in post’s Front Matter - # has a higher priority than here +# Open external links in a new tab? +hrefTargetBlank = true - linkHeadingsToTOC = true +###################################### +# Table of Contents - ###################################### - # Headings Anchor +enableTOC = false +# Note: *global settings* +# `toc` in post’s Front Matter +# has a higher priority than here - enableHeadingsAnchor = true - # Note: *global settings* - # `anchor` in post’s Front Matter - # has a higher priority than here +displayTOCTitle = true - # Level range of headings - headingsOpt = "1-6" - # Note: regex format, default value - # is 1-6, which is 1|2|3|4|5|6, - # which is h1 to h6. +displayTOCNum = true +# Note: *global settings* +# `tocNum` in post’s Front Matter +# has a higher priority than here - anchorSymbol = "#" - # Note: the anchorIcon has a higher - # priority than anchorSybol - # Default: § +linkHeadingsToTOC = true - anchorIcon = "link" - # Note: you can leave it empty("") to - # fallback to the anchorSymbol - enableAnchorLink = true +###################################### +# Headings Anchor - enableAnchorAutoHide = true +enableHeadingsAnchor = true +# Note: *global settings* +# `anchor` in post’s Front Matter +# has a higher priority than here +# Level range of headings +headingsOpt = "1-6" +# Note: regex format, default value +# is 1-6, which is 1|2|3|4|5|6, +# which is h1 to h6. - ###################################### - # Caption +anchorSymbol = "#" +# Note: the anchorIcon has a higher +# priority than anchorSybol +# Default: § - enableCaption = true +anchorIcon = "link" +# Note: you can leave it empty("") to +# fallback to the anchorSymbol - captionPrefix = "◎ " +enableAnchorLink = true +enableAnchorAutoHide = true - ###################################### - # Image Hosting - # Note: render only in production - # environment - # - # only support absolute URLs - # relative to root, e.g. - # /images/meme.jpg - # (~/blog/static/images/meme.jpg) +###################################### +# Caption - enableImageHost = false +enableCaption = true - imageHostURL = "https://example.com/" +captionPrefix = "◎ " - # Replace the image link in the HTML - # head meta also? - headAlso = false +###################################### +# Image Hosting - ###################################### - # Video Hosting +# Note: render only in production +# environment +# +# only support absolute URLs +# relative to root, e.g. +# /images/meme.jpg +# (~/blog/static/images/meme.jpg) - # Note: render only in production - # environment - # - # only support absolute URLs - # relative to root, e.g. - # /videos/meme.mp4 - # - # and the HTML code you add must - # start with `