From 59ee3f114a2740c5ebd181cad12e262bd9b79f61 Mon Sep 17 00:00:00 2001 From: Mivinci Date: Mon, 7 Nov 2022 16:57:21 +0800 Subject: [PATCH] add language navigator and fix some styles --- .github/workflows/site.yml | 2 +- Makefile | 4 +- assets/sass/atom.scss | 38 +++++++++- assets/sass/main.scss | 100 ++++++++++++++------------ assets/sass/markdown.scss | 8 +-- assets/sass/toc.scss | 12 ++-- data/svg.toml | 2 +- exampleSite/config.toml | 25 ++++--- exampleSite/content/instruction.md | 2 +- exampleSite/content/instruction.zh.md | 10 +++ layouts/_default/baseof.html | 6 +- layouts/_default/list.html | 2 +- layouts/_default/single.html | 100 +++++++++++++------------- layouts/_default/terms.html | 2 +- layouts/index.html | 42 +++++------ layouts/partials/footer.html | 34 ++++----- layouts/partials/head.html | 10 +-- layouts/partials/header.html | 33 +++++---- layouts/partials/list.html | 4 +- layouts/partials/paginator.html | 2 +- theme.toml | 10 +-- 21 files changed, 262 insertions(+), 186 deletions(-) create mode 100644 exampleSite/content/instruction.zh.md diff --git a/.github/workflows/site.yml b/.github/workflows/site.yml index 0d8f0c0..e1cf64f 100644 --- a/.github/workflows/site.yml +++ b/.github/workflows/site.yml @@ -30,4 +30,4 @@ jobs: with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./exampleSite/public - cname: h.xjj.pub \ No newline at end of file + # cname: h.xjj.pub \ No newline at end of file diff --git a/Makefile b/Makefile index 24c0ae5..4451d6b 100644 --- a/Makefile +++ b/Makefile @@ -4,11 +4,11 @@ themeDir=../.. .PHONY: dev, build, clean dev: - -rm -r exampleSite/resources hugo server -D -s $(source) --themesDir $(themeDir) --disableFastRender build: hugo -D --gc --minify -s $(source) --themesDir $(themeDir) clean: - rm -r $(source)/public \ No newline at end of file + rm -r $(source)/public + rm -r exampleSite/resources \ No newline at end of file diff --git a/assets/sass/atom.scss b/assets/sass/atom.scss index d81c05e..f296533 100644 --- a/assets/sass/atom.scss +++ b/assets/sass/atom.scss @@ -110,13 +110,15 @@ $screens: ( } } -@include style_with_prefix(""); @each $screen, $size in $screens { @media (max-width: $size) { @include style_with_prefix($screen); } } +@include style_with_prefix(""); + + // border width .bw-0 { border-width: 0; @@ -147,4 +149,38 @@ $screens: ( &:not(:first-child) { margin-left: 0.75rem; } +} + + +/* font weight */ +.font-thin { + font-weight: 100; +} + +.font-extralight { + font-weight: 200; +} + +.font-light { + font-weight: 300; +} + +.font-normal { + font-weight: 400; +} + +.font-medium { + font-weight: 500; +} + +.font-semibold { + font-weight: 600; +} + +.font-bold { + font-weight: 700; +} + +.text-left { + text-align: left; } \ No newline at end of file diff --git a/assets/sass/main.scss b/assets/sass/main.scss index 4f1b1a5..1b866bc 100644 --- a/assets/sass/main.scss +++ b/assets/sass/main.scss @@ -4,38 +4,36 @@ @import "toc.scss"; :root { - --pm: #0fa0ce; - --bd: #e1e1e1; - --bg: #fff; - --ft: #222; + --prime: #0fa0ce; + --grid: #e1e1e1; + --back: #fff; + --text: #222; --tag: #333; - --w-mobile: 640px; + --mobile-w: 640px; --global-font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; } html.dark { - --bg: #181818; - --ft: silver; - --bd: #555; + --back: #181818; + --text: silver; + --grid: #555; --tag: #999; - --ovo-ft: var(--ft); - --ovo-bdr: var(--bd); - --ovo-bg: var(--bg); + --ovo-ft: var(--text); + --ovo-bdr: var(--grid); + --ovo-bg: var(--back); --ovo-bg-hvr: #555; --ovo-tag: #30363d; } body { - max-width: var(--w-mobile); - margin: 3rem auto 0; font-family: var(--global-font-family); font-size: 16px; font-weight: 400; - color: var(--ft); - background-color: var(--bg); + color: var(--text); + background-color: var(--back); transition-property: background-color, border-color, color; transition-duration: 0.5s; } @@ -45,8 +43,6 @@ h2, h3, h4, h5 { - font-family: "Noto Serif SC", 'Times New Roman', Times, sans-serif; - font-weight: 700; line-height: 1.5; } @@ -57,7 +53,40 @@ p { hr { border-width: 0; - border-top: 1px solid var(--bd); + border-top: 1px solid var(--grid); +} + +a { + line-height: 1.5; + text-decoration: none; + color: inherit; +} + +a:hover { + color: var(--prime); +} + +main { + animation: showup 0.7s; +} + +p a { + // font-style: italic; + text-decoration: underline; +} + +footer a { + font-style: unset; + text-decoration: none; +} + +header nav { + color: var(--tag); +} + +header ul { + padding: 0; + list-style: none; } pre, @@ -70,39 +99,11 @@ code { .minima-tag, p code { - background-color: var(--bd); + background-color: var(--grid); padding: 0.2em 0.4em; border-radius: 1px; } -a { - line-height: 1.5; - text-decoration: none; - color: inherit; -} - -a:hover { - color: var(--pm); -} - -main { - animation: showup 0.7s; -} - -p a { - font-style: italic; - text-decoration: underline; -} - -footer a { - font-style: unset; - text-decoration: none; -} - -header nav { - color: var(--tag); -} - ::-webkit-scrollbar { width: 4px; height: 4px; @@ -139,4 +140,9 @@ nav::-webkit-scrollbar { .home-intro { line-height: 1.65; +} + +.container { + max-width: var(--mobile-w); + margin: 0 auto; } \ No newline at end of file diff --git a/assets/sass/markdown.scss b/assets/sass/markdown.scss index 4bb6cb0..d3ccc73 100644 --- a/assets/sass/markdown.scss +++ b/assets/sass/markdown.scss @@ -1,7 +1,7 @@ .md blockquote { background-color: rgba(148, 148, 149, 0.08) ; padding: 1px 1rem; - border-left: 4px solid var(--pm); + border-left: 4px solid var(--prime); font-style: italic; } @@ -16,12 +16,12 @@ } .md table thead { - border-top: 2px solid var(--ft); - border-bottom: 1px solid var(--ft); + border-top: 2px solid var(--text); + border-bottom: 1px solid var(--text); } .md table tbody { - border-bottom: 2px solid var(--ft); + border-bottom: 2px solid var(--text); } .md table th, diff --git a/assets/sass/toc.scss b/assets/sass/toc.scss index f4e2237..342e847 100644 --- a/assets/sass/toc.scss +++ b/assets/sass/toc.scss @@ -1,7 +1,7 @@ details.toc { position: sticky; top: 0; - background-color: var(--bg); + background-color: var(--back); transition: .5s all; } @@ -9,12 +9,12 @@ details.toc summary { position: relative; width: fit-content; cursor: pointer; - background-color: var(--bg); + background-color: var(--back); transition: .5s all; } details.toc div { - background-color: var(--bg); + background-color: var(--back); transition: .5s all; } @@ -49,7 +49,7 @@ details.toc-bar { & div { top: -1em; padding-top: 2em; - background-color: var(--bg); + background-color: var(--back); } & summary { @@ -59,8 +59,8 @@ details.toc-bar { height: var(--toc-bar-ht); margin-left: calc(50% - var(--toc-bar-wd) / 2); border-radius: calc(var(--toc-bar-ht) / 2); - background-color: var(--ft); - box-shadow: var(--bg) 0 0 8px 8px; + background-color: var(--text); + box-shadow: var(--back) 0 0 8px 8px; } } diff --git a/data/svg.toml b/data/svg.toml index 95deee7..ffd81bd 100644 --- a/data/svg.toml +++ b/data/svg.toml @@ -2,4 +2,4 @@ github = 'LinkedIn' twitter = 'Twitter' rss = '' -toc = '' \ No newline at end of file +toc = '' \ No newline at end of file diff --git a/exampleSite/config.toml b/exampleSite/config.toml index 7c8fa52..5470638 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -1,7 +1,7 @@ -baseURL = "http://h.xjj.pub" +baseURL = "https://mivinci.github.io/hugo-theme-minima" languageCode = "en-us" title = "Hi Folks" -copyright = "© XJJ 2022" +copyright = "© 2022 Mivinci" googleAnalytics = "" # paginate decides the number of the newest posts @@ -15,7 +15,7 @@ theme = "hugo-theme-minima" # Author has some of your information to be shown on the home page. [author] -name = "XJJ" +name = "Mivinci" slogon = "A tech lover from Earth 🌍" description = "This is Minima, a clean and minimal Hugo theme porting from the [Hexo Minima](https://github.com/adisaktijrs/hexo-theme-minima). Except for everything from Hexo Minima like dark/light mode, Hugo Minima supports KaTeX, Mermaid, comments and some taxonomies like categories, series and tags. I created this using SASS, VanillaJS and the most importantly, Hugo. 😁" @@ -43,7 +43,7 @@ selectable = true # on texts in some special positions like on titles globalFontFamily = "" # If set true, all your posts will use the chosen comment plugin -# except those with a `comment: false` in their front-matter +# except those with a `comment: false` specified in their front-matter commentOnAllPosts = true # toc decides the shape of the toc button. e.g. default, lines, bar toc = "lines" @@ -94,7 +94,7 @@ url = "https://linkedin/in/leonard-mivinci-63895317a" svg = "" [[params.social]] name = "twitter" -url = "https://twitter.com/Leonard14733745" +url = "https://twitter.com/realmivinci" svg = "" [[params.social]] name = "rss" @@ -106,7 +106,7 @@ svg = "" # providers have to make their 'Access-Control-Allow-Origin' contain # your domain, otherwise the feeds cannot be fetched. [params.friends] -feeds = ["https://h.xjj.pub/index.xml"] +feeds = [] topk = 3 title = "Friends' Posts" proxy = "" # reserved @@ -119,8 +119,8 @@ name = "Home" url = "/" weight = 1 [[menu.main]] -name = "Categories" -url = "/categories" +name = "Tags" +url = "/tags" weight = 2 [[menu.main]] name = "Series" @@ -149,3 +149,12 @@ series = "series" [markup.highlight] lineNos = true noClasses = false + + +defaultContentLanguage = "en" +[languages.en] +languageName = "EN" +weight = 1 +[languages.zh] +languageName = "ZH" +weight = 2 \ No newline at end of file diff --git a/exampleSite/content/instruction.md b/exampleSite/content/instruction.md index ec29790..495d752 100644 --- a/exampleSite/content/instruction.md +++ b/exampleSite/content/instruction.md @@ -1,5 +1,5 @@ --- -author: Hugo Authors +author: Mivinci title: Instruction date: 2021-07-19T10:52:59+08:00 description: A Clean and minimal Hugo theme porting from the [Hexo Minima](https://github.com/adisaktijrs/hexo-theme-minima). [Click me](https://h.xjj.pub/) to take a look. diff --git a/exampleSite/content/instruction.zh.md b/exampleSite/content/instruction.zh.md new file mode 100644 index 0000000..52caf4c --- /dev/null +++ b/exampleSite/content/instruction.zh.md @@ -0,0 +1,10 @@ +--- +author: Hugo Authors +title: 使用说明 +date: 2021-07-19T10:52:59+08:00 +description: +math: true +comment: true +--- + +你好 \ No newline at end of file diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index ac50352..97fb99d 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -1,11 +1,13 @@ {{ partial "head.html" . }} - + + {{ partial "header.html" . }} - + {{ block "main" . }} {{ end }} {{ partial "footer.html" . }} + \ No newline at end of file diff --git a/layouts/_default/list.html b/layouts/_default/list.html index c4ca39c..530fea9 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -1,5 +1,5 @@ {{ define "main" }} -
+
{{ if isset .Data "Term" }}

