Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unneeded highlight CSS, fix disable_highlight, clean up highlight template #135

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions exampleSite/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ canonifyURLs = true

# options for highlight.js (version, additional languages, and theme)
disable_highlight = false # set to true to disable Highlight
highlightjsVersion = "9.11.0"
highlightjsCDN = "//cdn.bootcss.com"
highlightjsVersion = "9.12.0"
highlightjsCDN = "//cdnjs.cloudflare.com/ajax/libs"
highlightjsLang = ["r", "yaml", "css"]
highlightjsTheme = "github"
MathJaxCDN = "//cdn.bootcss.com"
Expand Down
17 changes: 9 additions & 8 deletions layouts/partials/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,19 @@
{{ $.Scratch.Set "jsFiles" false }}
{{ end }}

{{ if (not .Params.disable_highlight) }}
{{ $highVer := .Site.Params.highlightjsVersion }}
{{ $highCDN := (.Site.Params.highlightjsCDN | default "//cdn.bootcss.com") }}
{{ if (not (eq $highVer "")) }}
<script src="{{ $highCDN }}/highlight.js/{{ $highVer }}/highlight.min.js"></script>
{{ if (and (not .Site.Params.disable_highlight) (not .Params.disable_highlight)) }}
{{ $highVersion := .Site.Params.highlightjsVersion | default "9.12.0" }}
{{ $highCDN := .Site.Params.highlightjsCDN | default "//cdnjs.cloudflare.com/ajax/libs" }}
<script src="{{ $highCDN }}/highlight.js/{{ $highVersion }}/highlight.min.js"></script>

{{ $.Scratch.Set "highLangs" .Site.Params.highlightjsLang }}
{{ range .Params.highlightjsLang }}{{ $.Scratch.Add "highLangs" . }}{{ end }}
{{ range ($.Scratch.Get "highLangs") }}
<script src="{{ $highCDN }}/highlight.js/{{ $highVer }}/languages/{{ . }}.min.js"></script>{{ end }}
<script>hljs.configure({languages: []}); hljs.initHighlightingOnLoad();</script>
{{ end }}
<script src="{{ $highCDN }}/highlight.js/{{ $highVersion }}/languages/{{ . }}.min.js"></script>
{{ end }}
<script>hljs.initHighlightingOnLoad();</script>
{{ end }}

<!-- If the value "default" is passed into the param then we will first
load the standard js files associated with the theme -->
{{ if or (in ($.Scratch.Get "jsFiles") "default") (eq ($.Scratch.Get "jsFiles") false) }}
Expand Down
13 changes: 6 additions & 7 deletions layouts/partials/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
<!-- If the value "default" is passed into the param then we will first
load the standard css files associated with the theme -->
{{ if or (in ($.Scratch.Get "cssFiles") "default") (eq ($.Scratch.Get "cssFiles") false) }}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/atom-one-light.min.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Raleway:400,800,900|Source+Sans+Pro:400,700">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.1.25/jquery.fancybox.min.css">
Expand All @@ -68,12 +67,12 @@
{{ end }}
{{ end }}

{{ if (not .Params.disable_highlight) }}
{{ $highTheme := .Site.Params.highlightjsTheme }}
{{ with .Site.Params.highlightjsVersion }}
<link href='{{ $.Site.Params.highlightjsCDN | default "//cdn.bootcss.com" }}/highlight.js/{{ . }}/styles/{{ $highTheme }}.min.css' rel='stylesheet' type='text/css' />
{{ end }}
{{ end }}
{{ if (and (not .Site.Params.disable_highlight) (not .Params.disable_highlight)) }}
{{ $highTheme := .Site.Params.highlightjsTheme | default "github" }}
{{ $highVersion := .Site.Params.highlightjsVersion | default "9.12.0" }}
{{ $highCDN := .Site.Params.highlightjsCDN | default "//cdnjs.cloudflare.com/ajax/libs" }}
<link href='{{ $highCDN }}/highlight.js/{{ $highVersion }}/styles/{{ $highTheme }}.min.css' rel='stylesheet' type='text/css' />
{{ end }}

{{ template "_internal/google_analytics.html" . }}
</head>
Expand Down