From f14d5fa8f78a5756866002591aa479f8ccf5b582 Mon Sep 17 00:00:00 2001
From: amzrk2
Date: Sat, 30 May 2020 12:54:18 +0800
Subject: Custom highlight.js support
---
README.md | 10 ++++++++--
README_CN.md | 35 +++++++++++++++++++++--------------
layouts/partials/head.html | 15 +++++++++++++++
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
   
-[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 @@
   
-[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 @@
+{{ if .Site.Params.customHighlight }}
+
+{{ else }}
+{{ end }}
+{{ if .Params.playerURL }}
+{{ end }}
+
{{ else }}
+
+{{ if .Site.Params.customHighlight }}
+
+{{ else }}
+{{ end }}
+{{ if .Params.playerURL }}
{{ end }}
+{{ end }}
+
{{ partial "analytic-gtag.html" . }}
{{ partial "analytic-cfga.html" . }}
\ No newline at end of file
--
cgit v1.2.3