From f5e440d57b0ed07cd596e2e92eeccb4d71610590 Mon Sep 17 00:00:00 2001 From: Mivinci <1366723936@qq.com> Date: Wed, 26 Jan 2022 23:23:06 +0800 Subject: [PATCH 01/56] v1.1.0 --- README.md | 2 +- exampleSite/content/instruction.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 987ec45..897ab71 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ 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 at the demo site. -> The main branch is in development stage, UI or configurations may vary. You can use the latest stable version [here](https://github.com/Mivinci/hugo-theme-minima/releases/tag/v1.0.0). +> The main branch is in development stage, UI or configurations may vary. You can use the latest stable version [here](https://github.com/Mivinci/hugo-theme-minima/releases/tag/v1.1.0). ![screenshot](./images/tn.png) diff --git a/exampleSite/content/instruction.md b/exampleSite/content/instruction.md index 0bd2709..ec29790 100644 --- a/exampleSite/content/instruction.md +++ b/exampleSite/content/instruction.md @@ -7,7 +7,7 @@ math: true comment: true --- -> The main branch is in development stage, UI or configurations may vary. You can use the latest stable version [here](https://github.com/Mivinci/hugo-theme-minima/releases/tag/v1.0.0). +> The main branch is in development stage, UI or configurations may vary. You can use the latest stable version [here](https://github.com/Mivinci/hugo-theme-minima/releases/tag/v1.1.0). ## Features From 9440dfe1d4777367a30752d93908dad2f5acceea Mon Sep 17 00:00:00 2001 From: XJJ Date: Wed, 26 Jan 2022 23:36:12 +0800 Subject: [PATCH 02/56] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 987ec45..897ab71 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ 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 at the demo site. -> The main branch is in development stage, UI or configurations may vary. You can use the latest stable version [here](https://github.com/Mivinci/hugo-theme-minima/releases/tag/v1.0.0). +> The main branch is in development stage, UI or configurations may vary. You can use the latest stable version [here](https://github.com/Mivinci/hugo-theme-minima/releases/tag/v1.1.0). ![screenshot](./images/tn.png) From 756deb824bfac73e87fb74318670d91929a55935 Mon Sep 17 00:00:00 2001 From: Mivinci <1366723936@qq.com> Date: Sun, 30 Jan 2022 14:14:39 +0800 Subject: [PATCH 03/56] edit theme config --- theme.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/theme.toml b/theme.toml index b491df0..52b5bf6 100644 --- a/theme.toml +++ b/theme.toml @@ -4,10 +4,10 @@ name = "Minima" license = "MIT" licenselink = "https://github.com/mivinci/minima/blob/master/LICENSE" -description = "A Clean and minimal Hugo theme porting from Minima on Hexo." +description = "A Hugo port of Hexo Minima" homepage = "https://github.com/mivinci/hugo-theme-minima" tags = ["minimal", "clean", "blog", "responsive", "personal", "simple", "minimalist", "portfolio", "dark"] -features = ["Dark mode", "KaTeX"] +features = ["Dark mode", "KaTeX", "Mermaid", "VSCode-style code highlighting"] min_version = "0.41.0" [author] From b4031adcd6764e57844cd0e2d55aad93087f6a3a Mon Sep 17 00:00:00 2001 From: Mivinci <1366723936@qq.com> Date: Sun, 30 Jan 2022 15:12:29 +0800 Subject: [PATCH 04/56] new feature: external link post --- README.md | 18 ++++++++++++++++++ docs/README_CN.md | 21 ++++++++++++++++++++- exampleSite/content/about.md | 2 +- exampleSite/content/chinese.md | 2 +- exampleSite/content/link.md | 7 +++++++ exampleSite/content/placeholder-text.md | 2 +- layouts/partials/list.html | 4 ++++ theme.toml | 2 +- 8 files changed, 53 insertions(+), 5 deletions(-) create mode 100644 exampleSite/content/link.md diff --git a/README.md b/README.md index 897ab71..afa452f 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,7 @@ Follow [exampleSite/config.toml](https://github.com/Mivinci/hugo-theme-minima/bl | title | string | Title of the post | | description | string | Description of the post | | date | string | Datetime when the post is written | +| link | string | If set, the post will redirect to an external link | | categories | array | Array of categories the posts belongs to | | series | array | Array of series the post belongs to | | tags | array | Array of tags the posts is related to | @@ -59,6 +60,23 @@ Follow [exampleSite/config.toml](https://github.com/Mivinci/hugo-theme-minima/bl | draft | bool | True if the post isn't already for publishing | | toc | bool | True if the post needs a ToC | +### External Link Post + +Use the `link` in the front matter to make a post a specific external link. Such external link post will redirect to the link provided. + +**Example** + +```yaml +--- +author: XJJ +title: External Link Post +date: 2021-07-17T10:52:59+08:00 +link: https://gohugo.io +--- +``` + +And when you click the title in the list page, you will be redireted to https://gohugo.io which's 🆒. + ### Feedback Feedbacks are welcome [here](https://github.com/Mivinci/hugo-theme-minima/issues). diff --git a/docs/README_CN.md b/docs/README_CN.md index 2b88e9c..d87de22 100644 --- a/docs/README_CN.md +++ b/docs/README_CN.md @@ -51,10 +51,11 @@ git clone https://github.com/mivinci/hugo-theme-minima.git themes/minima 为缩短博客网页的加载和渲染时间,minima 不支持如公式、图表、评论插件的全局配置,需要在每篇文章中设置是否启用相关插件,以下是 minima 目前支持的文章配置。 | 字段 | 类型 | 解释 | -| ----------- | ------ | --------------------------------- | +|:----------- |:------ |:--------------------------------- | | title | string | 文章标题 | | description | string | 文章简介,会显示在标题和正文之间 | | date | string | 文章创建日期 | +| link | string | 外部链接 | | categories | array | 文章分类 | | series | array | 文章专栏 | | tags | array | 文章标签 | @@ -64,6 +65,24 @@ git clone https://github.com/mivinci/hugo-theme-minima.git themes/minima | draft | bool | true:该篇文章为草稿,不会被打包 | | toc | bool | true:为该篇文章开启目录显示 | + +### 外部链接 + +可在 front matter 中通过设置 `link` 来创建外部链接。 + +**Example** + +```yaml +--- +author: XJJ +title: External Link Post +date: 2021-07-17T10:52:59+08:00 +link: https://gohugo.io +--- +``` + +当点击改文章题目时,会跳转到设置的链接地址 https://gohugo.io,🆒 + ### 反馈 欢迎在 [issues](https://github.com/Mivinci/hugo-theme-minima/issues) 下留言,或将问题详细描述发送到我的邮箱:mivinci@qq.com diff --git a/exampleSite/content/about.md b/exampleSite/content/about.md index 7e1b642..c6c879e 100644 --- a/exampleSite/content/about.md +++ b/exampleSite/content/about.md @@ -1,6 +1,6 @@ --- title: "About" -date: 2021-07-16T11:24:06+08:00 +date: 2021-07-10T11:24:06+08:00 draft: false type: about --- diff --git a/exampleSite/content/chinese.md b/exampleSite/content/chinese.md index 16ba62b..b18b6bd 100644 --- a/exampleSite/content/chinese.md +++ b/exampleSite/content/chinese.md @@ -1,7 +1,7 @@ --- author: XJJ title: 中文测试 -date: 2021-07-17T10:52:59+08:00 +date: 2021-07-16T10:52:59+08:00 description: comment: false --- diff --git a/exampleSite/content/link.md b/exampleSite/content/link.md new file mode 100644 index 0000000..4079c14 --- /dev/null +++ b/exampleSite/content/link.md @@ -0,0 +1,7 @@ +--- +author: XJJ +title: External Link Post +date: 2021-07-17T10:52:59+08:00 +description: +link: https://gohugo.io +--- \ No newline at end of file diff --git a/exampleSite/content/placeholder-text.md b/exampleSite/content/placeholder-text.md index 860d681..cf8700f 100644 --- a/exampleSite/content/placeholder-text.md +++ b/exampleSite/content/placeholder-text.md @@ -1,7 +1,7 @@ +++ author = "Hugo Authors" title = "Placeholder Text" -date = "2021-07-18T10:52:59+08:00" +date = "2021-07-11T10:52:59+08:00" description = "Lorem Ipsum Dolor Si Amet" toc = true categories = ["Markdown"] diff --git a/layouts/partials/list.html b/layouts/partials/list.html index 6d0b8a3..5377082 100644 --- a/layouts/partials/list.html +++ b/layouts/partials/list.html @@ -1,5 +1,9 @@
+{{ if .Page.Params.link }} +{{ .Title }} +{{ else }} {{ .Title }} +{{ end }} {{ if .Site.Params.displayDate }}
{{ dateFormat .Site.Params.timeformat .Date }}
{{ end }} diff --git a/theme.toml b/theme.toml index 52b5bf6..c226286 100644 --- a/theme.toml +++ b/theme.toml @@ -7,7 +7,7 @@ licenselink = "https://github.com/mivinci/minima/blob/master/LICENSE" description = "A Hugo port of Hexo Minima" homepage = "https://github.com/mivinci/hugo-theme-minima" tags = ["minimal", "clean", "blog", "responsive", "personal", "simple", "minimalist", "portfolio", "dark"] -features = ["Dark mode", "KaTeX", "Mermaid", "VSCode-style code highlighting"] +features = ["Dark mode", "KaTeX", "Mermaid", "VSCode-style code highlighting", "External link post"] min_version = "0.41.0" [author] From dc8a99d0fa48078cca8f0c0fbf72a71985592279 Mon Sep 17 00:00:00 2001 From: Mivinci <1366723936@qq.com> Date: Sun, 30 Jan 2022 16:36:07 +0800 Subject: [PATCH 05/56] README --- README.md | 5 +++-- docs/README_CN.md | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index afa452f..3daf2ec 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # Minima -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 at the demo site. +A Hugo port of [Hexo Minima](https://github.com/adisaktijrs/hexo-theme-minima). [Demo site](https://h.xjj.pub/). -> The main branch is in development stage, UI or configurations may vary. You can use the latest stable version [here](https://github.com/Mivinci/hugo-theme-minima/releases/tag/v1.1.0). +> The main branch is in development stage, UI or configuration may vary. You can use the latest stable version [here](https://github.com/Mivinci/hugo-theme-minima/releases/tag/v1.1.0). ![screenshot](./images/tn.png) @@ -16,6 +16,7 @@ A Clean and minimal Hugo theme porting from the [Hexo Minima](https://github.com - [x] Google analytics - [x] Disqus/Utterances - [x] Optional ToC +- [x] External link post ## Usage diff --git a/docs/README_CN.md b/docs/README_CN.md index d87de22..eec2459 100644 --- a/docs/README_CN.md +++ b/docs/README_CN.md @@ -14,6 +14,7 @@ Minima 是个简洁但功能完整的 Hugo 主题,是 [Hexo Minima](https://gi - [x] Disqus、Utterances 评论插件(即将支持 Waline) - [x] 文章目录 - [x] 分类、标签、专栏 +- [x] 外部链接 ## 使用 @@ -70,7 +71,7 @@ git clone https://github.com/mivinci/hugo-theme-minima.git themes/minima 可在 front matter 中通过设置 `link` 来创建外部链接。 -**Example** +**示例** ```yaml --- @@ -85,4 +86,4 @@ link: https://gohugo.io ### 反馈 -欢迎在 [issues](https://github.com/Mivinci/hugo-theme-minima/issues) 下留言,或将问题详细描述发送到我的邮箱:mivinci@qq.com +欢迎在 [issues](https://github.com/Mivinci/hugo-theme-minima/issues) 下留言,或将问题详细描述发送到我的邮箱:i@xjj.pub From 8f5abfdbe30b991643e615c91fd90823acfdec8a Mon Sep 17 00:00:00 2001 From: Mivinci <1366723936@qq.com> Date: Thu, 17 Feb 2022 18:18:35 +0800 Subject: [PATCH 06/56] rss feeds --- assets/js/friends.js | 57 ++++++++++++++++++++++++++++++++++++++ assets/js/main.js | 3 +- assets/sass/main.scss | 1 + exampleSite/config.toml | 10 +++++++ layouts/index.html | 2 ++ layouts/partials/list.html | 4 +-- testdata/rss.xml | 0 7 files changed, 74 insertions(+), 3 deletions(-) create mode 100644 assets/js/friends.js create mode 100644 testdata/rss.xml diff --git a/assets/js/friends.js b/assets/js/friends.js new file mode 100644 index 0000000..8564d74 --- /dev/null +++ b/assets/js/friends.js @@ -0,0 +1,57 @@ +const dom = document.getElementById('friends') + +const topk = '{{.Site.Params.friends.topk}}' +const raw = '{{.Site.Params.friends.feeds}}' + +const feeds = raw.replace(/^\[|\]$/g, '').split(' ') + +feeds.forEach(v => fetch(v).then(r => r.text()).then(r => rss(r))) + +/** + * @param {string} xml + */ +function rss(xml) { + xml = xml.trim().replace(/\n/g, '') + const g = xml.matchAll(/<(item|entry)>.*?<\/(item|entry)>/g) + let n = +topk || 2; + while (n) { + const next = g.next() + if (next.done) { + break + } + + // title + const title = next.value[0].match(/(?<=).*(?=<\/title>)/)[0] + + // link + const link = next.value[0].match(/(?<=<(link|id)>).*(?=<\/(link|id)>)/)[0] + + // date + const date = next.value[0].match(/(?<=<(pubDate|updated)>).*(?=<\/(pubDate|updated)>)/)[0] + + // innsert dom + const div = document.createElement('div') + div.className = 'flex justify-between sm:flex-col-reverse my-4 sm:mb-6 sm:mt-3' + div.innerHTML = template(link, title, date) + dom.appendChild(div) + + n--; + } +} + +/** + * @param {string} date + */ +function format(date) { + const d = new Date(date) + return d.toDateString() +} + + +function template() { + const a = arguments + return ` + <a href=${a[0]}>${a[1]}</a> + <div class="sm:mb-2 sm:text-xs">${format(a[2])}</div> + `.trim() +} \ No newline at end of file diff --git a/assets/js/main.js b/assets/js/main.js index 1c8e586..5243f52 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -1,3 +1,4 @@ import "./theme"; import "./style"; -import "./selectable"; \ No newline at end of file +import "./selectable"; +import "./friends"; \ No newline at end of file diff --git a/assets/sass/main.scss b/assets/sass/main.scss index 1afa378..8e948e0 100644 --- a/assets/sass/main.scss +++ b/assets/sass/main.scss @@ -74,6 +74,7 @@ p code { } a { + line-height: 1.5; text-decoration: none; color: inherit; } diff --git a/exampleSite/config.toml b/exampleSite/config.toml index be5e996..b3d1634 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -97,6 +97,16 @@ name = "rss" url = "/index.xml" svg = "" +# If set, titles and links of the topk newest posts extracted from +# the feeds will be displayed in the home page. Note that the feeds +# providers have to make their 'Access-Control-Allow-Origin' contain +# your domain, otherwise the feeds cannot be fetched. +[params.friends] +feeds = ["https://is.boxmoe.cn/atom.xml", "https://xiabor.com/atom.xml"] +topk = 3 +title = "Friends' Posts" + + # Menu.main is an array that's used to decide what entries can be shown # on the navigator of yur blog. You can use a weight to make them ordered. diff --git a/layouts/index.html b/layouts/index.html index 4e643bb..84b96ad 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -15,5 +15,7 @@ {{ end }} {{ partial "paginator.html" . }} </div> + <h3 class="my-6">{{ .Site.Params.friends.title }}</h3> + <div id="friends"></div> </main> {{ end }} \ No newline at end of file diff --git a/layouts/partials/list.html b/layouts/partials/list.html index 5377082..695712e 100644 --- a/layouts/partials/list.html +++ b/layouts/partials/list.html @@ -1,10 +1,10 @@ -<div class="flex justify-between sm:flex-col-reverse my-4 sm:mb-6 sm:mt-3"> +<div class="flex justify-between sm:flex-col-reverse my-3 sm:mb-6 sm:mt-3"> {{ if .Page.Params.link }} <a class="" href="{{ .Page.Params.link }}">{{ .Title }}</a> {{ else }} <a class="" href="{{ .RelPermalink }}">{{ .Title }}</a> {{ end }} {{ if .Site.Params.displayDate }} - <div class="sm:mb-2 sm:text-sm">{{ dateFormat .Site.Params.timeformat .Date }}</div> + <div class="sm:mb-1 sm:text-xs">{{ dateFormat .Site.Params.timeformat .Date }}</div> {{ end }} </div> \ No newline at end of file diff --git a/testdata/rss.xml b/testdata/rss.xml new file mode 100644 index 0000000..e69de29 From 46bb218788e982ef1b9519e41cbb5e9a9e64a4da Mon Sep 17 00:00:00 2001 From: Mivinci <1366723936@qq.com> Date: Thu, 17 Feb 2022 18:20:43 +0800 Subject: [PATCH 07/56] rss feeds --- exampleSite/config.toml | 2 +- layouts/index.html | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/exampleSite/config.toml b/exampleSite/config.toml index b3d1634..85b3215 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -102,7 +102,7 @@ svg = "" # providers have to make their 'Access-Control-Allow-Origin' contain # your domain, otherwise the feeds cannot be fetched. [params.friends] -feeds = ["https://is.boxmoe.cn/atom.xml", "https://xiabor.com/atom.xml"] +feeds = ["https://xjj.pub/index.xml"] topk = 3 title = "Friends' Posts" diff --git a/layouts/index.html b/layouts/index.html index 84b96ad..79b9d7a 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -15,7 +15,9 @@ {{ end }} {{ partial "paginator.html" . }} </div> + {{ if .Site.Params.friends.feeds }} <h3 class="my-6">{{ .Site.Params.friends.title }}</h3> <div id="friends"></div> + {{ end }} </main> {{ end }} \ No newline at end of file From 91a08c63bb07c4ff75579d80a9a1d8021e0c0cf2 Mon Sep 17 00:00:00 2001 From: Mivinci <1366723936@qq.com> Date: Thu, 17 Feb 2022 19:55:29 +0800 Subject: [PATCH 08/56] docs --- README.md | 22 ++++++++++++++++++++-- docs/README_CN.md | 18 +++++++++++++++++- exampleSite/config.toml | 2 +- 3 files changed, 38 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 3daf2ec..c56a43c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,10 @@ # Minima -A Hugo port of [Hexo Minima](https://github.com/adisaktijrs/hexo-theme-minima). [Demo site](https://h.xjj.pub/). +This project was originally a Hugo port of the [Hexo Minima](https://github.com/adisaktijrs/hexo-theme-minima). A lot of changes have been made so far to make Minima cooler. + + +Links: [Demo Site](https://h.xjj.pub/), [Demo Configs](../exampleSite/), [Author's Blog](https://xjj.pub) + > The main branch is in development stage, UI or configuration may vary. You can use the latest stable version [here](https://github.com/Mivinci/hugo-theme-minima/releases/tag/v1.1.0). @@ -17,6 +21,7 @@ A Hugo port of [Hexo Minima](https://github.com/adisaktijrs/hexo-theme-minima). - [x] Disqus/Utterances - [x] Optional ToC - [x] External link post +- [x] RSS ## Usage @@ -76,7 +81,20 @@ link: https://gohugo.io --- ``` -And when you click the title in the list page, you will be redireted to https://gohugo.io which's 🆒. +And when you click the title in the list page, you will be redireted to https://gohugo.io, which's 🆒. + +### RSS Feeds + +v1.1.0 and later versions support subscription to external RSS feeds whereas titles and links to your friends' posts can be displayed in your blog site. For details, see `friends` in the [configuaration](./exampleSite/config.toml) + +**Example** + +```yaml +[params.friends] +feeds = ["https://xjj.pub/index.xml"] +topk = 3 +title = "Friends' Posts" +``` ### Feedback diff --git a/docs/README_CN.md b/docs/README_CN.md index eec2459..cd69634 100644 --- a/docs/README_CN.md +++ b/docs/README_CN.md @@ -1,6 +1,8 @@ # Minima -Minima 是个简洁但功能完整的 Hugo 主题,是 [Hexo Minima](https://github.com/adisaktijrs/hexo-theme-minima) 的 Hugo 版本,但对其界面做了些调整,也添加了些功能.。示例网页:[h.xjj.pub](https://h.xjj.pub/),或直接查看作者的博客网站:[xjj.pub](https://xjj.pub)。 +Minima 是个简洁但功能完整的 Hugo 主题,原本是 [Hexo Minima](https://github.com/adisaktijrs/hexo-theme-minima) 主题的 Hugo 版本,现在已经在其设计行上做了多处调整,和添加新的功能。 + +链接:[示例网页](https://h.xjj.pub/),[示例配置](../exampleSite/config.toml),[作者博客](https://xjj.pub) ![screenshot](../images/tn.png) @@ -15,6 +17,7 @@ Minima 是个简洁但功能完整的 Hugo 主题,是 [Hexo Minima](https://gi - [x] 文章目录 - [x] 分类、标签、专栏 - [x] 外部链接 +- [x] RSS ## 使用 @@ -84,6 +87,19 @@ link: https://gohugo.io 当点击改文章题目时,会跳转到设置的链接地址 https://gohugo.io,🆒 +### RSS Feeds + +v1.1.0 版本之后,Minima 支持订阅 RSS Feeds,因此你可以用来在自己的博客上显示别人的文章标题和链接。详情见 [示例配置](./exampleSite/config.toml) 的 `friends` 部分。 + +**示例** + +```yaml +[params.friends] +feeds = ["https://xjj.pub/index.xml"] +topk = 3 +title = "Friends' Posts" +``` + ### 反馈 欢迎在 [issues](https://github.com/Mivinci/hugo-theme-minima/issues) 下留言,或将问题详细描述发送到我的邮箱:i@xjj.pub diff --git a/exampleSite/config.toml b/exampleSite/config.toml index 85b3215..6aa8c38 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -105,7 +105,7 @@ svg = "" feeds = ["https://xjj.pub/index.xml"] topk = 3 title = "Friends' Posts" - +proxy = "" # reserved # Menu.main is an array that's used to decide what entries can be shown From 62bb79180889734e3d105c3b3afe049fc7d07306 Mon Sep 17 00:00:00 2001 From: Mivinci <1366723936@qq.com> Date: Fri, 18 Feb 2022 10:34:06 +0800 Subject: [PATCH 09/56] demo site --- exampleSite/config.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exampleSite/config.toml b/exampleSite/config.toml index 6aa8c38..6ad23bf 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -102,7 +102,7 @@ svg = "" # providers have to make their 'Access-Control-Allow-Origin' contain # your domain, otherwise the feeds cannot be fetched. [params.friends] -feeds = ["https://xjj.pub/index.xml"] +feeds = ["https://h.xjj.pub/index.xml"] topk = 3 title = "Friends' Posts" proxy = "" # reserved From 5a2a7cc35a5a13b13aa55b87fed43d6f31fc27cd Mon Sep 17 00:00:00 2001 From: Mivinci <1366723936@qq.com> Date: Tue, 12 Apr 2022 21:43:46 +0800 Subject: [PATCH 10/56] add line highlighting #20 --- .gitignore | 3 +- assets/sass/main.scss | 4 ++- assets/sass/syntax.scss | 43 ++++++++++++-------------- exampleSite/content/markdown-syntax.md | 2 +- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/.gitignore b/.gitignore index 96e0abb..551cd43 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .DS_Store public -resources \ No newline at end of file +resources +.hugo_build.lock \ No newline at end of file diff --git a/assets/sass/main.scss b/assets/sass/main.scss index 8e948e0..4f1b1a5 100644 --- a/assets/sass/main.scss +++ b/assets/sass/main.scss @@ -51,7 +51,7 @@ h5 { } p { - line-height: 1.8; + line-height: 1.6; text-align: justify; } @@ -62,8 +62,10 @@ hr { pre, code { + overflow: auto hidden; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 13px; + line-height: 1.3; } .minima-tag, diff --git a/assets/sass/syntax.scss b/assets/sass/syntax.scss index 4cd165b..086182d 100644 --- a/assets/sass/syntax.scss +++ b/assets/sass/syntax.scss @@ -1,14 +1,5 @@ -pre[class*="language-"], -code[class*="language-"] { +.chroma code { color: #d4d4d4; - font-size: 13px; - text-shadow: none; - font-family: Menlo, Monaco, Consolas, "Courier New", monospace; - line-height: 1.5; -} - -pre { - line-height: 1.5; } .chroma { @@ -24,29 +15,30 @@ pre { border: 0; } -.chroma .lntable { - border-spacing: 0; - padding: 0; - margin: 0; - border: 0; - width: auto; - overflow: auto; - display: block; -} - .chroma .lntable tbody { border: 0; } +.chroma .lntable td:nth-child(2) { + width: 100%; +} + +.chroma .lnt, +.chroma .line { + display: block; + line-height: 1.3; +} + /* LineNumbersTable */ .chroma .lnt { color: #999; - display: block; padding-left: .9em; padding-right: 1em; text-align: right; - line-height: 1.5; - font-size: 13px; +} + +.chroma .hl .lnt { + display: inline; } /* Keyword */ @@ -143,3 +135,8 @@ pre { color: #c586c0; } +.chroma .hl { + display: block; + background-color: #585858; +} + diff --git a/exampleSite/content/markdown-syntax.md b/exampleSite/content/markdown-syntax.md index 8fedb1d..08e41f5 100644 --- a/exampleSite/content/markdown-syntax.md +++ b/exampleSite/content/markdown-syntax.md @@ -96,7 +96,7 @@ Tables aren't part of the core Markdown spec, but Hugo supports supports them ou #### Code block with Golang -```go +```go {hl_lines=[3]} type Registry interface { Register(*Service, ...RegisterOption) error Deregister(*Service, ...DeregisterOption) error From ef4d32b9498d529957fc4a24214e34136b47994e Mon Sep 17 00:00:00 2001 From: Mivinci <1366723936@qq.com> Date: Thu, 14 Apr 2022 09:49:24 +0800 Subject: [PATCH 11/56] fix style --- assets/sass/markdown.scss | 3 ++- exampleSite/config.toml | 3 +++ layouts/index.html | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/assets/sass/markdown.scss b/assets/sass/markdown.scss index db4238c..4bb6cb0 100644 --- a/assets/sass/markdown.scss +++ b/assets/sass/markdown.scss @@ -47,7 +47,8 @@ } .md li { - margin-bottom: 1rem; + margin-bottom: .5rem; + line-height: 1.5; } .md ol, diff --git a/exampleSite/config.toml b/exampleSite/config.toml index 6ad23bf..69380ba 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -48,6 +48,9 @@ commentOnAllPosts = true # toc decides the shape of the toc button. e.g. default, lines, bar toc = "lines" +recent = "Recent Posts" +older = "Older Posts" + # Disqus configuration [params.disqus] shortname = "hugo-minima" diff --git a/layouts/index.html b/layouts/index.html index 79b9d7a..ef45cd9 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -4,9 +4,9 @@ <p class="my-0">{{ .Site.Author.slogon }}</p> <p class="my-3 home-intro">{{ .Site.Author.description | markdownify | safeHTML }}</p> {{ if eq .Paginator.PageNumber 1 }} - <h3 class="my-6">Recent Posts</h3> + <h3 class="my-6">{{ .Site.Params.recent }}</h3> {{ else }} - <h3 class="my-6">Older Posts</h3> + <h3 class="my-6">{{ .Site.Params.older }}</h3> {{ end }} <div> {{ $paginator := .Paginate (where .Site.RegularPages "Kind" "page") }} From b4289bcbd43c6fc1770412470f16eda4fe4c9dcc Mon Sep 17 00:00:00 2001 From: Memory Clutter <memclutter@gmail.com> Date: Sat, 5 Nov 2022 15:43:57 +0300 Subject: [PATCH 12/56] Added support for comment label customization --- exampleSite/config.toml | 1 + layouts/partials/utterances.html | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/exampleSite/config.toml b/exampleSite/config.toml index 69380ba..7c8fa52 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -62,6 +62,7 @@ shortname = "hugo-minima" [params.utterances] repo = "mivinci/hugo-theme-minima" issueTerm = "pathname" +label = "comment" # **deprecated** # OvO is a comment plugin written by the author of Minima. diff --git a/layouts/partials/utterances.html b/layouts/partials/utterances.html index d1093e2..9b05863 100644 --- a/layouts/partials/utterances.html +++ b/layouts/partials/utterances.html @@ -2,6 +2,7 @@ const repo = '{{ .Site.Params.utterances.repo }}' const issueTerm = '{{ .Site.Params.utterances.issueTerm }}' const theme = localStorage.theme ? `github-${localStorage.theme}` : 'preferred-color-scheme'; + const label = '{{ .Site.Params.utterances.label }}' const script = document.createElement('script') script.src = 'https://utteranc.es/client.js' @@ -11,7 +12,7 @@ script.setAttribute('repo', repo) script.setAttribute('issue-term', issueTerm) script.setAttribute('theme', theme) - script.setAttribute('label', 'comment') + script.setAttribute('label', label ? label : 'comment') document.querySelector('main').appendChild(script) </script> From 4b2c4a267774e96d473a37366c3ca1bbb98d1b61 Mon Sep 17 00:00:00 2001 From: Memory Clutter <memclutter@gmail.com> Date: Sat, 5 Nov 2022 16:11:16 +0300 Subject: [PATCH 13/56] Added support for i18n url in main menu --- layouts/partials/header.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layouts/partials/header.html b/layouts/partials/header.html index 9ed2d4c..e5870d2 100644 --- a/layouts/partials/header.html +++ b/layouts/partials/header.html @@ -8,7 +8,7 @@ <nav class="flex items-center whitespace-nowrap overflow-x-auto overflow-y-hidden"> {{ range .Site.Menus.main }} - <a class="ml-5" href="{{ .URL }}">{{ .Name }}</a> + <a class="ml-5" href="{{ .URL | absLangURL }}">{{ .Name }}</a> {{ end }} </nav> </header> \ No newline at end of file From c39379d105cee452e8e070d14b08e8b367b946fd Mon Sep 17 00:00:00 2001 From: Memory Clutter <memclutter@gmail.com> Date: Sat, 5 Nov 2022 17:45:26 +0300 Subject: [PATCH 14/56] Fixed terms layout: support i18n url --- layouts/_default/terms.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layouts/_default/terms.html b/layouts/_default/terms.html index 7dff683..63a669e 100644 --- a/layouts/_default/terms.html +++ b/layouts/_default/terms.html @@ -5,7 +5,7 @@ {{ $data := .Data }} {{ range $key, $value := .Data.Terms.ByCount }} <div class="mb-5 flex justify-between"> - <a class="self-start" href="/{{ $data.Plural }}/{{ $value.Name }}"> + <a class="self-start" href="{{ $data.Plural | absLangURL }}/{{ $value.Name }}"> {{ $value.Name }} </a> <span class="">{{ $value.Count }}</span> From 59ee3f114a2740c5ebd181cad12e262bd9b79f61 Mon Sep 17 00:00:00 2001 From: Mivinci <mivinci@qq.com> Date: Mon, 7 Nov 2022 16:57:21 +0800 Subject: [PATCH 15/56] 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 = '<svg fill="#63636f" width="18" role="img" viewBox="0 0 24 24" xmlns="h linkedin = '<svg fill="#0073b1" width="18" role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>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 }}

{{ if .Params.tags }}
- {{ range .Params.tags }} - #{{ . }} + {{ range $tag := .Params.tags }} + {{ $url := printf "tags/%s" $tag | relLangURL }} + #{{ . }} {{ end }}
{{ end }} @@ -26,32 +27,6 @@ {{ .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 "utterances"}} - {{ partial "utterances.html" . }} - {{ end }} - - {{ if eq .Site.Params.comment "giscus" }} - {{ partial "giscus.html" }} - {{ end }} - - {{ if eq .Site.Params.comment "ovo"}} - {{ partial "ovo.html" . }} - {{ end }} - - {{ end }} + {{ partial "plugin.html" . }}
{{ end }} \ No newline at end of file diff --git a/layouts/_default/terms.html b/layouts/_default/terms.html index 1e0b200..75ff2bf 100644 --- a/layouts/_default/terms.html +++ b/layouts/_default/terms.html @@ -5,7 +5,7 @@ {{ $data := .Data }} {{ range $key, $value := .Data.Terms.ByCount }}
- + {{ $value.Name }} {{ $value.Count }} diff --git a/layouts/partials/giscus.html b/layouts/partials/giscus.html index a32e484..68579ac 100644 --- a/layouts/partials/giscus.html +++ b/layouts/partials/giscus.html @@ -1,28 +1,18 @@ - \ No newline at end of file +{{ $giscus := .Site.Params.comment.giscus }} + diff --git a/layouts/partials/head.html b/layouts/partials/head.html index e2aabd4..14d454a 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -29,23 +29,12 @@ {{ end }} + \ No newline at end of file diff --git a/layouts/partials/ovo.html b/layouts/partials/ovo.html deleted file mode 100644 index 8870f5d..0000000 --- a/layouts/partials/ovo.html +++ /dev/null @@ -1,29 +0,0 @@ -
-
评论插件加载中 OvO
-
- - \ No newline at end of file diff --git a/layouts/partials/plugin.html b/layouts/partials/plugin.html new file mode 100644 index 0000000..846b11a --- /dev/null +++ b/layouts/partials/plugin.html @@ -0,0 +1,23 @@ +{{ 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.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 }} \ No newline at end of file diff --git a/layouts/partials/utterances.html b/layouts/partials/utterances.html index 9b05863..8a4325f 100644 --- a/layouts/partials/utterances.html +++ b/layouts/partials/utterances.html @@ -1,18 +1,8 @@ - From 88481e9f0b23d51f11ce72b4a0dddf7cb8117fba Mon Sep 17 00:00:00 2001 From: Mivinci Date: Wed, 9 Nov 2022 18:03:38 +0800 Subject: [PATCH 23/56] fix mermaid --- assets/css/atom.scss | 9 +++++++++ assets/css/syntax.scss | 2 +- assets/js/main.js | 8 +++++--- assets/js/selectable.js | 8 +++++--- assets/js/style.js | 19 ++++++++---------- assets/js/theme.js | 10 ++++------ exampleSite/content/markdown-syntax.md | 7 ++++--- exampleSite/content/markdown-syntax.zh-cn.md | 7 ++++--- layouts/_default/single.html | 2 +- layouts/_default/terms.html | 21 ++++++++++---------- layouts/partials/item.html | 4 ++-- layouts/partials/{math.html => katex.html} | 0 layouts/partials/mermaid.html | 2 +- layouts/partials/plugin.html | 6 +++++- layouts/shortcodes/mermaid.html | 1 - 15 files changed, 59 insertions(+), 47 deletions(-) rename layouts/partials/{math.html => katex.html} (100%) delete mode 100644 layouts/shortcodes/mermaid.html diff --git a/assets/css/atom.scss b/assets/css/atom.scss index f875d77..b1af7e6 100644 --- a/assets/css/atom.scss +++ b/assets/css/atom.scss @@ -36,6 +36,10 @@ align-items: flex-start; } +.items-end { + align-items: flex-end; +} + .items-baseline { align-items: baseline; } @@ -78,6 +82,11 @@ $texts: (xs, 0.75), (sm, 0.875), (base, 1), (lg, 1.125), (xl, 1.25), white-space: nowrap; } +.list-disc { + list-style-type: disc; + padding-inline-start: 22px; +} + /* interactivity */ .cursor-pointer { cursor: pointer; diff --git a/assets/css/syntax.scss b/assets/css/syntax.scss index e3cf5b2..05169a4 100644 --- a/assets/css/syntax.scss +++ b/assets/css/syntax.scss @@ -3,7 +3,7 @@ } .chroma { - background-color: #292929; + background-color: #222222; margin: .5em 0; } diff --git a/assets/js/main.js b/assets/js/main.js index ab59668..c1e94f0 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -1,6 +1,8 @@ import { setup_theme_switch } from "./theme" -import "./style"; -import "./selectable"; +import { fix_checkbox_list_style } from "./style" +import { setup_selectable } from './selectable' -setup_theme_switch('theme-switch') \ No newline at end of file +setup_theme_switch('theme-switch') +setup_selectable() +fix_checkbox_list_style('.md ul') \ No newline at end of file diff --git a/assets/js/selectable.js b/assets/js/selectable.js index dc2def5..a801f89 100644 --- a/assets/js/selectable.js +++ b/assets/js/selectable.js @@ -1,4 +1,6 @@ -const selectable = '{{ .Site.Params.selectable }}' -if (selectable === 'false') { - document.documentElement.style = 'user-select:none' +export function setup_selectable () { + const selectable = '{{ .Site.Params.selectable }}' + if (selectable === 'false') { + document.documentElement.style = 'user-select:none' + } } \ No newline at end of file diff --git a/assets/js/style.js b/assets/js/style.js index c185aec..4f63afe 100644 --- a/assets/js/style.js +++ b/assets/js/style.js @@ -1,11 +1,8 @@ -// fix style of checked/unchecked list items -document.querySelectorAll('.md ul').forEach(v => { - if (/
  • .+<\/li>/.test(v.innerHTML)) { - console.log(v); - v.classList.add('ul-checkbox'); - } -}); - - -// // use custom font family -// document.querySelector('body').style.setProperty('--global-font-family', '{{ .Site.Params.globalFontFamily }}'); \ No newline at end of file +/** @param {string} selectors */ +export function fix_checkbox_list_style(selectors) { + document.querySelectorAll(selectors).forEach(v => { + if (/
  • .+<\/li>/.test(v.innerHTML)) { + v.classList.add('ul-checkbox'); + } + }); +} \ No newline at end of file diff --git a/assets/js/theme.js b/assets/js/theme.js index 662c7df..163c55c 100644 --- a/assets/js/theme.js +++ b/assets/js/theme.js @@ -53,16 +53,14 @@ function switch_minima_theme(current, next) { /** @param {string} theme */ function switch_utterances_theme(theme) { - if (!utterances) { - utterances = document.querySelector('iframe.utterances-frame') - } + utterances =utterances || document.querySelector('iframe.utterances-frame') + if (!utterances) return utterances.contentWindow.postMessage({ type: 'set-theme', theme }, 'https://utteranc.es') } /** @param {string} theme */ function switch_giscus_theme(theme) { - if (!giscus) { - giscus = document.querySelector('iframe.giscus-frame') - } + giscus = giscus || document.querySelector('iframe.giscus-frame') + if (!giscus) return giscus.contentWindow.postMessage({giscus: {setConfig: {theme}}}, 'https://giscus.app') } diff --git a/exampleSite/content/markdown-syntax.md b/exampleSite/content/markdown-syntax.md index 3d6992f..c16ab5d 100644 --- a/exampleSite/content/markdown-syntax.md +++ b/exampleSite/content/markdown-syntax.md @@ -3,8 +3,9 @@ author: "Hugo Authors" title: "Markdown Syntax Guide" date: "2021-07-18T10:52:59+08:00" description: "Sample article showcasing basic Markdown syntax." -categories: ["markdown"] -tags: ["markdown"] +categories: +tags: + - markdown --- This article offers a sample of basic Markdown syntax that can be used in Hugo content files, also it shows whether basic HTML elements are decorated with CSS in a Hugo theme. @@ -100,7 +101,7 @@ Tables aren't part of the core Markdown spec, but Hugo supports supports them ou type Registry interface { Register(*Service, ...RegisterOption) error Deregister(*Service, ...DeregisterOption) error - GetService(string, ...GetOption) ([]*Service, error) + List(string, ...ListOption) ([]*Service, error) } ``` diff --git a/exampleSite/content/markdown-syntax.zh-cn.md b/exampleSite/content/markdown-syntax.zh-cn.md index 175e92a..8ca9d37 100644 --- a/exampleSite/content/markdown-syntax.zh-cn.md +++ b/exampleSite/content/markdown-syntax.zh-cn.md @@ -3,8 +3,9 @@ author: "Mivinci" title: "Markdown 语法指北" date: "2021-07-18T10:52:59+08:00" description: "一篇 Markdown 示例文章,翻译自官方示例。" -categories: ["markdown"] -tags: ["markdown"] +categories: +tags: + - markdown --- 本文提供了一个可以在 Hugo 内容文件中使用的基本 Markdown 语法示例,还展示了基本 HTML 元素是否在 Hugo 主题中使用 CSS 进行修饰。 @@ -100,7 +101,7 @@ blockquote 元素表示从另一个来源引用的内容,可选地带有必须 type Registry interface { Register(*Service, ...RegisterOption) error Deregister(*Service, ...DeregisterOption) error - GetService(string, ...GetOption) ([]*Service, error) + List(string, ...ListOption) ([]*Service, error) } ``` diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 1720af9..1bcdfcc 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -21,7 +21,7 @@
  • {{ end }} -
    +

    {{ .Description | markdownify | safeHTML }}

    {{ .Content }} diff --git a/layouts/_default/terms.html b/layouts/_default/terms.html index 75ff2bf..86f0080 100644 --- a/layouts/_default/terms.html +++ b/layouts/_default/terms.html @@ -1,16 +1,15 @@ {{ define "main" }}
    -

    {{ .Title }}

    -
    {{ end }} \ No newline at end of file diff --git a/layouts/partials/item.html b/layouts/partials/item.html index 238daed..7d63575 100644 --- a/layouts/partials/item.html +++ b/layouts/partials/item.html @@ -1,12 +1,12 @@
    -
    +
    {{ if .Page.Params.link }} {{ .Title }} {{ else }} {{ .Title }} {{ end }} {{ if .Site.Params.displayDate }} -
    {{ .Date | time.Format (T "timeformat") }}
    +
    {{ .Date | time.Format (T "timeformat") }}
    {{ end }}
    {{ if .Site.Params.displayDescription }} diff --git a/layouts/partials/math.html b/layouts/partials/katex.html similarity index 100% rename from layouts/partials/math.html rename to layouts/partials/katex.html diff --git a/layouts/partials/mermaid.html b/layouts/partials/mermaid.html index fec2c08..46667a0 100644 --- a/layouts/partials/mermaid.html +++ b/layouts/partials/mermaid.html @@ -3,5 +3,5 @@ crossorigin="anonymous"> \ No newline at end of file diff --git a/layouts/partials/plugin.html b/layouts/partials/plugin.html index 846b11a..3528b2c 100644 --- a/layouts/partials/plugin.html +++ b/layouts/partials/plugin.html @@ -1,5 +1,9 @@ + + {{ if or .Params.math .Site.Params.math }} -{{ partial "math.html" . }} +{{ partial "katex.html" . }} {{ end }} {{ if or .Params.mermaid .Site.Params.mermaid }} diff --git a/layouts/shortcodes/mermaid.html b/layouts/shortcodes/mermaid.html deleted file mode 100644 index 13638ee..0000000 --- a/layouts/shortcodes/mermaid.html +++ /dev/null @@ -1 +0,0 @@ -

    {{ safeHTML .Inner }}

    \ No newline at end of file From e4522e429af9a3252fa077b1ac5eed3f4648ae7f Mon Sep 17 00:00:00 2001 From: Mivinci Date: Wed, 9 Nov 2022 18:57:42 +0800 Subject: [PATCH 24/56] fix style --- assets/css/atom.scss | 9 +++++++++ assets/css/main.scss | 11 ++--------- exampleSite/config.yaml | 4 ++-- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/assets/css/atom.scss b/assets/css/atom.scss index b1af7e6..297a669 100644 --- a/assets/css/atom.scss +++ b/assets/css/atom.scss @@ -1,8 +1,17 @@ +// $devices: ("", 0), (sm\:, 480px); +// @each $dev, $size in devices { +// // this is gonna waste hella space +// } + /* layout */ .container { max-width: var(--max-w); } +.hidden { + display: none; +} + .overflow-x-auto { overflow-x: auto; } diff --git a/assets/css/main.scss b/assets/css/main.scss index 5b17375..35b3734 100644 --- a/assets/css/main.scss +++ b/assets/css/main.scss @@ -6,19 +6,11 @@ :root { --max-w: 640px; - --nav-s: 1.5rem; --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; } -@media screen and (min-width: 480px) { - :root { - --nav-s: .5rem; - } -} - - html { font-size: 16px; -webkit-text-size-adjust: 100%; @@ -55,4 +47,5 @@ main p a { opacity: 1; transform: none; } -} \ No newline at end of file +} + diff --git a/exampleSite/config.yaml b/exampleSite/config.yaml index 10ad6a7..28f9f87 100644 --- a/exampleSite/config.yaml +++ b/exampleSite/config.yaml @@ -1,7 +1,7 @@ baseURL: https://mivinci.github.io/hugo-theme-minima languageCode: en-us title: Hugo on Minima -copyright: © 2022 Mivinci +copyright: © 2022 X googleAnalytics: # paginate specifies the maximum number of posts displayed on the home page. paginate: 12 @@ -27,7 +27,7 @@ languages: # author specifies your name, a slogon and your brief self-introduction. author: - name: Mivinci + name: X status: Am currently living on Earth 🌍 description: | This is Minima, a clean and minimal Hugo theme porting from From 37351acf91027bbd13be3bc46762b982e945e3fd Mon Sep 17 00:00:00 2001 From: Mivinci Date: Wed, 9 Nov 2022 20:51:50 +0800 Subject: [PATCH 25/56] standarize configuration --- README.md | 4 +- assets/css/main.scss | 4 ++ assets/css/pre.scss | 1 + assets/css/syntax.scss | 11 +-- assets/css/theme.scss | 6 +- exampleSite/config.yaml | 18 +++-- exampleSite/content/mermaid-diagrams.md | 2 +- layouts/404.html | 6 ++ layouts/partials/comment.html | 67 +++++++++++++++++++ .../partials/{mermaid.html => diagram.html} | 4 +- layouts/partials/disqus.html | 16 ----- layouts/partials/giscus.html | 18 ----- layouts/partials/head.html | 11 ++- layouts/partials/katex.html | 25 ------- layouts/partials/math.html | 29 ++++++++ layouts/partials/plugin.html | 28 ++------ layouts/partials/utterances.html | 8 --- 17 files changed, 150 insertions(+), 108 deletions(-) create mode 100644 layouts/partials/comment.html rename layouts/partials/{mermaid.html => diagram.html} (70%) delete mode 100644 layouts/partials/disqus.html delete mode 100644 layouts/partials/giscus.html delete mode 100644 layouts/partials/katex.html create mode 100644 layouts/partials/math.html delete mode 100644 layouts/partials/utterances.html diff --git a/README.md b/README.md index 0d4e928..8e90dda 100644 --- a/README.md +++ b/README.md @@ -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 | diff --git a/assets/css/main.scss b/assets/css/main.scss index 35b3734..32e71ec 100644 --- a/assets/css/main.scss +++ b/assets/css/main.scss @@ -37,6 +37,10 @@ main p a { color: var(--prime); } +main p a:hover { + text-decoration: underline; +} + @keyframes showup { from { opacity: 0; diff --git a/assets/css/pre.scss b/assets/css/pre.scss index bcdd9f8..ea1e211 100644 --- a/assets/css/pre.scss +++ b/assets/css/pre.scss @@ -34,6 +34,7 @@ hr { height: 0; /* 1 */ color: inherit; /* 2 */ border-top-width: 1px; /* 3 */ + border-color: var(--grid, inherit); } /* diff --git a/assets/css/syntax.scss b/assets/css/syntax.scss index 05169a4..dc1cc99 100644 --- a/assets/css/syntax.scss +++ b/assets/css/syntax.scss @@ -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 */ diff --git a/assets/css/theme.scss b/assets/css/theme.scss index 35080da..8ed22f8 100644 --- a/assets/css/theme.scss +++ b/assets/css/theme.scss @@ -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; } \ No newline at end of file diff --git a/exampleSite/config.yaml b/exampleSite/config.yaml index 28f9f87..b10b658 100644 --- a/exampleSite/config.yaml +++ b/exampleSite/config.yaml @@ -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: diff --git a/exampleSite/content/mermaid-diagrams.md b/exampleSite/content/mermaid-diagrams.md index 9e4d1c5..aa2ec17 100644 --- a/exampleSite/content/mermaid-diagrams.md +++ b/exampleSite/content/mermaid-diagrams.md @@ -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 diff --git a/layouts/404.html b/layouts/404.html index e69de29..aff5634 100644 --- a/layouts/404.html +++ b/layouts/404.html @@ -0,0 +1,6 @@ +{{ define "main" }} +
    +

    Oops!

    +

    404 Not Found

    +
    +{{ end }} \ No newline at end of file diff --git a/layouts/partials/comment.html b/layouts/partials/comment.html new file mode 100644 index 0000000..b7c0441 --- /dev/null +++ b/layouts/partials/comment.html @@ -0,0 +1,67 @@ + +
    + + +{{ if eq .Site.Params.comment.provider "giscus" }} +{{ with .Site.Params.comment.giscus }} + +{{ end }} +{{ end }} + + +{{ if eq .Site.Params.comment.provider "utterances" }} +{{ with .Site.Params.comment.utterances }} + +{{ end }} +{{ end }} + + +{{ if eq .Site.Params.comment.provider "disqus" }} +{{ with .Site.Params.comment.disqus }} +
    + + +{{ end }} +{{ end }} \ No newline at end of file diff --git a/layouts/partials/mermaid.html b/layouts/partials/diagram.html similarity index 70% rename from layouts/partials/mermaid.html rename to layouts/partials/diagram.html index 46667a0..c3bc881 100644 --- a/layouts/partials/mermaid.html +++ b/layouts/partials/diagram.html @@ -1,7 +1,9 @@ +{{ if eq .Site.Params.diagram.provider "mermaid" }} \ No newline at end of file + +{{ end }} \ No newline at end of file diff --git a/layouts/partials/disqus.html b/layouts/partials/disqus.html deleted file mode 100644 index 905a085..0000000 --- a/layouts/partials/disqus.html +++ /dev/null @@ -1,16 +0,0 @@ -
    - - \ No newline at end of file diff --git a/layouts/partials/giscus.html b/layouts/partials/giscus.html deleted file mode 100644 index 68579ac..0000000 --- a/layouts/partials/giscus.html +++ /dev/null @@ -1,18 +0,0 @@ -{{ $giscus := .Site.Params.comment.giscus }} - diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 14d454a..0ae50e6 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -30,11 +30,16 @@ - - - - \ No newline at end of file diff --git a/layouts/partials/math.html b/layouts/partials/math.html new file mode 100644 index 0000000..733ed06 --- /dev/null +++ b/layouts/partials/math.html @@ -0,0 +1,29 @@ +{{ if eq .Site.Params.math.provider "katex" }} + + + + + + + +{{ end }} \ No newline at end of file diff --git a/layouts/partials/plugin.html b/layouts/partials/plugin.html index 3528b2c..f8bee83 100644 --- a/layouts/partials/plugin.html +++ b/layouts/partials/plugin.html @@ -1,27 +1,11 @@ - - -{{ 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 }} \ No newline at end of file diff --git a/layouts/partials/utterances.html b/layouts/partials/utterances.html deleted file mode 100644 index 8a4325f..0000000 --- a/layouts/partials/utterances.html +++ /dev/null @@ -1,8 +0,0 @@ - From bab2a8c6024914a15d656f401e016f3721040554 Mon Sep 17 00:00:00 2001 From: Mivinci <1366723936@qq.com> Date: Thu, 10 Nov 2022 15:09:45 +0800 Subject: [PATCH 26/56] update example content --- assets/css/theme.scss | 4 ++ exampleSite/content/markdown-syntax.md | 32 +++++----- exampleSite/content/markdown-syntax.zh-cn.md | 32 +++++----- exampleSite/content/math-typesetting.md | 62 ++++++++------------ exampleSite/content/mermaid-diagrams.md | 18 +++++- 5 files changed, 80 insertions(+), 68 deletions(-) diff --git a/assets/css/theme.scss b/assets/css/theme.scss index 8ed22f8..8d92649 100644 --- a/assets/css/theme.scss +++ b/assets/css/theme.scss @@ -4,6 +4,8 @@ --back: #fff; --text: #222; --code-back: #fff; + + // code highlighting } .dark { @@ -12,4 +14,6 @@ --text: silver; --grid: #555; --code-back: #222; + + // code highlighting } \ No newline at end of file diff --git a/exampleSite/content/markdown-syntax.md b/exampleSite/content/markdown-syntax.md index c16ab5d..466fd3c 100644 --- a/exampleSite/content/markdown-syntax.md +++ b/exampleSite/content/markdown-syntax.md @@ -67,7 +67,22 @@ Tables aren't part of the core Markdown spec, but Hugo supports supports them ou ## Code Blocks -#### Code block with backticks +#### Code block without code highlighting + +``` + + + + + Example HTML5 Document + + +

    Test

    + + +``` + +#### Code block with HTML ```html @@ -82,20 +97,7 @@ Tables aren't part of the core Markdown spec, but Hugo supports supports them ou ``` -#### Code block indented with four spaces - - - - - - Example HTML5 Document - - -

    Test

    - - - -#### Code block with Golang +#### Code block with Go ```go {hl_lines=[3]} type Registry interface { diff --git a/exampleSite/content/markdown-syntax.zh-cn.md b/exampleSite/content/markdown-syntax.zh-cn.md index 8ca9d37..e790649 100644 --- a/exampleSite/content/markdown-syntax.zh-cn.md +++ b/exampleSite/content/markdown-syntax.zh-cn.md @@ -67,7 +67,22 @@ blockquote 元素表示从另一个来源引用的内容,可选地带有必须 ## 代码块 -#### 带反引号的代码块 +#### 不使用高亮的代码块 + +``` + + + + + Example HTML5 Document + + +

    Test

    + + +``` + +#### HTML 的代码块 ```html @@ -82,20 +97,7 @@ blockquote 元素表示从另一个来源引用的内容,可选地带有必须 ``` -#### 缩进四个空格的代码块 - - - - - - Example HTML5 Document - - -

    Test

    - - - -#### Golang 的代码块 +#### Go 的代码块 ```go {hl_lines=[3]} type Registry interface { diff --git a/exampleSite/content/math-typesetting.md b/exampleSite/content/math-typesetting.md index 5b15fcb..c3d09bd 100644 --- a/exampleSite/content/math-typesetting.md +++ b/exampleSite/content/math-typesetting.md @@ -1,55 +1,43 @@ --- -author: Hugo Authors +author: Mivinci title: Math Typesetting date: 2021-07-18T10:52:59+08:00 -description: A brief guide to setup KaTeX. +description: A brief guide to write mathematical notation. math: true tags: - KaTex --- -Mathematical notation in a Hugo project can be enabled by using third party JavaScript libraries. +Mathematical notation in a Hugo project can be enabled by using third party JavaScript libraries like [KaTeX](https://katex.org) the one that Minima uses. Here's what you can do in the configuration file to enable it. - - -In this example we will be using [KaTeX](https://katex.org/) - -- Create a partial under `/layouts/partials/math.html` -- Within this partial reference the [Auto-render Extension](https://katex.org/docs/autorender.html) or host these scripts locally. -- Include the partial in your templates like so: - -```bash -{{ if or .Params.math .Site.Params.math }} -{{ partial "math.html" . }} -{{ end }} +``` +math: + enable: false + provider: katex ``` -- To enable KaTex globally set the parameter `math` to `true` in a project's configuration -- To enable KaTex on a per page basis include the parameter `math: true` in content files +## Examples -**Note:** Use the online reference of [Supported TeX Functions](https://katex.org/docs/supported.html) +The following are some examples of mathematical notations with KaTeX that are pretty much like LaTeX's. -{{< math.inline >}} -{{ if or .Page.Params.math .Site.Params.math }} +### Block - +``` +\varphi = 1+\frac{1}{1+\frac{1}{1+\frac{1} {1+\cdots}}} +``` - - - -{{ end }} -{{}} +wiil be rendered as: -### Examples - -{{< math.inline >}} - -

    -Inline math: \(\varphi = \dfrac{1+\sqrt5}{2}= 1.6180339887…\) -

    -{{}} - -Block math: $$ - \varphi = 1+\frac{1} {1+\frac{1} {1+\frac{1} {1+\cdots} } } +\varphi = 1+\frac{1}{1+\frac{1}{1+\frac{1} {1+\cdots}}} $$ + +### Inline + +``` +Pythagorean theorem can be written as $a^2+b^2=c^2$ where *a*, *b* and *c* are the length of legs of a triangle. +``` + +will be rendered as: + +Pythagorean theorem can be written as $a^2+b^2=c^2$ where *a*, *b* and *c* are the length of legs of a triangle. diff --git a/exampleSite/content/mermaid-diagrams.md b/exampleSite/content/mermaid-diagrams.md index aa2ec17..242a8e2 100644 --- a/exampleSite/content/mermaid-diagrams.md +++ b/exampleSite/content/mermaid-diagrams.md @@ -2,7 +2,7 @@ author: Mermaid Team title: Mermaid Diagrams date: 2021-07-18T10:52:59+08:00 -description: A brief guide to Mermaid syntax. +description: A brief guide to write diagrams. diagram: true tags: - markdown @@ -26,6 +26,8 @@ C -->|One| D[Result 1] C -->|Two| E[Result 2] ``` +will be rendered as: + ```mermaid flowchart LR @@ -49,6 +51,8 @@ John->>Bob: How about you? Bob-->>John: Jolly good! ``` +will be rendered as: + ```mermaid sequenceDiagram Alice->>John: Hello John, how are you? @@ -74,6 +78,8 @@ gantt Parallel 4 : des6, after des4, 1d ``` +will be rendered as: + ```mermaid gantt section Section @@ -106,6 +112,8 @@ class Class10 { } ``` +will be rendered as: + ```mermaid classDiagram Class01 <|-- AveryLongClass : Cool @@ -137,6 +145,8 @@ Moving --> Crash Crash --> [*] ``` +will be rendered as: + ```mermaid stateDiagram-v2 [*] --> Still @@ -156,6 +166,8 @@ pie "Rats" : 15 ``` +will be rendered as: + ```mermaid pie "Dogs" : 386 @@ -178,6 +190,8 @@ pie Sit down: 3: Me ``` +will be rendered as: + ```mermaid journey title My working day @@ -227,6 +241,8 @@ Rel(SystemAA, SystemC, "Sends e-mails", "SMTP") Rel(SystemC, customerA, "Sends e-mails to") ``` +will be rendered as: + ```mermaid C4Context title System Context diagram for Internet Banking System From 04977374f0cc6c3fb51d19c70b6360dc16ee7141 Mon Sep 17 00:00:00 2001 From: Mivinci <1366723936@qq.com> Date: Thu, 10 Nov 2022 16:00:20 +0800 Subject: [PATCH 27/56] code highlighting colors vary with theme --- assets/css/syntax.scss | 28 ++++++++++++++-------------- assets/css/theme.scss | 26 ++++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 16 deletions(-) diff --git a/assets/css/syntax.scss b/assets/css/syntax.scss index dc1cc99..97de9df 100644 --- a/assets/css/syntax.scss +++ b/assets/css/syntax.scss @@ -1,11 +1,11 @@ .chroma { margin: .5em 0; - background-color: #222222; + background-color: var(--code-back); border-radius: 2px; } .chroma code { - color: #d4d4d4; + color: var(--code-text); } /* LineTableTD */ @@ -32,7 +32,7 @@ /* LineNumbersTable */ .chroma .lnt { - color: #999; + color: var(--code-line-number); padding-left: .9em; padding-right: 1em; text-align: right; @@ -51,11 +51,11 @@ // .chroma .kt, .chroma .k, .chroma .si { - color: #569cd6; + color: var(--code-keyword); } .chroma .na { - color: #9cdcfe; + color: var(--code-attribute); } // .chroma .n, @@ -70,7 +70,7 @@ .chroma .fm, .chroma .nl, .chroma .nn { - color: #569cd6; + color: var(--code-keyword); } /* NameProperty */ @@ -81,7 +81,7 @@ .chroma .vg, .chroma .vi, .chroma .vm { - color: #569cd6; + color: var(--code-keyword); } /* LiteralString */ @@ -99,7 +99,7 @@ .chroma .s1, .chroma .ss, .chroma .cpf { - color: #ce9178; + color: var(--code-literal-string); } /* LiteralNumber */ @@ -110,7 +110,7 @@ .chroma .mi, .chroma .il, .chroma .mo { - color: #b5cea8; + color: var(--code-literal-number); } /* Comment */ @@ -119,25 +119,25 @@ .chroma .cm, .chroma .c1, .chroma .cs { - color: #517043; + color: var(--code-comment); } .chroma .nb, .chroma .kt { - color: #4ec9b0; + color: var(--code-builtin-type); } .chroma .fm, .chroma .nf { - color: #dcdcaa; + color: var(--code-function); } .chroma .cp { - color: #c586c0; + color: var(--code-meta); } .chroma .hl { display: block; - background-color: #585858; + background-color: var(--code-highlighted-line); } \ No newline at end of file diff --git a/assets/css/theme.scss b/assets/css/theme.scss index 8d92649..aaa09e5 100644 --- a/assets/css/theme.scss +++ b/assets/css/theme.scss @@ -3,9 +3,20 @@ --grid: #e1e1e1; --back: #fff; --text: #222; - --code-back: #fff; // code highlighting + --code-back: #f6f8fa; + --code-text: #24292f; + --code-line-number: #999; + --code-keyword: #cf222e; + --code-attribute: #0550ae; + --code-literal-string: #0a3069; + --code-literal-number: #b5cea8; + --code-comment: #6e7781; + --code-builtin-type: #cf222e; + --code-function: #0550ae; + --code-meta: #cf222e; + --code-highlighted-line: #e9e9e9; } .dark { @@ -13,7 +24,18 @@ --back: #181818; --text: silver; --grid: #555; - --code-back: #222; // code highlighting + --code-back: #1d1d1d; + --code-text: #d4d4d4cc; + --code-line-number: #999999ca; + --code-keyword: #569cd6cb; + --code-attribute: #9cdcfecb; + --code-literal-string: #ce9178; + --code-literal-number: #b5cea8; + --code-comment: #517043d5; + --code-builtin-type: #4ec9b0cb; + --code-function: #dcdcaaca; + --code-meta: #c586c0cb; + --code-highlighted-line: #9494951b; } \ No newline at end of file From eda9db772f2510f8510924a824d44b1740161ebe Mon Sep 17 00:00:00 2001 From: Memory Clutter Date: Sun, 13 Nov 2022 23:28:15 +0300 Subject: [PATCH 28/56] Added ru language --- i18n/ru.yaml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 i18n/ru.yaml diff --git a/i18n/ru.yaml b/i18n/ru.yaml new file mode 100644 index 0000000..e55a905 --- /dev/null +++ b/i18n/ru.yaml @@ -0,0 +1,28 @@ +recent: + other: Recent Posts +older: + other: Older Posts + +home: + other: Home +about: + other: Обо мне +categories: + other: Категории +tags: + other: Тэги +series: + other: Серии + +timeformat: + other: Jan 02, 2006 + +paginator: + prev: + other: Новые + next: + other: Старые + +post: + at: + other: Обуликовано \ No newline at end of file From 66ef888efe91804fd7e8ef640ac8e2550b0a9f0b Mon Sep 17 00:00:00 2001 From: Memory Clutter Date: Mon, 14 Nov 2022 00:22:19 +0300 Subject: [PATCH 29/56] Added missing transaltions --- i18n/ru.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/i18n/ru.yaml b/i18n/ru.yaml index e55a905..84eb27a 100644 --- a/i18n/ru.yaml +++ b/i18n/ru.yaml @@ -1,7 +1,7 @@ recent: - other: Recent Posts + other: Свежие посты older: - other: Older Posts + other: Старые посты home: other: Home @@ -25,4 +25,4 @@ paginator: post: at: - other: Обуликовано \ No newline at end of file + other: Обуликовано From 11fee57d2934b7825cdcdf839e115978b65b34aa Mon Sep 17 00:00:00 2001 From: Mivinci <1366723936@qq.com> Date: Mon, 14 Nov 2022 10:53:03 +0800 Subject: [PATCH 30/56] fix #39 --- assets/css/md.scss | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/assets/css/md.scss b/assets/css/md.scss index fd313ec..4861e28 100644 --- a/assets/css/md.scss +++ b/assets/css/md.scss @@ -59,17 +59,22 @@ $heading: (h1, 2.25, 800), (h2, 2, 700), (h3, 1.75, 600), (h4, 1.5, 600), .md ul { list-style: disc; - padding-inline-start: 22px; + padding-inline-start: 30px; +} + +.md ol { + list-style: decimal; + padding-inline-start: 30px; } .md ul input[type="checkbox"] { margin: 0; - margin-right: 3px; + margin-right: 7px; } .md .ul-checkbox { list-style: none; - padding-inline-start: 2px; + padding-inline-start: 8px; } .md li { From db6cb9bdaa83ad78e22838bd9616b9b4d3fb2adf Mon Sep 17 00:00:00 2001 From: foresle Date: Fri, 20 Jan 2023 13:41:54 +0200 Subject: [PATCH 31/56] Added ua language --- i18n/ua.yaml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 i18n/ua.yaml diff --git a/i18n/ua.yaml b/i18n/ua.yaml new file mode 100644 index 0000000..57e4189 --- /dev/null +++ b/i18n/ua.yaml @@ -0,0 +1,28 @@ +recent: + other: Нові дописи +older: + other: Старі дописи + +home: + other: Головна +about: + other: Про мене +categories: + other: Категорії +tags: + other: Теги +series: + other: Серії + +timeformat: + other: Jan 02, 2006 + +paginator: + prev: + other: Нові + next: + other: Старі + +post: + at: + other: Опубліковано From 638ee7a7f6312fd83057ac0f747214f25a89be95 Mon Sep 17 00:00:00 2001 From: x Date: Tue, 7 Feb 2023 16:51:21 +0800 Subject: [PATCH 32/56] fix a typo --- exampleSite/config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exampleSite/config.yaml b/exampleSite/config.yaml index b10b658..4c32d4b 100644 --- a/exampleSite/config.yaml +++ b/exampleSite/config.yaml @@ -28,7 +28,7 @@ languages: # author specifies your name, a slogon and your brief self-introduction. author: name: X - status: Am currently living on Earth 🌍 + status: Currently living on Earth 🌍 description: | This is Minima, a clean and minimal Hugo theme porting from [Hexo Minima](https://github.com/adisaktijrs/hexo-theme-minima). It has supports From 160feab8ce344f747a81207e3da13f7cc82f98e6 Mon Sep 17 00:00:00 2001 From: Emmanuella Rumanti Date: Tue, 28 Feb 2023 15:52:16 +0700 Subject: [PATCH 33/56] Create id.yaml --- i18n/id.yaml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 i18n/id.yaml diff --git a/i18n/id.yaml b/i18n/id.yaml new file mode 100644 index 0000000..761583f --- /dev/null +++ b/i18n/id.yaml @@ -0,0 +1,28 @@ +recent: + other: Postingan Terbaru +older: + other: Postingan Lama + +home: + other: Beranda +about: + other: Tentang +categories: + other: Kategori +tags: + other: Tags +series: + other: Series + +timeformat: + other: 2 Jan 2006 + +paginator: + prev: + other: Lebih Baru + next: + other: Lebih Lama + +post: + at: + other: Postingan pada From 0da4b481c6df271a94fcda04a5a1722c426ab1ce Mon Sep 17 00:00:00 2001 From: x Date: Thu, 2 Mar 2023 02:38:59 +0800 Subject: [PATCH 34/56] add a star history chart --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 8e90dda..39c8743 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,10 @@ I'm currently looking for i18n contributors :) Feedbacks are welcome [here](https://github.com/Mivinci/hugo-theme-minima/issues). +## Star History + +[![Star History Chart](https://api.star-history.com/svg?repos=mivinci/hugo-theme-minima&type=Date)](https://star-history.com/#star-history/star-history&Date) + ## License Hugo Minima is MIT licensed. From 35525243352ea741a87291efb287f9717afcfc17 Mon Sep 17 00:00:00 2001 From: nescatfe Date: Sat, 11 Mar 2023 12:47:51 +0700 Subject: [PATCH 35/56] Adding instagram logo on svg.toml --- data/svg.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/data/svg.toml b/data/svg.toml index 6e0e023..41a6550 100644 --- a/data/svg.toml +++ b/data/svg.toml @@ -4,3 +4,4 @@ twitter = '' email = '' rss = '' +instagram = 'Instagram' \ No newline at end of file From f935dbc74fb25984fdd35d6e40b6a277528b2a07 Mon Sep 17 00:00:00 2001 From: mivinci Date: Tue, 14 Mar 2023 18:00:05 +0800 Subject: [PATCH 36/56] replace style.js with a CSS trick --- assets/css/md.scss | 4 ++-- assets/js/main.js | 2 -- assets/js/style.js | 8 -------- layouts/partials/header.html | 2 +- 4 files changed, 3 insertions(+), 13 deletions(-) delete mode 100644 assets/js/style.js diff --git a/assets/css/md.scss b/assets/css/md.scss index 4861e28..bedd955 100644 --- a/assets/css/md.scss +++ b/assets/css/md.scss @@ -69,10 +69,10 @@ $heading: (h1, 2.25, 800), (h2, 2, 700), (h3, 1.75, 600), (h4, 1.5, 600), .md ul input[type="checkbox"] { margin: 0; - margin-right: 7px; + margin-right: 5px; } -.md .ul-checkbox { +.md ul:has(input) { list-style: none; padding-inline-start: 8px; } diff --git a/assets/js/main.js b/assets/js/main.js index c1e94f0..347b862 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -1,8 +1,6 @@ import { setup_theme_switch } from "./theme" -import { fix_checkbox_list_style } from "./style" import { setup_selectable } from './selectable' setup_theme_switch('theme-switch') setup_selectable() -fix_checkbox_list_style('.md ul') \ No newline at end of file diff --git a/assets/js/style.js b/assets/js/style.js deleted file mode 100644 index 4f63afe..0000000 --- a/assets/js/style.js +++ /dev/null @@ -1,8 +0,0 @@ -/** @param {string} selectors */ -export function fix_checkbox_list_style(selectors) { - document.querySelectorAll(selectors).forEach(v => { - if (/
  • .+<\/li>/.test(v.innerHTML)) { - v.classList.add('ul-checkbox'); - } - }); -} \ No newline at end of file diff --git a/layouts/partials/header.html b/layouts/partials/header.html index 70e8df0..9cb8540 100644 --- a/layouts/partials/header.html +++ b/layouts/partials/header.html @@ -10,7 +10,7 @@
      From a44436d2374775df7803cbde8401206fbd8cb4df Mon Sep 17 00:00:00 2001 From: kranurag78 <84301342+kranurag78@users.noreply.github.com> Date: Wed, 15 Mar 2023 18:21:12 +0530 Subject: [PATCH 37/56] page listing as per the year --- layouts/_default/list.html | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/layouts/_default/list.html b/layouts/_default/list.html index 4a4b6f4..317fe91 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -6,9 +6,14 @@

      {{ .Title }}

      {{ end }}
      - {{ range .Data.Pages }} - {{ partial "item.html" . }} + {{ range .Data.Pages.GroupByDate "2006" }} +

      + {{ .Key }} +

      + {{ range .Pages }} + {{ partial "item.html" . }} + {{ end }} {{ end }}
  • -{{ end }} \ No newline at end of file +{{ end }} From a0a89797edb1a72851aad06a56fbd997c158ff80 Mon Sep 17 00:00:00 2001 From: Mivinci <1366723936@qq.com> Date: Thu, 16 Mar 2023 00:22:34 +0800 Subject: [PATCH 38/56] fix issue #52 --- exampleSite/content/math-typesetting.md | 3 ++- layouts/partials/head.html | 7 +++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/exampleSite/content/math-typesetting.md b/exampleSite/content/math-typesetting.md index c3d09bd..67440b7 100644 --- a/exampleSite/content/math-typesetting.md +++ b/exampleSite/content/math-typesetting.md @@ -1,11 +1,12 @@ --- author: Mivinci title: Math Typesetting -date: 2021-07-18T10:52:59+08:00 +date: 2020-07-18T10:52:59+08:00 description: A brief guide to write mathematical notation. math: true tags: - KaTex + - markdown --- Mathematical notation in a Hugo project can be enabled by using third party JavaScript libraries like [KaTeX](https://katex.org) the one that Minima uses. Here's what you can do in the configuration file to enable it. diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 0ae50e6..7b3aad6 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -15,12 +15,11 @@ {{ $favicon := "favicon.ico" }} - {{ $hash := now.Unix }} - {{ $options := (dict "targetPath" (printf `minima.%d.css` $hash) "outputStyle" "compressed" "enableSourceMap" true) }} + {{ $options := (dict "targetPath" "minima.css" "outputStyle" "compressed" "enableSourceMap" true) }} {{ $style := resources.Get "css/main.scss" | resources.ToCSS $options }} - {{ $options = (dict "targetPath" (printf `minima.%d.js` $hash) "minify" true) }} - {{ $js := resources.Get "js/main.js" | js.Build $options | resources.ExecuteAsTemplate (printf `minima.%d.js` $hash) . }} + {{ $options = (dict "targetPath" "minima.js" "minify" true) }} + {{ $js := resources.Get "js/main.js" | js.Build $options | resources.ExecuteAsTemplate "minima.js" . }} {{ if .IsTranslated }} {{ range .Translations }} From cab0dedf32278cd43e6d703a7fc8c6887aa2ca16 Mon Sep 17 00:00:00 2001 From: mivinci Date: Thu, 16 Mar 2023 20:14:08 +0800 Subject: [PATCH 39/56] update about.md --- exampleSite/content/about.md | 78 +++++++++++++++++++++++++++++++++++- 1 file changed, 77 insertions(+), 1 deletion(-) diff --git a/exampleSite/content/about.md b/exampleSite/content/about.md index c6c879e..04b0e4a 100644 --- a/exampleSite/content/about.md +++ b/exampleSite/content/about.md @@ -1,7 +1,83 @@ --- title: "About" -date: 2021-07-10T11:24:06+08:00 +date: 2019-07-10T11:24:06+08:00 draft: false type: about --- +A clean and minimal Hugo theme porting from [Hexo Minima](https://github.com/adisaktijrs/hexo-theme-minima). Check out the [example site](https://mivinci.github.io/hugo-theme-minima). + +![screenshot](./images/tn.png) + +> Note that the main branch is in development stage, UI or configuration may vary. + + +## Features + +- [x] Dark mode +- [x] Multilingual mode +- [x] Code highlighting - VSCode dark+ +- [x] Math - KaTeX +- [x] Flowcharts - Mermaid +- [x] Comment - Disqus, Utterances, Giscus +- [x] Google analytics +- [x] External link +- [x] RSS + +## Usage + +Before using Minima, make sure you've got Hugo (extended version) installed on your device. + +### Installation + +You can use either `git submodule` or `git clone` to fetch this theme into the directory where Hugo places themes. + +#### Git Submodule + +```bash +git submodule add --depth 1 https://github.com/mivinci/hugo-theme-minima.git themes/minima +``` + +#### Git Clone + +```bash +git clone https://github.com/mivinci/hugo-theme-minima.git themes/minima +``` + + +### Configuration + +Follow [exampleSite/config.yaml](https://github.com/Mivinci/hugo-theme-minima/blob/main/exampleSite/config.yaml) and edit your own one. + +## Supported Front Matters + +| Attr | Type | Explanation | +|:----------- |:------ |:------------| +| title | string | title | +| description | string | description | +| date | string | creation time | +| categories | array | category list | +| series | array | series list | +| tags | array | tag list | +| 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 | + + +## Contribution + +I'm currently looking for i18n contributors :) + +## Feedback + +Feedbacks are welcome [here](https://github.com/Mivinci/hugo-theme-minima/issues). + +## Star History + +[![Star History Chart](https://api.star-history.com/svg?repos=mivinci/hugo-theme-minima&type=Date)](https://star-history.com/#star-history/star-history&Date) + +## License + +Hugo Minima is MIT licensed. From d8d9a04b4f35be60c4ae3aec01ece94276632b31 Mon Sep 17 00:00:00 2001 From: mivinci Date: Mon, 10 Apr 2023 21:37:53 +0800 Subject: [PATCH 40/56] add two more themes --- assets/css/main.scss | 8 +++++ assets/css/syntax.scss | 1 + assets/css/theme.scss | 38 +++++++++++++++++---- assets/js/theme.js | 63 +++++++++++++++++++---------------- exampleSite/config.yaml | 18 +++++----- layouts/partials/head.html | 12 ++++--- layouts/partials/header.html | 2 +- static/texture.png | Bin 0 -> 6290 bytes 8 files changed, 93 insertions(+), 49 deletions(-) create mode 100644 static/texture.png diff --git a/assets/css/main.scss b/assets/css/main.scss index 32e71ec..46ce128 100644 --- a/assets/css/main.scss +++ b/assets/css/main.scss @@ -4,6 +4,7 @@ @import "./md.scss"; @import "./syntax.scss"; + :root { --max-w: 640px; --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, @@ -23,6 +24,8 @@ body { margin: 0 16px; font-family: var(--font); font-weight: 400; + line-height: 1.6; + background-image: var(--back-image); background-color: var(--back); color: var(--text); transition-property: background-color, border-color, color; @@ -53,3 +56,8 @@ main p a:hover { } } +@media (min-width: 640px) { + body { + margin-top: calc(1rem + 2vh); + } +} diff --git a/assets/css/syntax.scss b/assets/css/syntax.scss index 97de9df..186e3c7 100644 --- a/assets/css/syntax.scss +++ b/assets/css/syntax.scss @@ -1,5 +1,6 @@ .chroma { margin: .5em 0; + background-image: var(--back-image); background-color: var(--code-back); border-radius: 2px; } diff --git a/assets/css/theme.scss b/assets/css/theme.scss index aaa09e5..40f4411 100644 --- a/assets/css/theme.scss +++ b/assets/css/theme.scss @@ -1,9 +1,4 @@ -.light { - --prime: #3170a7; - --grid: #e1e1e1; - --back: #fff; - --text: #222; - +:root { // code highlighting --code-back: #f6f8fa; --code-text: #24292f; @@ -19,6 +14,13 @@ --code-highlighted-line: #e9e9e9; } +.light { + --prime: #3170a7; + --grid: #e1e1e1; + --back: #fff; + --text: #333; +} + .dark { --prime: #3170a7; --back: #181818; @@ -38,4 +40,28 @@ --code-function: #dcdcaaca; --code-meta: #c586c0cb; --code-highlighted-line: #9494951b; +} + +.sand { + --prime: #3170a7; + --back: #e6dece; + --text: #434343; + + --code-back: #dbd3c1be; + --code-text: #24292f; + --code-highlighted-line: #cec3ac; + + --back-image: url('texture.png'); +} + +.rock { + --prime: #3170a7; + --back: #ccc; + --text: #434343; + + --code-back: #c1c1c1be; + --code-text: #24292f; + --code-highlighted-line: #afaeae; + + --back-image: url('texture.png'); } \ No newline at end of file diff --git a/assets/js/theme.js b/assets/js/theme.js index 163c55c..61d5af8 100644 --- a/assets/js/theme.js +++ b/assets/js/theme.js @@ -1,7 +1,8 @@ const comment = '{{ .Site.Params.comment.provider }}' +const default_theme_config = '{{ .Site.Params.defaultTheme }}' const icon_light = '{{ index .Site.Params.switch 1 }}' const icon_dark = '{{ index .Site.Params.switch 0 }}' -const THEME_LIGHT = 'light' +const THEME_LIGHT = default_theme_config === 'system' ? 'light' : default_theme_config const THEME_DARK = 'dark' /** @type {HTMLElement} */ @@ -13,28 +14,28 @@ let giscus /** @param {string} id */ export function setup_theme_switch(id) { - if (!toggler) { - toggler = document.getElementById(id) - } - toggler.innerHTML = localStorage.theme === THEME_LIGHT ? icon_light : icon_dark - toggler.addEventListener('click', switch_theme); + if (!toggler) { + toggler = document.getElementById(id) + } + toggler.innerHTML = localStorage.theme === THEME_LIGHT ? icon_light : icon_dark + toggler.addEventListener('click', switch_theme); } function switch_theme() { - const current = localStorage.getItem('theme') - const next = current === THEME_LIGHT ? THEME_DARK : THEME_LIGHT + const current = localStorage.getItem('theme') + const next = current === THEME_LIGHT ? THEME_DARK : THEME_LIGHT - switch_minima_theme(current, next) + switch_minima_theme(current, next) - switch (comment) { - case 'utterances': - switch_utterances_theme(`github-${next}`) - break + switch (comment) { + case 'utterances': + switch_utterances_theme(`github-${next}`) + break case 'giscus': - switch_giscus_theme(next) - break + switch_giscus_theme(next) + break default: - } + } } /** @@ -42,25 +43,31 @@ function switch_theme() { * @param {string} next */ function switch_minima_theme(current, next) { - const { classList } = document.documentElement - const icon = next === THEME_LIGHT ? icon_light : icon_dark; + const { classList } = document.documentElement + const icon = next === THEME_LIGHT ? icon_light : icon_dark; - classList.remove(current); - classList.add(next); - localStorage.setItem('theme', next); - toggler.innerHTML = icon; + classList.remove(current); + classList.add(next); + localStorage.setItem('theme', next); + toggler.innerHTML = icon; } /** @param {string} theme */ function switch_utterances_theme(theme) { - utterances =utterances || document.querySelector('iframe.utterances-frame') - if (!utterances) return - utterances.contentWindow.postMessage({ type: 'set-theme', theme }, 'https://utteranc.es') + if (theme !== 'dark') { + theme = 'light' + } + utterances = utterances || document.querySelector('iframe.utterances-frame') + if (!utterances) return + utterances.contentWindow.postMessage({ type: 'set-theme', theme }, 'https://utteranc.es') } /** @param {string} theme */ function switch_giscus_theme(theme) { - giscus = giscus || document.querySelector('iframe.giscus-frame') - if (!giscus) return - giscus.contentWindow.postMessage({giscus: {setConfig: {theme}}}, 'https://giscus.app') + if (theme !== 'dark') { + theme = 'light_protanopia' + } + giscus = giscus || document.querySelector('iframe.giscus-frame') + if (!giscus) return + giscus.contentWindow.postMessage({ giscus: { setConfig: { theme } } }, 'https://giscus.app') } diff --git a/exampleSite/config.yaml b/exampleSite/config.yaml index 4c32d4b..7581172 100644 --- a/exampleSite/config.yaml +++ b/exampleSite/config.yaml @@ -1,7 +1,7 @@ baseURL: https://mivinci.github.io/hugo-theme-minima languageCode: en-us title: Hugo on Minima -copyright: © 2022 X +copyright: © 2023 X googleAnalytics: # paginate specifies the maximum number of posts displayed on the home page. paginate: 12 @@ -12,10 +12,10 @@ defaultContentLanguage: en # language.x setup languages: en: - languageName: EN + languageName: EN # will be displayed in the navbar. weight: 1 zh-cn: - languageName: ZH + languageName: 简中 # will be displayed in the navbar. weight: 2 author: status: 目前住在地球 🌍 @@ -40,17 +40,17 @@ params: greet: Hello :) # subtitle speficies a subtitle displayed right after the site title. subtitle: - # switch specifies two emojis to be used as the button toggling color themes. + # switch specifies two emojis used as the button toggling color themes. switch: ["🌚", "🌝"] - # defaultTheme specifies a default theme to be used. - # currently available options: light, dark, system. - defaultTheme: system + # minima has one dark theme and multiple light themes. defaultTheme specifies + # a default light theme to use. currently available options: light, sand, rock, system. + defaultTheme: sand # displayDate speficies whether or not to display post date on the home page. displayDate: true # displayDescription specifies whether or not to display post description on # the hoem page. displayDescription: true - # selectable specifies if your post content can be selected. + # selectable specifies if or not your post content can be selected. selectable: true # social is an array containing as many as social accounts to be displayed # in the buttom of every page. @@ -116,7 +116,7 @@ taxonomies: series: series # markup.highlight has two keys set to make sure that the syntax highlighting -# in your posts are rendered correctly, so do not edit them. +# in your posts are rendered correctly, so DO NOT edit them. markup: highlight: lineNos: true diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 7b3aad6..8ef7c53 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -16,7 +16,7 @@ {{ $favicon := "favicon.ico" }} {{ $options := (dict "targetPath" "minima.css" "outputStyle" "compressed" "enableSourceMap" true) }} - {{ $style := resources.Get "css/main.scss" | resources.ToCSS $options }} + {{ $style := resources.Get "css/main.scss" | resources.ExecuteAsTemplate "main.scss" . | resources.ToCSS $options }} {{ $options = (dict "targetPath" "minima.js" "minify" true) }} {{ $js := resources.Get "js/main.js" | js.Build $options | resources.ExecuteAsTemplate "minima.js" . }} @@ -29,12 +29,14 @@ + +{{ end }} {{ end }} \ No newline at end of file From 677808fa3db313d60054c9ea738d14ba944ec616 Mon Sep 17 00:00:00 2001 From: CDN18 Date: Sat, 6 May 2023 08:27:28 +0800 Subject: [PATCH 46/56] integrate umami --- layouts/partials/head.html | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 8ef7c53..6f5d4b6 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -26,6 +26,12 @@ {{ end }} {{ end }} + +{{ if eq .Site.Params.analytics.provider "umami" }} +{{ with .Site.Params.analytics.umami }} + +{{ end }} +{{ end }} + + {{ end }} From 49d5d4863769002c51416931bb0f482b014c9c91 Mon Sep 17 00:00:00 2001 From: CDN18 Date: Sat, 6 May 2023 09:53:23 +0800 Subject: [PATCH 48/56] style: increase max-w & line-height --- assets/css/main.scss | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/assets/css/main.scss b/assets/css/main.scss index 46ce128..b9c9c3c 100644 --- a/assets/css/main.scss +++ b/assets/css/main.scss @@ -6,7 +6,7 @@ :root { - --max-w: 640px; + --max-w: 1080px; --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; @@ -24,7 +24,7 @@ body { margin: 0 16px; font-family: var(--font); font-weight: 400; - line-height: 1.6; + line-height: 2.2; background-image: var(--back-image); background-color: var(--back); color: var(--text); @@ -60,4 +60,4 @@ main p a:hover { body { margin-top: calc(1rem + 2vh); } -} +} \ No newline at end of file From bbdd3c79bbc920ee3510426f50c122f8d7850439 Mon Sep 17 00:00:00 2001 From: CDN18 Date: Sat, 6 May 2023 10:00:38 +0800 Subject: [PATCH 49/56] style: update date color --- layouts/partials/item.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layouts/partials/item.html b/layouts/partials/item.html index 842c07a..4e32c32 100644 --- a/layouts/partials/item.html +++ b/layouts/partials/item.html @@ -6,7 +6,7 @@ {{ .Title }} {{ end }} {{ if .Site.Params.displayDate }} -
    {{ .Date | time.Format (T "timeformat") }}
    +
    {{ .Date | time.Format (T "timeformat") }}
    {{ end }} {{ if .Site.Params.displayDescription }} From 5c8353a16a2a24e551faf0be1caee2a28a0d341d Mon Sep 17 00:00:00 2001 From: Dejavu Moe Date: Sun, 7 May 2023 13:02:48 +0800 Subject: [PATCH 50/56] Make Chroma line numbers unselectable (#57) * Make Chroma line numbers unselectable * Add browser compatibility prefix --- assets/css/syntax.scss | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/assets/css/syntax.scss b/assets/css/syntax.scss index 186e3c7..5d0a0ba 100644 --- a/assets/css/syntax.scss +++ b/assets/css/syntax.scss @@ -37,6 +37,9 @@ padding-left: .9em; padding-right: 1em; text-align: right; + user-select: none; + -moz-user-select: none; + -webkit-user-select: none; } .chroma .hl .lnt { @@ -141,4 +144,4 @@ .chroma .hl { display: block; background-color: var(--code-highlighted-line); -} \ No newline at end of file +} From 14d160af302a59aee1f1059cc155409095d295fe Mon Sep 17 00:00:00 2001 From: Mivinci <1366723936@qq.com> Date: Sun, 7 May 2023 13:11:20 +0800 Subject: [PATCH 51/56] fix some styles --- assets/css/md.scss | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/assets/css/md.scss b/assets/css/md.scss index bedd955..dc6a07b 100644 --- a/assets/css/md.scss +++ b/assets/css/md.scss @@ -108,3 +108,11 @@ $heading: (h1, 2.25, 800), (h2, 2, 700), (h3, 1.75, 600), (h4, 1.5, 600), .md p sup { margin-left: 4px; } + +.md a { + color: var(--prime); +} + +.md a:hover { + text-decoration: underline; +} \ No newline at end of file From ce0ce5be25d37af394f73a8efbbb2d9e182d353e Mon Sep 17 00:00:00 2001 From: Mivinci <1366723936@qq.com> Date: Fri, 12 May 2023 20:30:35 +0800 Subject: [PATCH 52/56] add search support using fusejs --- README.md | 23 ++++++++-------- assets/css/main.scss | 10 +++++++ assets/css/theme.scss | 2 ++ assets/js/min/fuse.basic.min.js | 9 +++++++ assets/js/search.js | 24 +++++++++++++++++ assets/js/selectable.js | 6 +++-- assets/js/theme.js | 10 ++++--- exampleSite/config.yaml | 42 ++++++++++++++++++++++++++--- exampleSite/content/search.md | 4 +++ exampleSite/content/search.zh-cn.md | 4 +++ layouts/_default/search.html | 16 +++++++++++ layouts/index.html | 2 ++ layouts/index.json | 7 +++++ layouts/partials/head.html | 23 ++++++++++++---- 14 files changed, 156 insertions(+), 26 deletions(-) create mode 100644 assets/js/min/fuse.basic.min.js create mode 100644 assets/js/search.js create mode 100644 exampleSite/content/search.md create mode 100644 exampleSite/content/search.zh-cn.md create mode 100644 layouts/_default/search.html create mode 100644 layouts/index.json diff --git a/README.md b/README.md index 39c8743..02c3e28 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,24 @@ # Minima -A clean and minimal Hugo theme porting from [Hexo Minima](https://github.com/adisaktijrs/hexo-theme-minima). Check out the [example site](https://mivinci.github.io/hugo-theme-minima). +Minima is a clean and minimal Hugo theme originally ported from [Hexo Minima](https://github.com/adisaktijrs/hexo-theme-minima). Check out the [example site](https://mivinci.github.io/hugo-theme-minima). ![screenshot](./images/tn.png) -> Note that the main branch is in development stage, UI or configuration may vary. +> Note that the main branch is in development phase, UI or configuration may vary. ## Features -- [x] Dark mode -- [x] Multilingual mode -- [x] Code highlighting - VSCode dark+ -- [x] Math - KaTeX -- [x] Flowcharts - Mermaid -- [x] Comment - Disqus, Utterances, Giscus -- [x] Google analytics -- [x] External link -- [x] RSS +- [x] 🌗 Dark mode +- [x] 📚 Multilingual mode +- [x] 🏳️‍🌈 Code highlighting - VSCode dark+ +- [x] 🔢 Math - KaTeX +- [x] 💹 Flowcharts - Mermaid +- [x] 🧑‍💻 Comment - Disqus, Utterances, Giscus +- [x] 🔎 Search - FuseJS +- [x] 〽️ Google analytics +- [x] 🔗 External link +- [x] ✉️ RSS ## Usage diff --git a/assets/css/main.scss b/assets/css/main.scss index 46ce128..f17d305 100644 --- a/assets/css/main.scss +++ b/assets/css/main.scss @@ -44,6 +44,16 @@ main p a:hover { text-decoration: underline; } +main .search > input { + width: 100%; + padding: .5em; + font-size: large; + border: 2px solid var(--grid); + border-radius: 2px; + background-color: transparent; + outline: none; +} + @keyframes showup { from { opacity: 0; diff --git a/assets/css/theme.scss b/assets/css/theme.scss index 40f4411..9cc4561 100644 --- a/assets/css/theme.scss +++ b/assets/css/theme.scss @@ -46,6 +46,7 @@ --prime: #3170a7; --back: #e6dece; --text: #434343; + --grid: #555; --code-back: #dbd3c1be; --code-text: #24292f; @@ -58,6 +59,7 @@ --prime: #3170a7; --back: #ccc; --text: #434343; + --grid: #555; --code-back: #c1c1c1be; --code-text: #24292f; diff --git a/assets/js/min/fuse.basic.min.js b/assets/js/min/fuse.basic.min.js new file mode 100644 index 0000000..89477c6 --- /dev/null +++ b/assets/js/min/fuse.basic.min.js @@ -0,0 +1,9 @@ +/** + * Fuse.js v6.6.2 - Lightweight fuzzy-search (http://fusejs.io) + * + * Copyright (c) 2022 Kiro Risk (http://kiro.me) + * All Rights Reserved. Apache Software License 2.0 + * + * http://www.apache.org/licenses/LICENSE-2.0 + */ +var e,t;e=this,t=function(){"use strict";function e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function t(t){for(var n=1;ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,n=new Map,r=Math.pow(10,t);return{get:function(t){var i=t.match(_).length;if(n.has(i))return n.get(i);var o=1/Math.pow(i,.5*e),a=parseFloat(Math.round(o*r)/r);return n.set(i,a),a},clear:function(){n.clear()}}}var O=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.getFn,i=void 0===n?L.getFn:n,o=t.fieldNormWeight,a=void 0===o?L.fieldNormWeight:o;r(this,e),this.norm=S(a,3),this.getFn=i,this.isCreated=!1,this.setIndexRecords()}return o(e,[{key:"setSources",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.docs=e}},{key:"setIndexRecords",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.records=e}},{key:"setKeys",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.keys=t,this._keysMap={},t.forEach((function(t,n){e._keysMap[t.id]=n}))}},{key:"create",value:function(){var e=this;!this.isCreated&&this.docs.length&&(this.isCreated=!0,u(this.docs[0])?this.docs.forEach((function(t,n){e._addString(t,n)})):this.docs.forEach((function(t,n){e._addObject(t,n)})),this.norm.clear())}},{key:"add",value:function(e){var t=this.size();u(e)?this._addString(e,t):this._addObject(e,t)}},{key:"removeAt",value:function(e){this.records.splice(e,1);for(var t=e,n=this.size();t2&&void 0!==arguments[2]?arguments[2]:{},r=n.getFn,i=void 0===r?L.getFn:r,o=n.fieldNormWeight,a=void 0===o?L.fieldNormWeight:o,c=new O({getFn:i,fieldNormWeight:a});return c.setKeys(e.map(k)),c.setSources(t),c.create(),c}function j(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.errors,r=void 0===n?0:n,i=t.currentLocation,o=void 0===i?0:i,a=t.expectedLocation,c=void 0===a?0:a,s=t.distance,h=void 0===s?L.distance:s,u=t.ignoreLocation,l=void 0===u?L.ignoreLocation:u,d=r/e.length;if(l)return d;var f=Math.abs(c-o);return h?d+f/h:f?1:d}function E(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:L.minMatchCharLength,n=[],r=-1,i=-1,o=0,a=e.length;o=t&&n.push([r,i]),r=-1)}return e[o-1]&&o-r>=t&&n.push([r,o-1]),n}var I=32;function F(e){for(var t={},n=0,r=e.length;n1&&void 0!==arguments[1]?arguments[1]:{},o=i.location,a=void 0===o?L.location:o,c=i.threshold,s=void 0===c?L.threshold:c,h=i.distance,u=void 0===h?L.distance:h,l=i.includeMatches,d=void 0===l?L.includeMatches:l,f=i.findAllMatches,v=void 0===f?L.findAllMatches:f,g=i.minMatchCharLength,y=void 0===g?L.minMatchCharLength:g,p=i.isCaseSensitive,m=void 0===p?L.isCaseSensitive:p,b=i.ignoreLocation,k=void 0===b?L.ignoreLocation:b;if(r(this,e),this.options={location:a,threshold:s,distance:u,includeMatches:d,findAllMatches:v,minMatchCharLength:y,isCaseSensitive:m,ignoreLocation:k},this.pattern=m?t:t.toLowerCase(),this.chunks=[],this.pattern.length){var M=function(e,t){n.chunks.push({pattern:e,alphabet:F(e),startIndex:t})},w=this.pattern.length;if(w>I){for(var x=0,_=w%I,S=w-_;x3&&void 0!==arguments[3]?arguments[3]:{},i=r.location,o=void 0===i?L.location:i,a=r.distance,c=void 0===a?L.distance:a,s=r.threshold,h=void 0===s?L.threshold:s,u=r.findAllMatches,l=void 0===u?L.findAllMatches:u,d=r.minMatchCharLength,f=void 0===d?L.minMatchCharLength:d,v=r.includeMatches,g=void 0===v?L.includeMatches:v,y=r.ignoreLocation,m=void 0===y?L.ignoreLocation:y;if(t.length>I)throw new Error(p(I));for(var b,k=t.length,M=e.length,w=Math.max(0,Math.min(o,M)),x=h,_=w,S=f>1||g,O=S?Array(M):[];(b=e.indexOf(t,_))>-1;){var A=j(t,{currentLocation:b,expectedLocation:w,distance:c,ignoreLocation:m});if(x=Math.min(A,x),_=b+k,S)for(var F=0;F=T;R-=1){var U=R-1,B=n[e.charAt(U)];if(S&&(O[U]=+!!B),J[R]=(J[R+1]<<1|1)&B,$&&(J[R]|=(C[R+1]|C[R])<<1|1|C[R+1]),J[R]&W&&(N=j(t,{errors:$,currentLocation:U,expectedLocation:w,distance:c,ignoreLocation:m}))<=x){if(x=N,(_=U)<=w)break;T=Math.max(1,2*w-_)}}if(j(t,{errors:$+1,currentLocation:w,expectedLocation:w,distance:c,ignoreLocation:m})>x)break;C=J}var V={isMatch:_>=0,score:Math.max(.001,N)};if(S){var q=E(O,f);q.length?g&&(V.indices=q):V.isMatch=!1}return V}(e,n,i,{location:a+o,distance:s,threshold:h,findAllMatches:u,minMatchCharLength:l,includeMatches:r,ignoreLocation:d}),m=y.isMatch,b=y.score,k=y.indices;m&&(g=!0),v+=b,m&&k&&(f=[].concat(c(f),c(k)))}));var y={isMatch:g,score:g?v/this.chunks.length:1};return g&&r&&(y.indices=f),y}}]),e}(),N=[];function P(e,t){for(var n=0,r=N.length;n-1&&(n.refIndex=e.idx),t.matches.push(n)}}))}function D(e,t){t.score=e.score}function K(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.includeMatches,i=void 0===r?L.includeMatches:r,o=n.includeScore,a=void 0===o?L.includeScore:o,c=[];return i&&c.push($),a&&c.push(D),e.map((function(e){var n=e.idx,r={item:t[n],refIndex:n};return c.length&&c.forEach((function(t){t(e,r)})),r}))}var T=function(){function e(n){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=arguments.length>2?arguments[2]:void 0;if(r(this,e),this.options=t(t({},L),i),this.options.useExtendedSearch)throw new Error(y);this._keyStore=new b(this.options.keys),this.setCollection(n,o)}return o(e,[{key:"setCollection",value:function(e,t){if(this._docs=e,t&&!(t instanceof O))throw new Error("Incorrect 'index' type");this._myIndex=t||A(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}},{key:"add",value:function(e){f(e)&&(this._docs.push(e),this._myIndex.add(e))}},{key:"remove",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){return!1},t=[],n=0,r=this._docs.length;n1&&void 0!==arguments[1]?arguments[1]:{},n=t.limit,r=void 0===n?-1:n,i=this.options,o=i.includeMatches,a=i.includeScore,c=i.shouldSort,s=i.sortFn,h=i.ignoreFieldNorm,d=u(e)?u(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e);return W(d,{ignoreFieldNorm:h}),c&&d.sort(s),l(r)&&r>-1&&(d=d.slice(0,r)),K(d,this._docs,{includeMatches:o,includeScore:a})}},{key:"_searchStringList",value:function(e){var t=P(e,this.options),n=this._myIndex.records,r=[];return n.forEach((function(e){var n=e.v,i=e.i,o=e.n;if(f(n)){var a=t.searchIn(n),c=a.isMatch,s=a.score,h=a.indices;c&&r.push({item:n,idx:i,matches:[{score:s,value:n,norm:o,indices:h}]})}})),r}},{key:"_searchLogical",value:function(e){throw new Error("Logical search is not available")}},{key:"_searchObjectList",value:function(e){var t=this,n=P(e,this.options),r=this._myIndex,i=r.keys,o=r.records,a=[];return o.forEach((function(e){var r=e.$,o=e.i;if(f(r)){var s=[];i.forEach((function(e,i){s.push.apply(s,c(t._findMatches({key:e,value:r[i],searcher:n})))})),s.length&&a.push({idx:o,item:r,matches:s})}})),a}},{key:"_findMatches",value:function(e){var t=e.key,n=e.value,r=e.searcher;if(!f(n))return[];var i=[];if(h(n))n.forEach((function(e){var n=e.v,o=e.i,a=e.n;if(f(n)){var c=r.searchIn(n),s=c.isMatch,h=c.score,u=c.indices;s&&i.push({score:h,key:t,value:n,idx:o,norm:a,indices:u})}}));else{var o=n.v,a=n.n,c=r.searchIn(o),s=c.isMatch,u=c.score,l=c.indices;s&&i.push({score:u,key:t,value:o,norm:a,indices:l})}return i}}]),e}();return T.version="6.6.2",T.createIndex=A,T.parseIndex=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.getFn,r=void 0===n?L.getFn:n,i=t.fieldNormWeight,o=void 0===i?L.fieldNormWeight:i,a=e.keys,c=e.records,s=new O({getFn:r,fieldNormWeight:o});return s.setKeys(a),s.setIndexRecords(c),s},T.config=L,T},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Fuse=t(); \ No newline at end of file diff --git a/assets/js/search.js b/assets/js/search.js new file mode 100644 index 0000000..ba1455e --- /dev/null +++ b/assets/js/search.js @@ -0,0 +1,24 @@ +import * as params from '@params'; + +const search_input = document.querySelector("#search-input"); +const search_result = document.querySelector("#search-result"); + +let fuse; + +window.onload = async function() { + const data = await fetch("../index.json").then(res => res.json()); + const opts = params.search.fuse; + fuse = new Fuse(data, opts); +} + +search_input.addEventListener("input", function () { + if (!fuse) return; + const results = fuse.search(this.value.trim()); + let html = ''; + if (results.length > 0) { + for (const v of results) { + html += `
  • ${v.item.title}
  • `; + } + } + search_result.innerHTML = html; +}) diff --git a/assets/js/selectable.js b/assets/js/selectable.js index a801f89..74e1dc8 100644 --- a/assets/js/selectable.js +++ b/assets/js/selectable.js @@ -1,6 +1,8 @@ +import * as params from '@params'; + export function setup_selectable () { - const selectable = '{{ .Site.Params.selectable }}' - if (selectable === 'false') { + const selectable = params.selectable + if (!selectable) { document.documentElement.style = 'user-select:none' } } \ No newline at end of file diff --git a/assets/js/theme.js b/assets/js/theme.js index 61d5af8..f35d309 100644 --- a/assets/js/theme.js +++ b/assets/js/theme.js @@ -1,7 +1,9 @@ -const comment = '{{ .Site.Params.comment.provider }}' -const default_theme_config = '{{ .Site.Params.defaultTheme }}' -const icon_light = '{{ index .Site.Params.switch 1 }}' -const icon_dark = '{{ index .Site.Params.switch 0 }}' +import * as params from '@params'; + +const comment = params.comment.provider +const default_theme_config = params.defaulttheme +const icon_light = params.switch[1] +const icon_dark = params.switch[0] const THEME_LIGHT = default_theme_config === 'system' ? 'light' : default_theme_config const THEME_DARK = 'dark' diff --git a/exampleSite/config.yaml b/exampleSite/config.yaml index d78930a..430b3e7 100644 --- a/exampleSite/config.yaml +++ b/exampleSite/config.yaml @@ -9,7 +9,7 @@ paginate: 12 theme: hugo-theme-minima # defaultContentLanguage specifies the default language to use. defaultContentLanguage: en -# language.x setup +# language.xxx setup languages: en: languageName: EN # will be displayed in the navbar. @@ -97,15 +97,42 @@ params: reactions: true metadata: false + # search plugin + search: + enable: true + provider: fuse + title: Search + placeholder: Enter keywords + # check out https://fusejs.io + fuse: + keys: + - title + - permalink + - summary + - content + distance: 100 + location: 0 + threshold: 0.6 + ignoreLocation: false + isCaseSensitive: false + includeScore: false + includeMatches: false + minMatchCharLength: 1 + shouldSort: true + findAllMatches: false + # menu.main is an array containing what is used as the navigator. menu: main: - identifier: tags - name: "Tags" - weight: 2 + name: Tags + weight: 1 - identifier: series - name: "Series" + name: Series + weight: 2 + - identifier: search + name: 🔍 weight: 3 # taxonomies defines ways to classify yout posts. Below are some presets that @@ -115,6 +142,13 @@ taxonomies: tag: tags series: series +# outputs tells Hugo the kind of files to be rendered. +outputs: + home: + - HTML + - RSS + - JSON + # markup.highlight has two keys set to make sure that the syntax highlighting # in your posts are rendered correctly, so DO NOT edit them. markup: diff --git a/exampleSite/content/search.md b/exampleSite/content/search.md new file mode 100644 index 0000000..b6d35b5 --- /dev/null +++ b/exampleSite/content/search.md @@ -0,0 +1,4 @@ +--- +title: Search +layout: search +--- \ No newline at end of file diff --git a/exampleSite/content/search.zh-cn.md b/exampleSite/content/search.zh-cn.md new file mode 100644 index 0000000..f23353f --- /dev/null +++ b/exampleSite/content/search.zh-cn.md @@ -0,0 +1,4 @@ +--- +title: 搜索 +layout: search +--- \ No newline at end of file diff --git a/layouts/_default/search.html b/layouts/_default/search.html new file mode 100644 index 0000000..9217e8f --- /dev/null +++ b/layouts/_default/search.html @@ -0,0 +1,16 @@ +{{ define "main" }} +
    + {{- $title := .Site.Params.search.title | default .Title }} + {{- $placeholder := .Site.Params.search.placeholder | default .Title }} +

    {{ $title }}

    +

    Powered by fuse.js.

    + +
    +{{ end }} \ No newline at end of file diff --git a/layouts/index.html b/layouts/index.html index e51721c..bf01da8 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -11,8 +11,10 @@
    {{ $paginator := .Paginate (where .Site.RegularPages "Kind" "page") }} {{ range $paginator.Pages }} + {{ if ne .Page.Layout "search" }} {{ partial "item.html" . }} {{ end }} + {{ end }} {{ partial "paginator.html" . }}
    {{ if .Site.Params.friends.feeds }} diff --git a/layouts/index.json b/layouts/index.json new file mode 100644 index 0000000..5847bae --- /dev/null +++ b/layouts/index.json @@ -0,0 +1,7 @@ +{{- $.Scratch.Add "index" slice -}} +{{- range site.RegularPages -}} +{{- if ne .Layout "search" -}} + {{- $.Scratch.Add "index" (dict "title" .Title "permalink" .Permalink "summary" .Summary "content" .Plain) -}} +{{- end -}} +{{- end -}} +{{- $.Scratch.Get "index" | jsonify -}} \ No newline at end of file diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 8ef7c53..c84a497 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -1,9 +1,11 @@ + {{ if hugo.IsProduction }} {{ template "_internal/opengraph.html" . }} {{ template "_internal/twitter_cards.html" . }} {{ template "_internal/google_analytics.html" . }} + {{ end }} @@ -13,14 +15,25 @@ {{ .Site.Title }} - {{ .Title }} {{ end }} + {{ $favicon := "favicon.ico" }} + {{ $options := (dict "targetPath" "minima.css" "outputStyle" "compressed" "enableSourceMap" true) }} - {{ $style := resources.Get "css/main.scss" | resources.ExecuteAsTemplate "main.scss" . | resources.ToCSS $options }} - - {{ $options = (dict "targetPath" "minima.js" "minify" true) }} - {{ $js := resources.Get "js/main.js" | js.Build $options | resources.ExecuteAsTemplate "minima.js" . }} - + {{ $style := resources.Get "css/main.scss" | resources.ExecuteAsTemplate "main.scss" . | resources.ToCSS $options | fingerprint }} + + + {{ $options = (dict "targetPath" "minima.js" "minify" true "params" site.Params) }} + {{ $script := resources.Get "js/main.js" | js.Build $options | fingerprint }} + + {{ if and .Site.Params.search.enable (eq .Layout "search") }} + {{ $options = (dict "minify" true "params" site.Params) }} + {{ $search := resources.Get "js/search.js" | js.Build $options}} + {{ $fusejs := resources.Get "js/min/fuse.basic.min.js" }} + {{ $script := (slice $fusejs $search) | resources.Concat "assets/js/search.js" | fingerprint }} + + {{ end }} + {{ if .IsTranslated }} {{ range .Translations }} From e85cfde4fa219e6278ddb591698746e89045a455 Mon Sep 17 00:00:00 2001 From: x Date: Wed, 14 Jun 2023 12:27:56 +0800 Subject: [PATCH 53/56] default example site to light theme --- exampleSite/config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exampleSite/config.yaml b/exampleSite/config.yaml index 430b3e7..148ef5e 100644 --- a/exampleSite/config.yaml +++ b/exampleSite/config.yaml @@ -44,7 +44,7 @@ params: switch: ["🌚", "🌝"] # minima has one dark theme and multiple light themes. defaultTheme specifies # a default light theme to use. currently available options: light, sand, rock, system. - defaultTheme: sand + defaultTheme: light # displayDate speficies whether or not to display post date on the home page. displayDate: true # displayDescription specifies whether or not to display post description on From dc9616c80ae854bd4bd0d232291b193371a2815c Mon Sep 17 00:00:00 2001 From: x Date: Thu, 17 Aug 2023 16:14:50 +0800 Subject: [PATCH 54/56] nothing but to refresh deployment --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 02c3e28..18e1afb 100644 --- a/README.md +++ b/README.md @@ -52,9 +52,9 @@ Follow [exampleSite/config.yaml](https://github.com/Mivinci/hugo-theme-minima/bl | title | string | title | | description | string | description | | date | string | creation time | -| categories | array | category list | -| series | array | series list | -| tags | array | tag list | +| categories | array | category list | +| series | array | series list | +| tags | array | tag list | | math | bool | enables math plugin | | diagram | bool | enables diagram plugin | | comment | bool | enable comment plugin | From bd471708d30c0b66cffb7688791fec17335aba61 Mon Sep 17 00:00:00 2001 From: CDN18 Date: Sun, 19 May 2024 19:26:26 +0800 Subject: [PATCH 55/56] add custom fonts todo: custom css/js --- assets/css/main.scss | 2 +- layouts/partials/head.html | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/assets/css/main.scss b/assets/css/main.scss index 08d0cb6..ae8e840 100644 --- a/assets/css/main.scss +++ b/assets/css/main.scss @@ -7,7 +7,7 @@ :root { --max-w: 1080px; - --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, + --font: -apple-system, BlinkMacSystemFont, 'MiSans Latin', MiSans, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; } diff --git a/layouts/partials/head.html b/layouts/partials/head.html index d00d5cd..f121e79 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -45,6 +45,7 @@ {{ end }} {{ end }} +