Skip to content

Commit

Permalink
CSS minification: shortcodes' CSS files are minified too
Browse files Browse the repository at this point in the history
  • Loading branch information
roneo.org committed Jan 21, 2021
1 parent fb5e203 commit 9bc4bfc
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 3 deletions.
File renamed without changes.
File renamed without changes.
5 changes: 4 additions & 1 deletion layouts/shortcodes/figure.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
Documentation and licence at https://github.com/liwenyip/hugo-easy-gallery/
-->
<!-- count how many times we've called this shortcode; load the css if it's the first time -->
{{- if not ($.Page.Scratch.Get "figurecount") }}<link rel="stylesheet" href="{{ "css/hugo-easy-gallery.css" | absURL}}" />{{ end }}
{{- if not ($.Page.Scratch.Get "figurecount") }}
{{ $hugoeasygalleryCss := resources.Get "css/hugo-easy-gallery.css" | minify }}
<link rel="stylesheet" href="{{ $hugoeasygalleryCss.Permalink }}">
{{ end }}
{{- $.Page.Scratch.Add "figurecount" 1 -}}
<!-- use either src or link-thumb for thumbnail image -->
{{- $thumb := .Get "src" | default (printf "%s." (.Get "thumb") | replace (.Get "link") ".") }}
Expand Down
4 changes: 3 additions & 1 deletion layouts/shortcodes/gallery.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
Documentation and licence at https://github.com/liwenyip/hugo-easy-gallery/
-->
<!-- count how many times we've called this shortcode; load the css if it's the first time -->
{{- if not ($.Page.Scratch.Get "figurecount") }}<link rel="stylesheet" href="{{ "css/hugo-easy-gallery.css" | absURL }}" />{{ end }}
{{- if not ($.Page.Scratch.Get "figurecount") }}
{{ $hugoeasygalleryCss := resources.Get "css/hugo-easy-gallery.css" | minify }}
<link rel="stylesheet" href="{{ $hugoeasygalleryCss.Permalink }}">{{ end }}
{{- $.Page.Scratch.Add "figurecount" 1 }}
{{ $baseURL := .Site.BaseURL }}
<div class="gallery caption-position-{{ with .Get "caption-position" | default "bottom" }}{{.}}{{end}} caption-effect-{{ with .Get "caption-effect" | default "slide" }}{{.}}{{end}} hover-effect-{{ with .Get "hover-effect" | default "zoom" }}{{.}}{{end}} {{ if ne (.Get "hover-transition") "none" }}hover-transition{{end}}" itemscope itemtype="http://schema.org/ImageGallery">
Expand Down
5 changes: 4 additions & 1 deletion layouts/shortcodes/mermaid.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<link href="{{"css/mermaid.css" | relURL}}" type="text/css" rel="stylesheet"/>

{{ $mermaidCss := resources.Get "css/mermaid.css" | minify }}
<link rel="stylesheet" href="{{ $mermaidCss.Permalink }}">

<script defer src="{{"js/mermaid.js" | relURL}}">
mermaid.initialize({startOnLoad:true});
</script>
Expand Down

0 comments on commit 9bc4bfc

Please sign in to comment.