standarize configuration

This commit is contained in:
Mivinci 2022-11-09 20:51:50 +08:00
parent e4522e429a
commit 37351acf91
17 changed files with 150 additions and 108 deletions

View file

@ -54,8 +54,8 @@ Follow [exampleSite/config.yaml](https://github.com/Mivinci/hugo-theme-minima/bl
| categories | array | category list | | categories | array | category list |
| series | array | series list | | series | array | series list |
| tags | array | tag list | | tags | array | tag list |
| math | bool | enables math formulas rendering | | math | bool | enables math plugin |
| mermaid | bool | enables flowcharts rendering | | diagram | bool | enables diagram plugin |
| comment | bool | enable comment plugin | | comment | bool | enable comment plugin |
| draft | bool | disallow being published | | draft | bool | disallow being published |
| link | string | a URL to redirect to | | link | string | a URL to redirect to |

View file

@ -37,6 +37,10 @@ main p a {
color: var(--prime); color: var(--prime);
} }
main p a:hover {
text-decoration: underline;
}
@keyframes showup { @keyframes showup {
from { from {
opacity: 0; opacity: 0;

View file

@ -34,6 +34,7 @@ hr {
height: 0; /* 1 */ height: 0; /* 1 */
color: inherit; /* 2 */ color: inherit; /* 2 */
border-top-width: 1px; /* 3 */ border-top-width: 1px; /* 3 */
border-color: var(--grid, inherit);
} }
/* /*

View file

@ -1,10 +1,11 @@
.chroma code { .chroma {
color: #d4d4d4; margin: .5em 0;
background-color: #222222;
border-radius: 2px;
} }
.chroma { .chroma code {
background-color: #222222; color: #d4d4d4;
margin: .5em 0;
} }
/* LineTableTD */ /* LineTableTD */

View file

@ -1,13 +1,15 @@
.light { .light {
--prime: #1691b6; --prime: #3170a7;
--grid: #e1e1e1; --grid: #e1e1e1;
--back: #fff; --back: #fff;
--text: #222; --text: #222;
--code-back: #fff;
} }
.dark { .dark {
--prime: #1691b6; --prime: #3170a7;
--back: #181818; --back: #181818;
--text: silver; --text: silver;
--grid: #555; --grid: #555;
--code-back: #222;
} }

View file

@ -52,10 +52,6 @@ params:
displayDescription: true displayDescription: true
# selectable specifies if your post content can be selected. # selectable specifies if your post content can be selected.
selectable: true selectable: true
# commentOnAllPosts specifies if the chosen comment plugin to be enabled on all
# post pages. If enabled, those you don't want a comment plugin to work on just
# set `comment` to false in their front matters.
commentOnAllPosts: true
# social is an array containing as many as social accounts to be displayed # social is an array containing as many as social accounts to be displayed
# in the buttom of every page. # in the buttom of every page.
social: social:
@ -68,8 +64,19 @@ params:
- name: "rss" - name: "rss"
url: "/index.xml" url: "/index.xml"
# comment specifies a comment plugin. # math plugin
math:
enable: false
provider: katex
# diagram plugin
diagram:
enable: false
provider: mermaid
# comment plugin
comment: comment:
enable: true
provider: giscus provider: giscus
# check out https://disqus.com/ # check out https://disqus.com/
disqus: disqus:
@ -90,6 +97,7 @@ params:
reactions: true reactions: true
metadata: false metadata: false
# menu.main is an array containing what is used as the navigator. # menu.main is an array containing what is used as the navigator.
menu: menu:
main: main:

View file

@ -3,7 +3,7 @@ author: Mermaid Team
title: Mermaid Diagrams title: Mermaid Diagrams
date: 2021-07-18T10:52:59+08:00 date: 2021-07-18T10:52:59+08:00
description: A brief guide to Mermaid syntax. description: A brief guide to Mermaid syntax.
mermaid: true diagram: true
tags: tags:
- markdown - markdown
- mermaid - mermaid

View file

@ -0,0 +1,6 @@
{{ define "main" }}
<main class="container mx-auto">
<h1 class="text-5xl font-bold">Oops!</h1>
<p>404 Not Found</p>
</main>
{{ end }}

View file

@ -0,0 +1,67 @@
<!-- slot -->
<div id="comment"></div>
<!-- Giscus -->
{{ if eq .Site.Params.comment.provider "giscus" }}
{{ with .Site.Params.comment.giscus }}
<script>
const s = document.createElement("script")
s.src = "https://giscus.app/client.js"
s.crossOrigin = "anonymous"
s.async = true
s.setAttribute("data-repo", "{{ .repo }}")
s.setAttribute("data-repo-id", "{{ .repoId }}")
s.setAttribute("data-category", "{{ .category }}")
s.setAttribute("data-category-id", "{{ .categoryId }}")
s.setAttribute("data-mapping", "{{ .mapping }}")
s.setAttribute("data-strict", "0")
s.setAttribute("data-reactions-enabled", "{{ cond .reactions 1 0 }}")
s.setAttribute("data-emit-metadata", "{{ cond .metadata 1 0 }}")
s.setAttribute("data-input-position", "{{ .inputPosition }}")
s.setAttribute("data-theme", window.minima_theme + "_protanopia")
s.setAttribute("data-lang", "en")
s.setAttribute("data-loading", "lazy")
document.getElementById("comment").appendChild(s)
</script>
{{ end }}
{{ end }}
<!-- Utterances -->
{{ if eq .Site.Params.comment.provider "utterances" }}
{{ with .Site.Params.comment.utterances }}
<script>
const s = document.createElement("script")
s.src = "https://utteranc.es/client.js"
s.crossOrigin = "anonymous"
s.async = true
s.setAttribute("repo", "{{ .repo }}")
s.setAttribute("issue-term", "{{ .issueTerm }}")
s.setAttribute("label", "{{ .label }}")
s.setAttribute("theme", "github-" + window.minima_theme)
document.getElementById("comment").appendChild(s)
</script>
{{ end }}
{{ end }}
<!-- Disqus -->
{{ if eq .Site.Params.comment.provider "disqus" }}
{{ with .Site.Params.comment.disqus }}
<div id="disqus_thread" class="mt-8 mb-8"></div>
<script type="text/javascript">
// Don't ever inject Disqus on localhost--it creates unwanted
// discussions from 'localhost:1313' on your Disqus account...
if (window.location.hostname == "localhost")
return;
const dsq = document.createElement('script');
dsq.type = 'text/javascript';
dsq.async = true;
const disqus_shortname = '{{ .shortname }}';
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
document.getElementById("comment").appendChild(dsq);
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by
Disqus.</a></noscript>
{{ end }}
{{ end }}

View file

@ -1,3 +1,4 @@
{{ if eq .Site.Params.diagram.provider "mermaid" }}
<script <script
src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js" src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"
crossorigin="anonymous"> crossorigin="anonymous">
@ -5,3 +6,4 @@
<script> <script>
mermaid.init(undefined, 'code.language-mermaid') mermaid.init(undefined, 'code.language-mermaid')
</script> </script>
{{ end }}

View file

@ -1,16 +0,0 @@
<div id="disqus_thread" class="mt-8 mb-8"></div>
<script type="text/javascript">
(function () {
// Don't ever inject Disqus on localhost--it creates unwanted
// discussions from 'localhost:1313' on your Disqus account...
if (window.location.hostname == "localhost")
return;
const dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
const disqus_shortname = '{{ .Site.Params.shortname }}';
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by
Disqus.</a></noscript>

View file

@ -1,18 +0,0 @@
{{ $giscus := .Site.Params.comment.giscus }}
<script
src="https://giscus.app/client.js"
data-repo="{{ $giscus.repo }}"
data-repo-id="{{ $giscus.repoId }}"
data-category="{{ $giscus.category }}"
data-category-id="{{ $giscus.categoryId }}"
data-mapping="{{ $giscus.mapping }}"
data-strict="0"
data-reactions-enabled="{{ cond $giscus.reactions 1 0 }}"
data-emit-metadata="{{ cond $giscus.metadata 1 0 }}"
data-input-position="{{ $giscus.inputPosition }}"
data-theme="preferred_color_scheme"
data-lang="en"
data-loading="lazy"
crossorigin="anonymous"
async>
</script>

View file

@ -30,11 +30,16 @@
</head> </head>
<script> <script>
// default to system color scheme. // default to system color scheme.
let systemColorScheme = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'; let default_theme = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
try { try {
document.querySelector('html').classList.add(systemColorScheme); const local = localStorage.getItem('theme')
localStorage.setItem('theme', systemColorScheme); if (local) {
default_theme = local
}
localStorage.setItem('theme', default_theme);
window.minima_theme = default_theme;
document.querySelector('html').classList.add(default_theme);
} catch (e) { } catch (e) {
console.error(e); console.error(e);
} }

View file

@ -1,25 +0,0 @@
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.13.11/dist/katex.min.css"
integrity="sha384-Um5gpz1odJg5Z4HAmzPtgZKdTBHZdw8S29IecapCSB31ligYPhHQZMIlWLYQGVoc" crossorigin="anonymous">
<!-- The loading of KaTeX is deferred to speed up page rendering -->
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.13.11/dist/katex.min.js"
integrity="sha384-YNHdsYkH6gMx9y3mRkmcJ2mFUjTd0qNQQvY9VYZgQd7DcN7env35GzlmFaZ23JGp" crossorigin="anonymous"></script>
<!-- To automatically render math in text elements, include the auto-render extension: -->
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.13.11/dist/contrib/auto-render.min.js"
integrity="sha384-vZTG03m+2yp6N6BNi5iM4rW4oIwk5DfcNdFfxkk9ZWpDriOkXX8voJBFrAO7MpVl" crossorigin="anonymous"></script>
<script>
document.addEventListener("DOMContentLoaded", function () {
renderMathInElement(document.body, {
// customised options
// • auto-render specific keys, e.g.:
delimiters: [
{ left: '$$', right: '$$', display: true },
{ left: '$', right: '$', display: false },
{ left: '\\(', right: '\\)', display: false },
{ left: '\\[', right: '\\]', display: true }
],
// • rendering keys, e.g.:
throwOnError: false
});
});
</script>

View file

@ -0,0 +1,29 @@
{{ if eq .Site.Params.math.provider "katex" }}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.13.11/dist/katex.min.css"
integrity="sha384-Um5gpz1odJg5Z4HAmzPtgZKdTBHZdw8S29IecapCSB31ligYPhHQZMIlWLYQGVoc" crossorigin="anonymous">
<!-- The loading of KaTeX is deferred to speed up page rendering -->
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.13.11/dist/katex.min.js"
integrity="sha384-YNHdsYkH6gMx9y3mRkmcJ2mFUjTd0qNQQvY9VYZgQd7DcN7env35GzlmFaZ23JGp"
crossorigin="anonymous"></script>
<!-- To automatically render math in text elements, include the auto-render extension: -->
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.13.11/dist/contrib/auto-render.min.js"
integrity="sha384-vZTG03m+2yp6N6BNi5iM4rW4oIwk5DfcNdFfxkk9ZWpDriOkXX8voJBFrAO7MpVl"
crossorigin="anonymous"></script>
<script>
document.addEventListener("DOMContentLoaded", function () {
renderMathInElement(document.body, {
// customised options
// • auto-render specific keys, e.g.:
delimiters: [
{ left: '$$', right: '$$', display: true },
{ left: '$', right: '$', display: false },
{ left: '\\(', right: '\\)', display: false },
{ left: '\\[', right: '\\]', display: true }
],
// • rendering keys, e.g.:
throwOnError: false
});
});
</script>
{{ end }}

View file

@ -1,27 +1,11 @@
<script> {{ if or .Params.math (and .Site.Params.math.enable (ne .Params.math false)) }}
window.minima_theme = localStorage.getItem('theme') {{ partial "math.html" . }}
</script>
{{ if or .Params.math .Site.Params.math }}
{{ partial "katex.html" . }}
{{ end }} {{ end }}
{{ if or .Params.mermaid .Site.Params.mermaid }} {{ if or .Params.diagram (and .Site.Params.diagram.enable (ne .Params.diagram false)) }}
{{ partial "mermaid.html" . }} {{ partial "diagram.html" . }}
{{ end }}
{{ if or .Params.comment (and .Site.Params.commentOnAllPosts (ne .Params.comment false)) }}
{{ if eq .Site.Params.comment.provider "disqus"}}
{{ partial "disqus.html" . }}
{{ end }}
{{ if eq .Site.Params.comment.provider "giscus" }}
{{ partial "giscus.html" . }}
{{ end }}
{{ if eq .Site.Params.comment.provider "utterances"}}
{{ partial "utterances.html" . }}
{{ end }} {{ end }}
{{ if or .Params.comment (and .Site.Params.comment.enable (ne .Params.comment false)) }}
{{ partial "comment.html" . }}
{{ end }} {{ end }}

View file

@ -1,8 +0,0 @@
<script src="https://utteranc.es/client.js"
repo="{{ .Site.Params.utterances.repo }}"
issue-term="{{ .Site.Params.utterances.issueTerm }}"
label="{{ .Site.Params.utterances.label }}"
theme="preferred-color-scheme"
crossorigin="anonymous"
async>
</script>