diff options
-rw-r--r-- | README.md | 10 | ||||
-rw-r--r-- | README_CN.md | 168 | ||||
-rw-r--r-- | layouts/partials/analytic-cfga.html | 7 | ||||
-rw-r--r-- | layouts/partials/analytic-gtag.html | 13 | ||||
-rw-r--r-- | layouts/partials/head.html | 15 |
5 files changed, 198 insertions, 15 deletions
@@ -4,6 +4,8 @@ Fuji is a minimal Hugo theme with full dark mode support and GitHub Primer markd     +[English](https://github.com/amzrk2/hugo-theme-fuji/blob/master/README.md) | [真正的白话文](https://github.com/amzrk2/hugo-theme-fuji/blob/master/README_CN.md) + ## Table of contents - [Live demos](#live-demos) @@ -32,7 +34,7 @@ Fuji is a minimal Hugo theme with full dark mode support and GitHub Primer markd ## Notice -Remember to add [summary divider](https://gohugo.io/content-management/summaries/#manual-summary-splitting) to your post `.md` files to show blockquotes, links and codes with proper style in list pages' summary part. +Remember to add [summary divider](https://gohugo.io/content-management/summaries/#manual-summary-splitting) `<!--more-->` to your post `.md` files to show blockquotes, links and codes with proper style in list pages' summary part. ## Getting started @@ -157,12 +159,16 @@ Use the `[SITEROOT]/layouts/partials/comment-disqus.html` to cover `themes/fuji/ ## Contributing -Did you found a bug or got an idea for a new feature? Feel free to use the [issue tracker](https://github.com/amzrk2/hugo-theme-fuji/issues) to let me know. +Note that to keep the `master` branch clean, the main development work is made under `dev` branch. Please set base branch to `dev`, then make commitment or pull request. + +Feel free to use the [issue tracker](https://github.com/amzrk2/hugo-theme-fuji/issues). The theme has only been fully tested on Firefox, so if there are some problems when accessing with Chrome or others please also report an issue. ## License The theme is released under the ```Apache License 2.0```, for more information read the [License](https://github.com/amzrk2/hugo-theme-fuji/blob/master/LICENSE). +> © 2020 DSRKafuU(amzrk2) Twitter[@amzrk2](https://twitter.com/amzrk2) + ## Annotations Thanks to [community contributors](https://github.com/amzrk2/hugo-theme-fuji/graphs/contributors) for great help. diff --git a/README_CN.md b/README_CN.md new file mode 100644 index 0000000..5143087 --- /dev/null +++ b/README_CN.md @@ -0,0 +1,168 @@ +# Fuji + +简单的 Hugo 主题,支持夜间模式,Markdown 照搬 GitHub Primer。萌新一个啥也不会,有问题尽管提( + +    + +[English](https://github.com/amzrk2/hugo-theme-fuji/blob/master/README.md) | [真正的白话文](https://github.com/amzrk2/hugo-theme-fuji/blob/master/README_CN.md) + +## 目录 + +- [在线 Demo](#live-demos) +- [注意注意注意啦](#notice) +- [所以怎么用](#getting-started) +- [更新主题](#update-the-theme) +- [看看设置项](#configration) + - [改下网站图标](#favicon) + - [这文章有点敏感,关了 License 和评论吧](#in-post-license--comments) + - [加点音乐](#aplayer) + - [放大图片;网慢,要 lazyload](#image-zoom-and-lazyload-settings) + - [Markdown 钩子](#markdown-render-hook) + - [这字体也太丑了,换掉](#custom-fonts) + - [Disqus identifier](#disqus-identifier) +- [批判一番](#contributing) +- [License](#license) +- [Annotations](#annotations) + +## 在线 Demo + +[**Demo on gohugo.io (英文)**](https://themes.gohugo.io/theme/hugo-theme-fuji/) | [My Blog (中文)](https://blog.amzrk2.cc/) + +<!--more--> + + + +## 注意注意注意啦 + +记得加上 [简介分隔线](https://gohugo.io/content-management/summaries/#manual-summary-splitting) `<!--more-->` 到文章里面,不然 Hugo 会直接自己裁剪简介,列表显示不出样式。 + +## 所以怎么用 + +```bash +$ git submodule add https://github.com/amzrk2/hugo-theme-fuji.git themes/fuji +``` + +其他的可以看[官方指南](https://gohugo.io/overview/installing/)。 + +然后把 `exampleSite` 复制出来,改下 `config.toml` 就行了。 + +## 更新主题 + +```bash +$ git submodule update --remote --merge +``` + +## 看看设置项 + +### 改下网站图标 + +用 `[SITEROOT]/layouts/partials/favicon.html` 来覆盖主题自带的图标。 + +可以在 [realfavicongenerator.net](https://realfavicongenerator.net/) 快速创建自己的图标。 + +### 这文章有点敏感,关了 License 和评论吧 + +安全第一,在 front matter 里加上这些: + +```toml +noLicense = true # 憋显示 License +noComments = true # 憋显示评论区 +``` + +### 加点音乐 + +支持给文章单独添加 APlayer,在 front matter 里加上这些: + +```toml +playerName = "..." # 标题 +playerArtist = "..." # 作者 +playerURL = "..." # URL +playerCover = "..." # 封面 +``` + +### 放大图片;网慢,要 lazyload + +可放大,非 lazyload: + +```markdown + +``` + +可放大,lazyload: + +```html +{{< img-lazy "Alt text" "test/example.png" >}} +{{< img-lazy "row" "Alt text" "test/example.png" >}} +{{< img-lazy "col" "Alt text" "test/example.png" >}} +``` + +不可放大,非 lazyload,可选外链: + +```html +{{< img-nz "Alt text" "test/example.png" ["https://example.com"] >}} +``` + +不可放大,lazyload,可选外链: + +```html +{{< img-nz-lazy "Alt text" "test/example.png" ["https://example.com"] >}} +{{< img-nz-lazy "row" "Alt text" "test/example.png" ["https://example.com"] >}} +{{< img-nz-lazy "col" "Alt text" "test/example.png" ["https://example.com"] >}} +``` + +`img-lazy` 提供 16:9 的占位 svg,`img-lazy-row` 提供 32:9 的占位 svg,`img-lazy-col` 提供 8:9 的占位 svg。你也可以在 `config.toml` 里面自定义想要的占位图片和比例。 + +### Markdown 钩子 + +具体内容看 [Hugo's Official Docs](https://gohugo.io/getting-started/configuration-markup#markdown-render-hooks),用于配置 Markdown 解释器。 + +比如你可以用 `[SITEROOT]/layouts/_default/_markup/render-link.html` 来修改文章里的链接是否在新页面打开: + +```html +<a href="{{ .Destination | safeURL }}"{{ with .Title }} title="{{ . }}"{{ end }}{{ if strings.HasPrefix .Destination "http" }} target="_blank"{{ end }}>{{ .Text | safeHTML }}</a> +``` + +### 这字体也太丑了,换掉 + +**要 Hugo Extended 版的** + +创建 `[SITEROOT]/assets/_custom.sass` 来覆盖主题的 sass 变量,以下是可以用的: + +```scss +$font-size-0: 2rem; // 16px->32px +$font-size-1: 1.75rem; // 16px->28px # +$font-size-2: 1.5rem; // 16px->24px ## +$font-size-3: 1.25rem; // 16px->20px ### +$font-size-4: 1rem; // 16px->16px #### + +$body-font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', 'Helvetica', 'Arial', 'PingFang SC', + 'Hiragino Sans GB', 'Source Han Sans CN', 'Source Han Sans SC', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; +$mono-font: 'Cascadia Code', 'SF Mono', 'Fira Code', 'Consolas', $body-font; +$body-font-size: 16px; +``` + +## Disqus identifier + +用 `[SITEROOT]/layouts/partials/comment-disqus.html` 覆盖 `themes/fuji/layouts/partials/comment-disqus.html`. + +## 批判一番 + +为了保证 `master` 分支干净,所有开发都是在 `dev` 分支进行的,记得对着 `dev` 分支批判。 + +[Issue](https://github.com/amzrk2/hugo-theme-fuji/issues)。主题本身只在 Firefox 上完整测试过,因此要是遇到了什么问题也可以随便批判。 + +## License + +The theme is released under the ```Apache License 2.0```, for more information read the [License](https://github.com/amzrk2/hugo-theme-fuji/blob/master/LICENSE). + +> © 2020 DSRKafuU(amzrk2) Twitter[@amzrk2](https://twitter.com/amzrk2) + +## Annotations + +Thanks to [community contributors](https://github.com/amzrk2/hugo-theme-fuji/graphs/contributors) for great help. + +- [Hugo](https://gohugo.io/) +- [Primer CSS](https://primer.style/css/) +- [APlayer](https://github.com/MoePlayer/APlayer) +- [lazysizes](https://github.com/aFarkas/lazysizes) +- [medium-zoom](https://github.com/francoischalifour/medium-zoom) diff --git a/layouts/partials/analytic-cfga.html b/layouts/partials/analytic-cfga.html new file mode 100644 index 0000000..ee7567e --- /dev/null +++ b/layouts/partials/analytic-cfga.html @@ -0,0 +1,7 @@ +{{ if .Site.Params.googleAnalyticsTid }} +<script> + window.ga_tid = '{{ .Site.Params.googleAnalyticsTid }}'; + window.ga_api = '{{ .Site.Params.googleAnalyticsRoute }}'; +</script> +<script src="https://cdn.jsdelivr.net/npm/cfga@1.0.1/cfga.min.js" async></script> +{{ end }}
\ No newline at end of file diff --git a/layouts/partials/analytic-gtag.html b/layouts/partials/analytic-gtag.html new file mode 100644 index 0000000..f43e48a --- /dev/null +++ b/layouts/partials/analytic-gtag.html @@ -0,0 +1,13 @@ +{{ with .Site.GoogleAnalytics }} +<!-- GA --> +<script async src="https://www.googletagmanager.com/gtag/js?id={{ . }}"></script> +<script> + window.dataLayer = window.dataLayer || []; + + function gtag() { + dataLayer.push(arguments); + } + gtag('js', new Date()); + gtag('config', '{{ . }}'); +</script> +{{ end }}
\ No newline at end of file diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 85b77cc..f52a7ce 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -56,16 +56,5 @@ <script src="{{ "/assets/js/APlayer.min.js" | relURL }}"></script> {{ end }} -{{ with .Site.GoogleAnalytics }} -<!-- GA --> -<script async src="https://www.googletagmanager.com/gtag/js?id={{ . }}"></script> -<script> - window.dataLayer = window.dataLayer || []; - - function gtag() { - dataLayer.push(arguments); - } - gtag('js', new Date()); - gtag('config', '{{ . }}'); -</script> -{{ end }}
\ No newline at end of file +{{ partial "analytic-gtag.html" . }} +{{ partial "analytic-cfga.html" . }}
\ No newline at end of file |