summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoramzrk22020-05-30 12:54:18 +0800
committeramzrk22020-05-30 12:54:18 +0800
commitf14d5fa8f78a5756866002591aa479f8ccf5b582 (patch)
tree0d3c7f625146285115b127dd604c73ab0408760b
parentcf395763b26103b1b147bc40d8a3126e92996b97 (diff)
downloadhugo-theme-fuji-f14d5fa8f78a5756866002591aa479f8ccf5b582.tar.gz
hugo-theme-fuji-f14d5fa8f78a5756866002591aa479f8ccf5b582.tar.bz2
hugo-theme-fuji-f14d5fa8f78a5756866002591aa479f8ccf5b582.zip
Custom highlight.js support
-rw-r--r--README.md10
-rw-r--r--README_CN.md35
-rw-r--r--layouts/partials/head.html15
3 files changed, 44 insertions, 16 deletions
diff --git a/README.md b/README.md
index 3345517..e67c1ba 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@ Fuji is a minimal Hugo theme with full dark mode support and GitHub Primer markd
![RELEASE](https://img.shields.io/github/v/release/amzrk2/hugo-theme-fuji?style=flat-square) ![BUILD STATUS](https://img.shields.io/github/workflow/status/amzrk2/hugo-theme-fuji/Build%20Test?style=flat-square) ![REPO SIZE](https://img.shields.io/github/repo-size/amzrk2/hugo-theme-fuji?style=flat-square) ![LICENSE](https://img.shields.io/github/license/amzrk2/hugo-theme-fuji?style=flat-square)
-[English](https://github.com/amzrk2/hugo-theme-fuji/blob/master/README.md) | [真正的白话文](https://github.com/amzrk2/hugo-theme-fuji/blob/master/README_CN.md)
+[English](https://github.com/amzrk2/hugo-theme-fuji#readme) | [白话文](https://github.com/amzrk2/hugo-theme-fuji/blob/master/README_CN.md)
## Table of contents
@@ -153,7 +153,13 @@ $mono-font: 'Cascadia Code', 'SF Mono', 'Fira Code', 'Consolas', $body-font;
$body-font-size: 16px;
```
-## Disqus identifier
+### Custom highlight.js language support
+
+Set `customHighlight` to `true` in `config.toml`, then set `customHighlightURL` to the path of your own `highlight.js`.
+
+Check [Getting highlight.js](https://highlightjs.org/download/) to download you own bundle of highlight.js.
+
+### Disqus identifier
Use the `[SITEROOT]/layouts/partials/comment-disqus.html` to cover `themes/fuji/layouts/partials/comment-disqus.html`.
diff --git a/README_CN.md b/README_CN.md
index 5143087..0f9b67a 100644
--- a/README_CN.md
+++ b/README_CN.md
@@ -4,23 +4,24 @@
![RELEASE](https://img.shields.io/github/v/release/amzrk2/hugo-theme-fuji?style=flat-square) ![BUILD STATUS](https://img.shields.io/github/workflow/status/amzrk2/hugo-theme-fuji/Build%20Test?style=flat-square) ![REPO SIZE](https://img.shields.io/github/repo-size/amzrk2/hugo-theme-fuji?style=flat-square) ![LICENSE](https://img.shields.io/github/license/amzrk2/hugo-theme-fuji?style=flat-square)
-[English](https://github.com/amzrk2/hugo-theme-fuji/blob/master/README.md) | [真正的白话文](https://github.com/amzrk2/hugo-theme-fuji/blob/master/README_CN.md)
+[English](https://github.com/amzrk2/hugo-theme-fuji#readme) | [白话文](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)
+- [在线 Demo](#在线-demo)
+- [注意注意注意啦](#注意注意注意啦)
+- [所以怎么用](#所以怎么用)
+- [更新主题](#更新主题)
+- [看看设置项](#看看设置项)
+ - [改下网站图标](#改下网站图标)
+ - [这文章有点敏感,关了 License 和评论吧](#这文章有点敏感关了-license-和评论吧)
+ - [加点音乐](#加点音乐)
+ - [放大图片;网慢,要 lazyload](#放大图片网慢要-lazyload)
+ - [Markdown 钩子](#markdown-钩子)
+ - [这字体也太丑了,换掉](#这字体也太丑了换掉)
+ - [自定义 highlight.js 支持的语言]()
- [Disqus identifier](#disqus-identifier)
-- [批判一番](#contributing)
+- [批判一番](#批判一番)
- [License](#license)
- [Annotations](#annotations)
@@ -141,7 +142,13 @@ $mono-font: 'Cascadia Code', 'SF Mono', 'Fira Code', 'Consolas', $body-font;
$body-font-size: 16px;
```
-## Disqus identifier
+### 自定义 highlight.js 支持的语言
+
+在 `config.toml` 里面把 `customHighlight` 设置为 `true`,将 `customHighlightURL` 设置为自定义的 `highlight.js` 的路径即可。
+
+语言的选择可以去 [Getting highlight.js](https://highlightjs.org/download/),非自定义情况下默认使用的即默认选项。
+
+### Disqus identifier
用 `[SITEROOT]/layouts/partials/comment-disqus.html` 覆盖 `themes/fuji/layouts/partials/comment-disqus.html`.
diff --git a/layouts/partials/head.html b/layouts/partials/head.html
index f52a7ce..b407340 100644
--- a/layouts/partials/head.html
+++ b/layouts/partials/head.html
@@ -43,18 +43,33 @@
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.13.0/css/all.min.css" />
<script src="https://cdn.jsdelivr.net/npm/lazysizes@5.2.2/lazysizes.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/medium-zoom@1.0.5/dist/medium-zoom.min.js"></script>
+{{ if .Site.Params.customHighlight }}
+<script src="{{ .Site.Params.customHighlightURL | relURL }}"></script>
+{{ else }}
<script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@10.0.3/build/highlight.min.js"></script>
+{{ end }}
+{{ if .Params.playerURL }}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aplayer@1.10.1/dist/APlayer.min.css" />
<script src="https://cdn.jsdelivr.net/npm/aplayer@1.10.1/dist/APlayer.min.js"></script>
+{{ end }}
+
{{ else }}
+
<script src="{{ "/assets/js/jquery-3.5.1.min.js" | relURL }}" data-cfasync="false"></script>
<link rel="stylesheet" href="{{ "/assets/css/fa.min.css" | relURL }}" />
<script src="{{ "/assets/js/lazysizes.min.js" | relURL }}"></script>
<script src="{{ "/assets/js/medium-zoom.min.js" | relURL }}"></script>
+{{ if .Site.Params.customHighlight }}
+<script src="{{ .Site.Params.customHighlightURL | relURL }}"></script>
+{{ else }}
<script src="{{ "/assets/js/highlight.min.js" | relURL }}"></script>
+{{ end }}
+{{ if .Params.playerURL }}
<link rel="stylesheet" href="{{ "/assets/css/APlayer.min.css" | relURL }}" />
<script src="{{ "/assets/js/APlayer.min.js" | relURL }}"></script>
{{ end }}
+{{ end }}
+
{{ partial "analytic-gtag.html" . }}
{{ partial "analytic-cfga.html" . }} \ No newline at end of file