Skip to content

Commit

Permalink
feat: support custom css and js (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
seisman authored and olOwOlo committed Feb 3, 2018
1 parent 52eeea8 commit 33594c0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
5 changes: 5 additions & 0 deletions exampleSite/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ copyright = "" # default: author.name ↓ # 默认为下面配
baidu_verification = "" # Baidu Verification
google_verification = "" # Google_Verification # 谷歌

# Link custom CSS and JS assets
# (relative to /static/css and /static/js respectively)
customCSS = []
customJS = []

[params.publicCDN] # load these files from public cdn # 启用公共CDN,需自行定义
enable = false
jquery = '<script src="https://cdn.jsdelivr.net/npm/jquery@3.2.1/dist/jquery.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>'
Expand Down
5 changes: 5 additions & 0 deletions layouts/partials/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@
{{ if .Site.Params.fancybox }}<link href="{{ "lib/fancybox/jquery.fancybox-3.1.20.min.css" | relURL }}" rel="stylesheet">{{ end }}
{{- end }}

<!-- custom css -->
{{ range .Site.Params.customCSS }}
<link rel="stylesheet" href="{{ "/css/" | relURL }}{{ . }}">
{{ end }}

{{/* NOTE: These Hugo Internal Templates can be found starting at https://github.com/spf13/hugo/blob/master/tpl/tplimpl/template_embedded.go#L158 */}}
{{- template "_internal/opengraph.html" . -}}
{{- template "_internal/google_news.html" . -}}
Expand Down
7 changes: 6 additions & 1 deletion layouts/partials/scripts.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,9 @@
s.parentNode.insertBefore(bp, s);
})();
</script>
{{- end }}
{{- end }}

<!-- custom js -->
{{ range .Site.Params.customJS }}
<script src="{{ "/js/" | relURL }}{{ . }}"></script>
{{ end }}

0 comments on commit 33594c0

Please sign in to comment.