diff --git a/README.md b/README.md index 97a5db1..6ddba56 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,8 @@ Maupassant theme, ported to Hugo. 21. 文章自定义摘要 22. 自定义广告支持 23. 自定义备案信息 +24. 自定义图片CDN +25. 图片点击放大 ## 下载安装 @@ -214,6 +216,27 @@ type: archives 以上配置中的备案信息要换成自己的 +#### 图片点击放大 + +将会引入jquery.js 和 fancybox 的css和js + +```toml +[params] + fancybox = true +``` + +#### 图片CDN + +将会在mark中引入的图片src前面加上设置的host, 有http前缀的路径不会在前面加入host +注意: 路径后面不要带/ +> 可直接使用jsdelivr加速 后面跟上github仓库即可 + +```toml +[params.image_cdn] + enable = true + Host = "https://cdn.jsdelivr.net/gh/user/user.github.io" +``` + #### Disqus 该主题支持Disqus评论,如果要启用Disqus,可以在`config.toml`里添加如下配置即可. diff --git a/layouts/_default/_markup/render-image.html b/layouts/_default/_markup/render-image.html new file mode 100644 index 0000000..ce98a79 --- /dev/null +++ b/layouts/_default/_markup/render-image.html @@ -0,0 +1,29 @@ +{{- $img_destination := .Destination -}} +{{- if (or .Page.Site.Params.image_cdn.enable (not .Page.Site.IsServer)) -}} + {{if hasPrefix .Destination "/" }} + {{ $img_destination = (print .Page.Site.Params.image_cdn.HOST .Destination) }} + {{ else if not (hasPrefix .Destination "http") }} + {{ $img_destination = (print .Page.Site.Params.image_cdn.HOST (path.Join .Page.RelPermalink .Destination)) }} + {{ end }} +{{- end -}} + +{{- if .Title -}} +
+ {{if .Page.Site.Params.fancybox }} + + {{ $.Text }} + + {{ else }} + {{ $.Text }} + {{ end }} +
{{ with $.Title | safeHTML }}{{ . }}{{ end }}
+
+{{- else -}} + {{if .Page.Site.Params.fancybox }} + + {{ $.Text }} + + {{ else }} + {{ $.Text }} + {{ end }} +{{- end -}} \ No newline at end of file diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index c239b2b..01b2f19 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -121,6 +121,11 @@ }; + + {{- if .Site.Params.fancybox -}} + + + {{- end -}} {{ end }} diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 793a6cd..b5f9992 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -42,6 +42,10 @@ {{ end }} + {{if .Site.Params.fancybox }} + + {{ end }} + {{ range .Site.Params.customCSS }}