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 |
| series | array | series list |
| tags | array | tag list |
| math | bool | enables math formulas rendering |
| mermaid | bool | enables flowcharts rendering |
| math | bool | enables math plugin |
| diagram | bool | enables diagram plugin |
| comment | bool | enable comment plugin |
| draft | bool | disallow being published |
| link | string | a URL to redirect to |

View file

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

View file

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

View file

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

View file

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

View file

@ -52,10 +52,6 @@ params:
displayDescription: true
# selectable specifies if your post content can be selected.
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
# in the buttom of every page.
social:
@ -68,8 +64,19 @@ params:
- name: "rss"
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:
enable: true
provider: giscus
# check out https://disqus.com/
disqus:
@ -90,6 +97,7 @@ params:
reactions: true
metadata: false
# menu.main is an array containing what is used as the navigator.
menu:
main:

View file

@ -3,7 +3,7 @@ author: Mermaid Team
title: Mermaid Diagrams
date: 2021-07-18T10:52:59+08:00
description: A brief guide to Mermaid syntax.
mermaid: true
diagram: true
tags:
- markdown
- 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,7 +1,9 @@
{{ if eq .Site.Params.diagram.provider "mermaid" }}
<script
src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"
crossorigin="anonymous">
</script>
<script>
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>
<script>
// 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 {
document.querySelector('html').classList.add(systemColorScheme);
localStorage.setItem('theme', systemColorScheme);
const local = localStorage.getItem('theme')
if (local) {
default_theme = local
}
localStorage.setItem('theme', default_theme);
window.minima_theme = default_theme;
document.querySelector('html').classList.add(default_theme);
} catch (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>
window.minima_theme = localStorage.getItem('theme')
</script>
{{ if or .Params.math .Site.Params.math }}
{{ partial "katex.html" . }}
{{ if or .Params.math (and .Site.Params.math.enable (ne .Params.math false)) }}
{{ partial "math.html" . }}
{{ end }}
{{ if or .Params.mermaid .Site.Params.mermaid }}
{{ partial "mermaid.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" . }}
{{ if or .Params.diagram (and .Site.Params.diagram.enable (ne .Params.diagram false)) }}
{{ partial "diagram.html" . }}
{{ end }}
{{ if or .Params.comment (and .Site.Params.comment.enable (ne .Params.comment false)) }}
{{ partial "comment.html" . }}
{{ 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>