{{ .Data.Singular | title }} - "{{ .Data.Term }}"

{{ else }} diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 32f552f..f16bcb0 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -1,52 +1,54 @@ {{ define "main" }} -{{ if .Params.toc }} -{{ partial "toc.html" . }} -{{ end }} -

{{ .Title }}

-
-
- {{ if .Site.Params.displayDate }} - Posted at — {{ dateFormat .Site.Params.timeformat .Date }} - {{ end }} - {{ if .Draft }} - - DRAFT - - {{ end }} -
- {{ if .Params.tags }} -
- {{ range .Params.tags }} - #{{ . }} - {{ end }} -
- {{ end }} +
+ {{ if .Params.toc }} + {{ partial "toc.html" . }} + {{ end }} +

{{ .Title }}

+
+
+ {{ if .Site.Params.displayDate }} + Posted at — {{ dateFormat .Site.Params.timeformat .Date }} + {{ end }} + {{ if .Draft }} + + DRAFT + + {{ end }} +
+ {{ if .Params.tags }} +
+ {{ range .Params.tags }} + #{{ . }} + {{ end }} +
+ {{ end }} +
+
+

{{ .Description | markdownify | safeHTML }}

+
+ {{ .Content }} +
+
+ {{ if or .Params.math .Site.Params.math }} + {{ 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 "disqus"}} + {{ partial "disqus.html" . }} + {{ end }} + + {{ if eq .Site.Params.comment "ovo"}} + {{ partial "ovo.html" . }} + {{ end }} + + {{ if eq .Site.Params.comment "utterances"}} + {{ partial "utterances.html" . }} + {{ end }} + {{ end }}
-
-

{{ .Description | markdownify | safeHTML }}

-
- {{ .Content }} -
-
-{{ if or .Params.math .Site.Params.math }} -{{ 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 "disqus"}} - {{ partial "disqus.html" . }} - {{ end }} - - {{ if eq .Site.Params.comment "ovo"}} - {{ partial "ovo.html" . }} - {{ end }} - - {{ if eq .Site.Params.comment "utterances"}} - {{ partial "utterances.html" . }} - {{ end }} -{{ end }} {{ end }} \ No newline at end of file diff --git a/layouts/_default/terms.html b/layouts/_default/terms.html index 63a669e..45df283 100644 --- a/layouts/_default/terms.html +++ b/layouts/_default/terms.html @@ -1,5 +1,5 @@ {{ define "main" }} -
+

{{ .Title }}