Skip to content

Commit

Permalink
feat: add ability to add custom css and js
Browse files Browse the repository at this point in the history
  • Loading branch information
jletey committed Feb 27, 2019
1 parent f0bfed8 commit 4bb4bb0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
5 changes: 5 additions & 0 deletions exampleSite/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ disableHugoGeneratorInject = false
# Prefix of link to the git commit detail page. GitInfo must be enabled.
# gitUrl = ""

# Integrate Javascript files or stylesheets by adding the url to the external assets or by
# linking local files with their path relative to the static folder, e.g. "css/styles.css"
customCSS = []
customJS = []

# Toggle this option need to rebuild SCSS, requires extended version of Hugo
justifyContent = false # Set "text-align: justify" to .content.

Expand Down
8 changes: 5 additions & 3 deletions layouts/partials/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@
{{ $style := resources.Get "scss/main.scss" | resources.ToCSS | resources.Minify | resources.Fingerprint }}
<link rel="stylesheet" href="{{ $style.Permalink }}">

{{- range .Site.Params.customCSS }}
<link rel="stylesheet" href="{{ . | absURL }}">
{{- end }}
{{ range $val := $.Site.Params.customCSS }}
{{ if gt (len $val) 0 }}
<link rel="stylesheet" type="text/css" href="{{ $val }}">
{{ end }}
{{ end }}

<!-- Icons -->
{{- partial "favicons.html" }}
Expand Down
6 changes: 6 additions & 0 deletions layouts/partials/javascript.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,9 @@
ga('send', 'pageview');
</script>
{{- end}}

{{ range $val := $.Site.Params.customJS }}
{{ if gt (len $val) 0 }}
<script src="{{ $val }}"></script>
{{ end }}
{{ end }}

0 comments on commit 4bb4bb0

Please sign in to comment.